Rasterizer Progress

without comments

Nothing too exciting…

The rasterizer sample now loads all the major geometric primitives supported by the ray-tracing sample. The code changes required a handful of minor fixes here and there (as the same code was now being used in a different context, thus exposing some holes in the original code), but otherwise was fairly trivial.

The current code uses a simple smooth-shading, normal shader as lights and materials are not yet implemented in the sample.  Also, there’s some disparity in the camera setup, which I suspect is due to an error in the ray tracing camera setup code as the rasterizer camera setup is quite concise.

Geometry Only

Rasterizer sample showing the basic geometric primitives using a normal-based shader

Unused Uniform Variables in GLSL

In GLSL, if a uniform variable is declared but never used, then glGetUniformLocation() will return -1 (i.e. not found) for that variable.  This is good to know since (1) it saves some time if you’re doing incremental development and try testing your code when it’s setting the variable but not yet using its value, and (2) it means that in dynamically constructed shaders, it’s okay to include “extra” uniforms that may not be used – the shader compilation will remove the unused variable – and as long as the client code first checks for the presence of the uniform in the final program, some client-side setup can likewise be skipped.

Update: Phong Shading (Initial Imp.)

The code has been updated to read and use the lights from the scene files to produce simple Phong shading.  It is not a full implementation yet, but the basic GLSL parameter passing in place.

Unfortunately, the geometry below is all currently flat-shaded.  I need to add code to detect the flat versus smooth faces in the .blend file and update the geometry shader to respect that flag.

 

Update v2: IJW Code Reuse

Scripting: it just worked (again).  The Javascript implementation was essentially fully reusable from the ray tracing sample.  It took about 30 seconds of coding to get a scene that uses Javascript to create the scene to display with the new rasterization sample.

Sure there are still visual fidelity issues, but it’s great to see that the LxEngine code base is achieving its goal of being highly reusable without a confusing level of abstraction / generalization in the components themselves.

Written by arthur

May 31st, 2011 at 10:11 am

 

Leave a Reply