This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Emma's profile picture

[POLL] A 3D Renderer [Accepts Wavefront objs]

Started by Emma, 02 June 2016 - 07:08 PM
Emma #1
Posted 02 June 2016 - 09:08 PM
Old post:
SpoilerSo, I've been making serious progress on my 3D renderer. And it's pretty smooth.
Here's a gif:
Spoiler
It's actually smoother when you run it than the gif shows for some reason. :/ Oh well.
Uses sub-pixel characters for that extra resolution.
Props to Bomb Bloke with his help with sub-pixel coloring.

PS: The texture on the triangle is loaded from a .bmp file. :P/>/>/>

UPDATE: So, I'm pretty much done, just a few problems to work out with clipping and then it will be done and I will release source.

Here's a nice video that demonstrates its current state:
[media]http://www.youtube.com/watch?v=qQ9clyeY6SA[/media]

UPDATE 2: So, I'm going to have a lot less time to work on this as I start my internship next week and have to leave town for the rest of this week. It struck me that some people might want the program as it is. It hurts me to release something that isn't finished, but I will not be able to work on it as much so I'm willing to make an exception if people want it.
Edited on 06 June 2016 - 08:46 PM
Creator #2
Posted 02 June 2016 - 10:59 PM
Now Yevano isn't the only one that can do magic.
Emma #3
Posted 02 June 2016 - 11:11 PM
Now Yevano isn't the only one that can do magic.

Got a cube and an icosphere render too :3
Cube:
Spoiler
Icosphere:
Spoiler
They look strange because of the UV mapping on them doesn't suit the texture being applied, but other than that. :P/>
Lignum #4
Posted 03 June 2016 - 04:05 PM
Got a cube and an icosphere render too :3
Cube:
Spoiler
Icosphere:
Spoiler
They look strange because of the UV mapping on them doesn't suit the texture being applied, but other than that. :P/>

I see wavefront in the first few frames :P/>. Does that mean it can render any model? I'd be thrilled to see the first Utah teapot in ComputerCraft.
Emma #5
Posted 03 June 2016 - 08:48 PM
Got a cube and an icosphere render too :3
Cube:
Spoiler
Icosphere:
Spoiler
They look strange because of the UV mapping on them doesn't suit the texture being applied, but other than that. :P/>

I see wavefront in the first few frames :P/>. Does that mean it can render any model? I'd be thrilled to see the first Utah teapot in ComputerCraft.

Yep, it can load any .obj
The renderer is mostly finished now, just smoothing out things with clipping, lighting, etc.
Emma #6
Posted 03 June 2016 - 10:57 PM
–snip–
I'd be thrilled to see the first Utah teapot in ComputerCraft.

Your wish is my command:
Spoiler
Btw, the stale pixels around the edges of the teapot are caused by my gif recorder not the renderer.

Edit: The reason the teapot is gray is because the .obj I used had no texture mapping information in it, I checked, it had vertices, normals, and faces, but no vt. :P/>
If you can find a texture mapped version with a texture, I will make a new gif. ;)/>
Edited on 03 June 2016 - 09:01 PM
Waitdev_ #7
Posted 04 June 2016 - 12:42 AM
Dude, this is awesome! Since you can do pretty much anything now, do a laptop :P/>
CrazedProgrammer #8
Posted 04 June 2016 - 03:12 PM
Wow, this is extremely impressive!
I can barely transform 3D vertices into 2D and draw flat triangles (not even clipped haha)
Are you going to release the program/source soon?
Anyways, great job!
Emma #9
Posted 04 June 2016 - 06:29 PM
Wow, this is extremely impressive!
I can barely transform 3D vertices into 2D and draw flat triangles (not even clipped haha)
Are you going to release the program/source soon?
Anyways, great job!

Thanks!
And I will release the source along with a tutorial of how to properly use it as soon as I fix some issues with my clipping algorithm and optimize some more. Right now the issue I am experiencing is that it takes longer to write data into my screen buffer than it takes to actually draw the buffer to the screen which is totally unacceptable. :P/>
Edited on 04 June 2016 - 04:30 PM
Bomb Bloke #10
Posted 05 June 2016 - 01:01 AM
The real problem is what happens when it takes longer for you to draw the display than it takes for repeated key events to enter the event queue… :(/>
Luca_S #11
Posted 05 June 2016 - 07:21 AM
Can it render this crazy thing I found on the internet. https://www.dropbox.com/s/us7hj97ff09hbmj/bb8.obj?dl=0

Found here: http://tf3dm.com/3d-model/bb8-35865.html
Emma #12
Posted 05 June 2016 - 05:47 PM
Can it render this crazy thing I found on the internet. https://www.dropbox....mj/bb8.obj?dl=0
Found here: http://tf3dm.com/3d-.../bb8-35865.html
Ich bezweifle das, dies war nie fur grosse Modelle wie das bedeutete Ihnen zur Verfugung gestellten, weil Lua Zahlknirschens Maschine nicht sein. Aber, ich werde versuche es sowieso. Obwohl nur raten, da die Teekanne hatte 600 Eckpunkte, und die bb8 hatte 9000. Ich bin gespannt zu sehen, wie langsam es lauft.

Ich habe versucht, jetzt ist es an dieser Stelle, ja, es macht es in Ordnung, aber es lauft bei etwa 0,5fps xD

Translation:
I doubt it, this was never meant for huge models such as the one you provided as Lua (as implemented in computercraft) isn't a great number crunching machine. But, I will try it anyways. Although just guessing since the teapot had 600-700 verts, and the bb8 model has 9000 verts, I'm curious to see how slow it will run.

I have now tried it at this point, yep, it renders it fine, but it runs at about 0.5fps xD
Edited on 05 June 2016 - 07:47 PM
Bomb Bloke #13
Posted 06 June 2016 - 02:26 AM
I for one am much more interested in the screenshot than the frame rate. ;)/>
Emma #14
Posted 06 June 2016 - 02:32 AM
I for one am much more interested in the screenshot than the frame rate. ;)/>

