I have a problem, or two actually.
- When I try to use lit material everything is black, even after I add lights.
I guess I have missed something but what?
[java]
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White);
Level.rootNode.addLight(al);
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(FastMath.PI/3, FastMath.PI/3, 0).normalizeLocal());
Level.rootNode.addLight(sun);
Level.rootNode.setShadowMode(ShadowMode.Off);
Material trackMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
trackMaterial.setBoolean("UseMaterialColors",true);
trackMaterial.setColor("Specular",ColorRGBA.White);
trackMaterial.setColor("Diffuse",ColorRGBA.White);
trackMaterial.setFloat("Shininess", 5f);
Node slope = new Node("slope");
Track track = new Track();
Mesh trackMesh = track.generateTrack(Level.analyze);
Geometry trackGeo = new Geometry("Slope", trackMesh);
trackGeo.setMaterial(trackMaterial);
trackGeo.setShadowMode(ShadowMode.Receive);
slope.attachChild(trackGeo);
slope.setCullHint(CullHint.Never);
Level.rootNode.attachChild(slope);[/java]
- When I try to use shadows it crashes, but this time it doesn’t feel like my fault.
Nothing I can guarantee though
[java]PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(assetManager, 1024, 3);
pssmRenderer.setDirection(new Vector3f(0, FastMath.PI/3, FastMath.PI/3).normalizeLocal());
app.getViewPort().addProcessor(pssmRenderer);[/java]
crashes with the error
Jul 20, 2012 10:00:59 PM com.jme3.renderer.lwjgl.LwjglRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #define FILTER_MODE 1
2 #define HARDWARE_SHADOWS 1
3 #define PCFEDGE 1.0
4 uniform mat4 m_LightViewProjectionMatrix0;
5 uniform mat4 m_LightViewProjectionMatrix1;
6 uniform mat4 m_LightViewProjectionMatrix2;
7 uniform mat4 m_LightViewProjectionMatrix3;
8
9 uniform mat4 g_WorldViewProjectionMatrix;
10 uniform mat4 g_WorldMatrix;
11
12 varying vec4 projCoord0;
13 varying vec4 projCoord1;
14 varying vec4 projCoord2;
15 varying vec4 projCoord3;
16
17 varying float shadowPosition;
18
19 varying vec2 texCoord;
20
21 attribute vec3 inPosition;
22 #ifdef DIFFUSEMAP) || defined(COLOR_MAP)
23 attribute vec2 inTexCoord;
24 #endif
25
26 const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0,
27 0.0, 0.5, 0.0, 0.0,
28 0.0, 0.0, 0.5, 0.0,
29 0.5, 0.5, 0.5, 1.0);
30
31
32 void main(){
33 gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
34
35 shadowPosition = gl_Position.z;
36 // get the vertex in world space
37 vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0);
38
39 #if defined(DIFFUSEMAP) || defined(COLOR_MAP)
40 texCoord = inTexCoord;
41 #endif
42 // populate the light view matrices array and convert vertex to light viewProj space
43 projCoord0 = biasMat * m_LightViewProjectionMatrix0 * worldPos;
44 projCoord1 = biasMat * m_LightViewProjectionMatrix1 * worldPos;
45 projCoord2 = biasMat * m_LightViewProjectionMatrix2 * worldPos;
46 projCoord3 = biasMat * m_LightViewProjectionMatrix3 * worldPos;
47 }
Jul 20, 2012 10:00:59 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadowPSSM.vert, defines, type=Vertex, language=GLSL100] error:0:22(18): preprocessor warning: extra tokens at end of directive
0:22(23): preprocessor error: syntax error, unexpected DEFINED, expecting NEWLINE