The next step in my quest to conquer shadow maps in jme is to implement the shader needed for it. I've already implemented this twice in plain OpenGL, but I'm not sure how to do that in jme.
The main problem is that this shader requires multiple textures (one per shadow caster) and all of this has to be active for all of the nodes.
The only way I could think of to integrate this into the existing jme system would be to walk the scenegraph and alter each and every TextureState and GLSLShaderObjectsState to include the information/code I need (creating new ones for the root node for nodes that don't have any of those). This is rather tedious and something I'd like to avoid. My map is loaded from a collada file, which can contain a lot of variety in the material information.
Another more hack-ish approach would be to use OpenGL to bind the textures to the highest texture units available (I think 8 texture units are common for GLSL programs, that would be more than enough for my purposes) and to bind the GLSL shaders (the map doesn't use any shader code), avoiding the jme render system altogether. Would this cause any troubles? Is there a better approach for this?
You can looking into the rendering functionality that enforces states and enforce your GLSLShaderState and TextureState if desired. Look at the source of the ShadowedRenderPass for an example on how to enforce states.
Thanks, this would work fine for the GLSL state. However, for the texture state I can't just override, since I still need the old state and just add my own textures.
Hmmm maybe I can use the texture combine feature to my advantage? Just add a texture state to the root node, apply my textures to the highest texture units (7/6/5/… on my ATI card) and let it sort out itself?
There is a TextureCombine feature build-in as well.
Yes, that's what I was referring to. According to the sticky forum post, this should be on by default anyways?
Some classes might override it. You would need to parse the scenegraph, set desired combine mode, then do your thing, then parse the scenegraph again and restore the previous mode.
Unless all your spatial objects are preconfigured to combine textures, then you only need to manipulate the rootNode (or desired node).