What is the minimum GLSL version for the Lighting shader?

Hi all,



What is the minimum GLSL version for the Lighting shader?

Or how could I check this out?



I added the following to the VertexShader:

[java]vec4 diffuseColor;

float i;

float alpha = 1;

int maxHeight = 255;

int maxRGB_1 = 1;

float interval = maxHeight/4;

if(position.y < interval){ // blue to cyan

i = interpolate (position.y, 0.0, maxRGB_1);

diffuseColor = vec4(0, i, maxRGB_1, alpha);

}

else if(position.y < interval2){ // cyan to yellow

i = interpolate (position.y, interval
1, maxRGB_1);

diffuseColor = vec4(i, maxRGB_1, 1-i, alpha);

}

else if(position.y < interval3){ // yellow to red

i = interpolate (position.y, interval
2, maxRGB_1);

diffuseColor = vec4(maxRGB_1, 1-i, 0.0, alpha);

}

else{ // red to dark red

i = interpolate (position.y, interval3, 0.5);

diffuseColor = vec4(1-i, 0.0, 0.0, alpha);

}

gl_FrontColor = diffuseColor;



float interpolate (float z, float lowerBound, float maxRGB){

// so all values are between 0 and lowerBound

float scaled = z - lowerBound;

float interval = 63.75;

// regra de tres simples

return (scaled
maxRGB)/interval;

}

[/java]

it’s glsl 1.0

you can check it in the lighting.j3md, the technique specify the shader to use for what version of glsl

[java]

VertexShader GLSL100: Common/MatDefs/Light/Lighting.vert

FragmentShader GLSL100: Common/MatDefs/Light/Lighting.frag

[/java]

Hmm,



The computer I’m looking at prints this in the caps:

[FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, ARBprogram, GLSL100, GLSL110, GLSL120, VertexTextureFetch, FloatTexture, FloatColorBuffer, NonPowerOfTwoTextures, VertexBufferArray]


but the shadows are completely black. It switches from black to showing the terrain.

If I use the regular lighting.j3md (without the mentioned added code) it shows shadows just fine.

Maybe the position is passed differently?

Ok i think i understand…please expose your problems right in the first post next time, it’s kinda hard to understand given what you wrote.



…so your problem is that you modify the vertices’ position of a mesh in the vertex shader, and then shadows does not work properly, right?



You can’t expect it to work right away. To generate the shadow maps the scene is rendered from the light point of view, so if you don’t modify the vertices position also in the pre shadow vert shader the shadows are rendered with the unmodified ones.



Then when you render the shadows on the scene, that’s the same. So the post shadow vert shader has to be modified too.

This last step can be skipped if you use the shadowFilter instead of the shadowRenderer.



So basically in your lighting.j3md, you have the preShadow and PostShadow techniques. Change the vert shaders of those technique and add your code into them (that may nee few adaptions, but you have to offset the vertices the same way)

1 Like
…so your problem is that you modify the vertices’ position of a mesh in the vertex shader, and then shadows does not work properly, right?


Not quite. I'm really sorry, I seem to keep not explaining everything right.

I have tested for several computers (about 8 ) in some of them everything shows up with proper shadows in others the shadows are just jet black.
Of those computers I have the Caps output of 2, one of each.

Caps of the computer that shows black for shadows: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, ARBprogram, GLSL100, GLSL110, GLSL120, VertexTextureFetch, FloatTexture, FloatColorBuffer, NonPowerOfTwoTextures, VertexBufferArray]

Caps of the computer that shows good shadows: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, TextureMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, OpenGL32, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray, PackedDepthStencilBuffer]

I assumed it was a compatibility problem and was trying to figure out what was using features of more advanced versions.

ok.

Are you using RC2 or nightly?

I updated to nightly of today (15-11-2012). now it blows up with a

>Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.UnsupportedOperationException: In material: /assets/materialDefs/TerrainLightingColor.j3md
The 'FixedFunc' technique name no longer has any special meanining.
To support fixed pipeline mode, remove that technique's name entirely.
at com.jme3.material.plugins.J3MLoader.readTechnique(J3MLoader.java:421)
at com.jme3.material.plugins.J3MLoader.loadFromRoot(J3MLoader.java:516)
at com.jme3.material.plugins.J3MLoader.load(J3MLoader.java:532)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:282)
at com.jme3.material.Material.(Material.java:118)
at pt.up.fe.dceg.neptus.plugins.r3d.jme3.spacials.Element3D.setTextureTerrainWithLight(Element3D.java:188)
at pt.up.fe.dceg.neptus.plugins.r3d.jme3.spacials.TerrainFromHeightMap.initTerrain(TerrainFromHeightMap.java:127)
at pt.up.fe.dceg.neptus.plugins.r3d.jme3.ShowBathymetryState.initialize(ShowBathymetryState.java:169)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:218)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:248)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:238)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:229)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Unknown Source)


I'm guessing that the version of the material that use as a starting point is now outdated.
In the mean time I noticed an interesting bit that was added to the Custom Meshes doc will try to color with as in the Vertex Color example.

Probably not gonna be able to work on it for a while but I didn't want to leave a question in the air.
Will post back with update if that doesn't go well.

Thanks for the support!

You need to remove FixedFunc from your matDef like core devs did.

http://code.google.com/p/jmonkeyengine/source/diff?spec=svn9563&r=9546&format=side&path=/trunk/engine/src/core-data/Common/MatDefs/Light/Lighting.j3md&old_path=/trunk/engine/src/core-data/Common/MatDefs/Light/Lighting.j3md&old=9330