r/ComputerCraft • Computercraft graphics research • Oct 16 '22

Finally after third try got my 3D rendering library running. featuring full shader and texture support with standard rendering pipeline, would yall appreciate such a lib if it had all the useful tools for thiese things. would like to hear if any of you would find this useful, and what do you think.

86 Upvotes

23 comments sorted by

10

u/9551-eletronics Computercraft graphics research Oct 16 '22
this is the code that was used for this video

local object

function c3d.load()
    object = c3d.geometry.cube_simple():add_param("texture",c3d.graphics.load_texture("cc.ppm"))
    :push():reposition(0,0,2)
    :set_vertex_shader(function(vertice,...)
        vertice[2] = vertice[2] + math.sin(vertice[1] + os.epoch("utc")/250)/5

        return c3d.shader.default.vertex(vertice,...)
    end)
end

local rx,ry,px,py,pz = 0,0,0,0,2
function c3d.update()
    object:set_rotation(rx,ry,0)
    object:reposition(px,py,pz)

    local dt = 0.1
    if c3d.keyboard.is_down("up") then
        rx = rx - 100*dt
    end
    -- and other ifs for more directions lol
end

2

u/exoflame Oct 16 '22

Beautiful ! 😁

2

u/9551-eletronics Computercraft graphics research Oct 16 '22

Thanks !

3

u/lazer_aio Oct 16 '22

Impressive! Is the video spedup? if not then how is the fps so high and do you think it's possible to make this run doom?

4

u/9551-eletronics Computercraft graphics research Oct 16 '22

Nope this is realtime. But don't forget its renderings just 12 faces !

If you used CCs default screen aize you could probably render something larger/more detailed.

Basically sacrifice resolution for kore complex geometries

1

u/lazer_aio Oct 16 '22

Not sure what you mean by 12 faces, a cube has 6.

but do you think it might be possible to render inside the cube? Basically as if the camera was inside the cube, that way you could fake a room and perhaps fake doors. Then you would simply need to change cube once you passed a door and you would have a basic map!

9

u/9551-eletronics Computercraft graphics research Oct 16 '22

You can render inside the cube by just disabling the backface culling.

Yes cube has 6 faces bt each one is made out of 2 triangles

In total a cube has 12 triangles 8 vertices 6 faces

2

u/xeshP Oct 18 '22

This is really impressive!

Keep up the good work like to see more of that :)

1

u/9551-eletronics Computercraft graphics research Oct 18 '22

I was thinking of posting more but i don't want it to feel spammy

2

u/xeshP Oct 19 '22

no way its more interesting

i never seen in it in that way u do it and i think this can be very useful thx for sharing

2

u/9551-eletronics Computercraft graphics research Oct 19 '22

Thanksm i have just realized that i have not actually linked the thing ! I should probably add a comment with the link.

1

u/ChrisCringe Nov 22 '22

Please keep posting

1

u/Harmed_Burglar You are the nil to my peripheral.wrap( ) Oct 17 '22

How'd you get the resolution so high?

3

u/9551-eletronics Computercraft graphics research Oct 17 '22

I used the CraftOS pc emulator to get a large window and i also use special mosaic characters to get 6x more pixels from that

2

u/theCyanEYED Oct 17 '22

Now you need to do the GameCube boot animation

1

u/herrkatze12 Oct 17 '22

Would it be possible to make a game using this?

2

u/fatboychummy Oct 17 '22

Yes but performance would be a question due to it running on Lua

2

u/Harmed_Burglar You are the nil to my peripheral.wrap( ) Oct 17 '22

Damn, isn't lua generally ok with performance though

2

u/fatboychummy Oct 17 '22

Lua is an interpreted language, not a compiled language. Because of this it is a lot slower.

Not to mention that the lua framework is running on Java in CC.

2

u/zarlo5899 Oct 17 '22

unless you are running in luaJIT

1

u/fatboychummy Oct 17 '22

LuaJIT is quite fast sure, but we are talking in the context of CC, which isn't LuaJIT.

1

u/Harmed_Burglar You are the nil to my peripheral.wrap( ) Oct 17 '22

Zoinks

1

u/Axelouuu ComputerCrafter Oct 17 '22

Amazing !