3d rendering objects to an image?

285 views
Skip to first unread message

Tom D

unread,
Apr 23, 2014, 10:16:43 PM4/23/14
to golan...@googlegroups.com
Hi everyone,

I am trying to find / create a library which can render 3d objects onto an image (ie PNG).

For example:
Obj := engine.NewCube(1,1,1,1,1,1,1)

And engine.Render("lol.PNG")

Would project a cube with the specified coordinates and stuff on the image.

I thought this would be relatively easy to do, so I attempted it myself with some help from Mr Wikipedia. Failed miserably lol.

Has anyone done anything like this or made a library for it?

If yes, Linky :) or can you explain how you did it for someone with limited math knowledge?

Thanks,
Tom

egon

unread,
Apr 24, 2014, 2:02:21 AM4/24/14
to golan...@googlegroups.com
It depends on the rendering style.

If you want ray tracing then the code isn't too complicated:


Ray tracing, of course, can take a lot of computational power. 

If you want to go the rasterization route then start something like:


or


Basically, search either "writing ray tracer tutorial" or "writing 3d rasterizer tutorial". I haven't noticed a a software rasterizer written in Go.

+ egon

Jsor

unread,
Apr 24, 2014, 4:56:46 AM4/24/14
to golan...@googlegroups.com
The other way, which is admittedly a bit like using a bazooka to kill a fly, is to grab Open GL (github.com/go-gl/gl) and render to a framebuffer texture, then write that texture to disk. 

Jsor

unread,
Apr 24, 2014, 4:58:36 AM4/24/14
to golan...@googlegroups.com
Ah, nevermind, I see that's basically what some of Egon's links were suggesting.

Stephen Gutekanst

unread,
Apr 24, 2014, 8:46:39 PM4/24/14
to golan...@googlegroups.com
One possibility would be through OpenGL. In fact you could do it with my game engine by taking a screen-shot [1] but it might be too convoluted for your simple task.

Sadly render-to-texture isn't supported yet so you would have to set the window size to whatever image size you want and take a screenshot using the Downloadable interface on Canvas.

Stephen

Tom D

unread,
Apr 24, 2014, 9:13:31 PM4/24/14
to golan...@googlegroups.com

Yeah I can't use external libraries, must be pure go. That rasterizer tutorial looks pretty promising, I will have to do a lot of reading though.

I'm surprised no one has made one yet though!

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/SjSFj1atInY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages