WebGL: Generating textures/ offscreen rendering?

116 views
Skip to first unread message

Joey Eremondi

unread,
Jun 16, 2014, 2:11:03 AM6/16/14
to elm-d...@googlegroups.com
I'm wondering, is it possible with the way the WebGL library is structured, to have the following features:

- A way to take a 2D Array/list of Vec3's and convert them into a Texture
- A way to render a scene to an offscreen buffer, either a texture or an array of Vec3's for colors

The first has a lot of uses. I think the most common one is supplying a solid color for a texture, which is particularly useful when you get to things like Specular or bump maps being supplied as a texture, and for having "default" texture values which don't need to be loaded using signals.

The second is useful for things like shadow maps and reflection/refraction maps.

I'm thinking something along the lines of:

createTexture : [[Vec3]] -> Texture

webglOffscreen : [Entity] -> [[Vec3]]

The type [[Vec3]] could be replaced by Array (Array Vec3), or even Dict (Int, Int) Vec3.

I don't understand enough of how the WebGL native module works to implement these (though I'm willing to learn), but I thought I'd put the idea out there before I put too much effort into coding anything up.

Thanks!

Joey
Reply all
Reply to author
Forward
0 new messages