DirectionalLightShadowRenderer: compile error in PostShadow.vert

Hey everyone,

I tried using the DirectionalLightShadowRenderer (latest nightly build) and got a compile error:
[java]
Mrz 02, 2014 11:16:54 PM com.jme3.app.Application handleError
Schwerwiegend: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadow.vert, defines, type=Vertex, language=GLSL150] error:0(88) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(89) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(90) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(91) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(101) : error C1038: declaration of “m_LightPos” conflicts with previous declaration at 0(86)
0(103) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(110) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(112) : warning C7555: ‘varying’ is deprecated, use ‘in/out’ instead
0(114) : warning C7555: ‘attribute’ is deprecated, use ‘in/out’ instead
[/java]

Before that there is all the code of PostShadow.vert (I don’t think I need to include that, do I?)
I’m running it on a NVidia GTX 660M, if that helps you.
@nehon, I believe you are the professional for that, aren`t you?

Thanks for any hints and suggestions!

Ah, I forgot: The “TestDirectionalLightShadow”-test works for me.
But it does not work when I copy-paste the dlsr-code into mine:
[java]
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, 2048, 3);
dlsr.setLight(sunLight);
dlsr.setLambda(0.55f);
dlsr.setShadowIntensity(0.6f);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
dlsr.displayDebug();
viewPort.addProcessor(dlsr);
[/java]

I don’t think it’s a problem with my code: I tried a few older projects with dlsr that worked before and now do not.

@m41q said: Before that there is all the code of PostShadow.vert (I don't think I need to include that, do I?)

It’s actually not the code to PostShadow.vert. It’s the code that was passed to the compiler that is based on the PostShadow.vert. That’s why the log dumps it because it’s the only way to see what those line numbers actually match up to without us running and getting the same error ourselves.

1 Like
@pspeed said: It's actually not the code to PostShadow.vert. It's the code that was passed to the compiler that is _based on_ the PostShadow.vert. That's why the log dumps it because it's the only way to see what those line numbers actually match up to without us running and getting the same error ourselves.

Ahh, my bad. I jumped to conclusions :roll:

Here is the output:

[java]
Mrz 03, 2014 12:07:15 AM com.jme3.renderer.lwjgl.LwjglRenderer updateShaderSourceData
Warnung: Bad compile of:
1 #version 150 core
2 #define FILTER_MODE 0
3 #define HARDWARE_SHADOWS 1
4 #define PCFEDGE 1.0
5 #define SHADOWMAP_SIZE 2048.0
6 #ifdef NUM_BONES
7
8 #if NUM_BONES < 1 || NUM_BONES > 255
9 #error NUM_BONES must be between 1 and 255.
10 #endif
11
12 #define NUM_WEIGHTS_PER_VERT 4
13
14 attribute vec4 inHWBoneWeight;
15 attribute vec4 inHWBoneIndex;
16 uniform mat4 m_BoneMatrices[NUM_BONES];
17
18 void Skinning_Compute(inout vec4 position){
19 if (inHWBoneWeight.x != 0.0) {
20 #if NUM_WEIGHTS_PER_VERT == 1
21 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
22 #else
23 mat4 mat = mat4(0.0);
24 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
25 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
26 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
27 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
28 position = mat * position;
29 #endif
30 }
31 }
32
33 void Skinning_Compute(inout vec4 position, inout vec3 normal){
34 if (inHWBoneWeight.x != 0.0) {
35 #if NUM_WEIGHTS_PER_VERT == 1
36 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
37 normal = (mat3(m_BoneMatrices[int(inHWBoneIndex.x)][0].xyz,
38 m_BoneMatrices[int(inHWBoneIndex.x)][1].xyz,
39 m_BoneMatrices[int(inHWBoneIndex.x)][2].xyz) * normal);
40 #else
41 mat4 mat = mat4(0.0);
42 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
43 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
44 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
45 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
46 position = mat * position;
47
48 mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);
49 normal = rotMat * normal;
50 #endif
51 }
52 }
53
54 void Skinning_Compute(inout vec4 position, inout vec3 tangent, inout vec3 normal){
55 if (inHWBoneWeight.x != 0.0) {
56 #if NUM_WEIGHTS_PER_VERT == 1
57 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
58 tangent = m_BoneMatrices[int(inHWBoneIndex.x)] * tangent;
59 normal = (mat3(m_BoneMatrices[int(inHWBoneIndex.x)][0].xyz,
60 m_BoneMatrices[int(inHWBoneIndex.x)][1].xyz,
61 m_BoneMatrices[int(inHWBoneIndex.x)][2].xyz) * normal);
62 #else
63 mat4 mat = mat4(0.0);
64 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
65 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
66 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
67 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
68 position = mat * position;
69
70 mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);
71 tangent = rotMat * tangent;
72 normal = rotMat * normal;
73 #endif
74 }
75 }
76
77 #endif
78 uniform mat4 m_LightViewProjectionMatrix0;
79 uniform mat4 m_LightViewProjectionMatrix1;
80 uniform mat4 m_LightViewProjectionMatrix2;
81 uniform mat4 m_LightViewProjectionMatrix3;
82
83 uniform mat4 g_WorldViewProjectionMatrix;
84 uniform mat4 g_WorldMatrix;
85 uniform mat4 g_ViewMatrix;
86 uniform vec3 m_LightPos;
87
88 varying vec4 projCoord0;
89 varying vec4 projCoord1;
90 varying vec4 projCoord2;
91 varying vec4 projCoord3;
92
93 #ifdef POINTLIGHT
94 uniform mat4 m_LightViewProjectionMatrix4;
95 uniform mat4 m_LightViewProjectionMatrix5;
96 varying vec4 projCoord4;
97 varying vec4 projCoord5;
98 varying vec4 worldPos;
99 #else
100 #ifndef PSSM
101 uniform vec3 m_LightPos;
102 uniform vec3 m_LightDir;
103 varying float lightDot;
104 #endif
105 #endif
106
107 #ifdef PSSM
108 varying float shadowPosition;
109 #endif
110 varying vec3 lightVec;
111
112 varying vec2 texCoord;
113
114 attribute vec3 inPosition;
115
116 #ifdef DISCARD_ALPHA
117 attribute vec2 inTexCoord;
118 #endif
119
120 const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0,
121 0.0, 0.5, 0.0, 0.0,
122 0.0, 0.0, 0.5, 0.0,
123 0.5, 0.5, 0.5, 1.0);
124
125
126 void main(){
127 vec4 modelSpacePos = vec4(inPosition, 1.0);
128
129 #ifdef NUM_BONES
130 Skinning_Compute(modelSpacePos);
131 #endif
132 gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
133
134 #ifndef POINTLIGHT
135 #ifdef PSSM
136 shadowPosition = gl_Position.z;
137 #endif
138 vec4 worldPos=vec4(0.0);
139 #endif
140 // get the vertex in world space
141 worldPos = g_WorldMatrix * modelSpacePos;
142
143 #ifdef DISCARD_ALPHA
144 texCoord = inTexCoord;
145 #endif
146 // populate the light view matrices array and convert vertex to light viewProj space
147 projCoord0 = biasMat * m_LightViewProjectionMatrix0 * worldPos;
148 projCoord1 = biasMat * m_LightViewProjectionMatrix1 * worldPos;
149 projCoord2 = biasMat * m_LightViewProjectionMatrix2 * worldPos;
150 projCoord3 = biasMat * m_LightViewProjectionMatrix3 * worldPos;
151 #ifdef POINTLIGHT
152 projCoord4 = biasMat * m_LightViewProjectionMatrix4 * worldPos;
153 projCoord5 = biasMat * m_LightViewProjectionMatrix5 * worldPos;
154 #else
155 #ifndef PSSM
156 vec3 lightDir = worldPos.xyz - m_LightPos;
157 lightDot = dot(m_LightDir,lightDir);
158 #endif
159 #endif
160 }
[/java]

Hope this helps

Mhh this chnaged recently so I might have broke something :stuck_out_tongue:
Thanks for reporting, I’ll look into it.

1 Like

I get this error. Fixes?

probably…