Monday 8 January 2007

Uniforms and java fields

Not sure if you know, but there is another shading language out there (yes, besides HLSL, GLSL and Cg) called SH. What it does is it allows uniforms and attributes to be treated just like normal C/C++ fields...which is nice!

What I'm working on now is a step in that direction. You extend Pass for your particular appearance/pass; declare a few Uniforms and use them just like java fields. Notice I didn't say declare, instantiate then use them just like java fields; the actual instantiation happens behind the scenes.

So, you declare a field name of type Uniform (e.g: protected Uniform4f pointSize;) the name that Volatile-Engine will use to query the location of the Uniform is pointSize. So the field in java is bound to the field in shader code...neat huh? This required a few modifications to the way Shaders and Uniforms are handled in Volatile-Engine, but I think its a step forwards...

Credit goes to MatthiasM for this one with slight modification on implementation by yours truly...

No comments: