How Primitive WebGL Is?

I was much disappointed when I started to learn WebGL and here I will tell why.

WebGL Public Wiki page about differences between WebGL and OpenGL tells us that the differences are:

  • problems with non-power of two texture support
  • behavior of vertex attribute 0
  • no double-precision floating point support
  • no 3D texture support
  • textureLod functions are only available at vertex shaders
  • precision qualifiers behavior.

Doesn't sound much catastrophic, I thought. But now I can expand this list... a little.

  • say goodbye to glBegin/glEnd. All data should now be handled only via array buffers (glCreateBuffer). And there is also no default shader program now (glUseProgram(0) in OpenGL), you have to write your own shaders anyway.
  • no floating point support AT ALL! To create a texture from a floating point data you'll have to enable OES_texture_float or OES_texture_half_float extension. But that won't help you if you wish for a floating point internal format in your textures (in a framebuffer attachment, for example). Add one more extension (WEBGL_color_buffer_float or EXT_color_buffer_half_float) to achieve that. By the way, two last ones are not currently supported by Chrome.
  • no support for attaching whole cube maps to framebuffers (only faces). aaaand also
  • NO GEOMETRY SHADERS, HELL YEAH. (And of course no tesselation shaders.)

I'm done with it.

Add a comment

OpenGL: One-pass rendering to a cube map

Rendering to a texture is a common trick one should be able to do in OpenGL in order to implement many magnificent effects like shadows or refracting surfaces. At this point cube maps supported by OpenGL are a way to enhance those effects. For example, omnidirectional shadows become possible.

How to implement it?

There are two basic approaches. The first approach is just to render the whole scene six times for each face of the cube map. OpenGL allows binding particular face of a cube map as a framebuffer's depth/color attachment. That is a simple trick, and there are lots of articles about it over the Internet.

The second approach is one-pass rendering. It uses geometry shaders to render each triangle six times for each face, so GPU is forced to do all the work. I think this way is preferable and I'm going to show how it can be accomplished.

Add a comment

Read more: OpenGL: One-pass rendering to a cube map

Subcategories