Quite difficult because it crashes with what I can only assume is a too long without yielding when I try to move the camera around. Will try to reduce the vertices with blender or something and try again.
Bomb Bloke #15
Posted 06 June 2016 - 02:36 AM
You may already be aware, but if you find you really do need to make your script yield more often, manually queuing and than pulling an event is generally the fastest way to go about it (as opposed to doing sleep(0), for eg).

local function snooze()
	local myEvent = tostring({})
	os.queueEvent(myEvent)
	os.pullEvent(myEvent)
end

The trick would be to adapt the function to listen for further input events, and set some bools indicating whether the current view should move again after the current frame has finished rendering.
Edited on 06 June 2016 - 12:38 AM
Emma #16
Posted 06 June 2016 - 02:23 PM
You may already be aware, but if you find you really do need to make your script yield more often, manually queuing and than pulling an event is generally the fastest way to go about it (as opposed to doing sleep(0), for eg).

local function snooze()
	local myEvent = tostring({})
	os.queueEvent(myEvent)
	os.pullEvent(myEvent)
end

The trick would be to adapt the function to listen for further input events, and set some bools indicating whether the current view should move again after the current frame has finished rendering.

Hmm, maybe I could do something sneaky like this

local function doLogic()
    os.queueEvent("FinishedQueue")
    local e,p1,p2,p3,p4,p5
    repeat
        e,p1,p2,p3,p4,p5 = os.pullEvent()
        if e=="key" then
             --perform logic
        end
    until e=="FinishedQueue"
end
Bomb Bloke #17
Posted 06 June 2016 - 03:02 PM
Exactly, yes.
Luca_S #18
Posted 06 June 2016 - 09:17 PM
Can it render this crazy thing I found on the internet. https://www.dropbox....mj/bb8.obj?dl=0
Found here: http://tf3dm.com/3d-.../bb8-35865.html
Ich bezweifle das, dies war nie fur grosse Modelle wie das bedeutete Ihnen zur Verfugung gestellten, weil Lua Zahlknirschens Maschine nicht sein. Aber, ich werde versuche es sowieso. Obwohl nur raten, da die Teekanne hatte 600 Eckpunkte, und die bb8 hatte 9000. Ich bin gespannt zu sehen, wie langsam es lauft.

Ich habe versucht, jetzt ist es an dieser Stelle, ja, es macht es in Ordnung, aber es lauft bei etwa 0,5fps xD

Translation:
I doubt it, this was never meant for huge models such as the one you provided as Lua (as implemented in computercraft) isn't a great number crunching machine. But, I will try it anyways. Although just guessing since the teapot had 600-700 verts, and the bb8 model has 9000 verts, I'm curious to see how slow it will run.

I have now tried it at this point, yep, it renders it fine, but it runs at about 0.5fps xD
I wanna see it rendering this :D/> Also why did you wrote it in german too?
Emma #19
Posted 06 June 2016 - 10:03 PM
–snip–
Also why did you wrote it in german too?

Ich sah, dass du aus Deutschland warst, und ich spreche Deutsch.

Translation:
I saw that you were from Germany and I speak German.
Luca_S #20
Posted 07 June 2016 - 07:51 PM
–snip–
Also why did you wrote it in german too?

Ich sah, dass du aus Deutschland warst, und ich spreche Deutsch.

Translation:
I saw that you were from Germany and I speak German.

:D/> Nice.

Nice way of getting around showing me the model :P/>
jv110 #21
Posted 08 October 2016 - 09:41 PM
Is this dead? I really wish this was released. Especially to see how you get such performance
Emma #22
Posted 26 May 2017 - 06:00 PM
By the way, I forgot I did this but I did release the code for someone else who asked me directly and forgot to post it here, the repo is currently setup to run in Love2D but all the CC code is still there, would just take some fiddling to get it to run. But I can't be bothered so. Here you go: https://github.com/incinirate/Bad-Software-Rendering

PS: The code runs like super mega slow now because of the stuff I added while porting it to love2d but eh
bobasrty #23
Posted 08 July 2017 - 11:12 PM
By the way, I forgot I did this but I did release the code for someone else who asked me directly and forgot to post it here, the repo is currently setup to run in Love2D but all the CC code is still there, would just take some fiddling to get it to run. But I can't be bothered so. Here you go: https://github.com/i...tware-Rendering

PS: The code runs like super mega slow now because of the stuff I added while porting it to love2d but eh
Also which program starts rendering the model or what command do i need to type in to render a model?
bobasrty #24
Posted 08 July 2017 - 11:35 PM
I tried to rewrite the code to CCLua but I am not that much of a programmer and I do not know any other programming languages. It probably need a rewrite for CC though. Plus I gave up. Someone who knows Lua should attempt this. I honestly myself wanted to try this out.
Edited on 08 July 2017 - 09:40 PM