Bonjour,
J'ai un fragment shader en GLSL qui ne compile pas.
L'erreur qui en ressort est assez inhabituelle et elle ne m'aide pas vraiment à trouver le problème:
Si je commente la dernière ligne (fragColor), je n'ai plus de problème. Il semble que le problème se produit quand j'utilise la variable NdotL.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 #version 330 #extension GL_EXT_gpu_shader4 : enable in vec2 textCoordinates; //deferred textures: uniform sampler2D depthTex; uniform sampler2D colorTex; uniform sampler2D normalAndAmbientTex; uniform mat4 mInverseViewProjection; //lights and shadows: struct StructLightInfo { bool isExist; vec3 position; bool produceShadow; float constantAtt; float linearAtt; float quadraticAtt; vec4 lightAmbient; sampler2DArray depthShadowTex; mat4 mLightProjectionView[3]; mat4 mShadowOffset[3]; }; uniform StructLightInfo lightsInfo[16]; uniform float depthSplitDistance[3]; uniform vec4 globalAmbient; out vec4 fragColor; void main() { vec4 diffuse = texture2D(colorTex, textCoordinates); vec4 normalAndAmbient = vec4(texture2D(normalAndAmbientTex, textCoordinates)); vec3 normal = vec3(normalAndAmbient) * 2.0 - 1.0; float modelAmbientFactor = normalAndAmbient.a; vec4 texPosition = vec4( textCoordinates.s * 2.0 - 1.0, textCoordinates.t * 2.0 - 1.0, texture2D(depthTex, textCoordinates).r * 2.0 - 1.0, 1.0 ); vec4 position = mInverseViewProjection * texPosition; position /= position.w; if(modelAmbientFactor >= 0.999) { //no lighting fragColor = diffuse; }else { fragColor = globalAmbient * modelAmbientFactor; for(int i=0; i<16;++i) { if(lightsInfo[i].isExist) { vec3 vertexToLight = lightsInfo[i].position - vec3(position); vec3 vertexToLightNormalized = normalize(vertexToLight); float NdotL = max(dot(normal, vertexToLightNormalized), 0.0); fragColor += NdotL; //diffuse * NdotL; } } } }
Voici l'erreur:
Si nécessaire, je peux vous donner le message d'erreur complet mais il est assez long.Fragment info
-------------
Internal error: assembly compile error for fragment shader at offset 15355:
-- error message --
line 250, column 35: error: invalid local parameter number
line 256, column 19: error: out of bounds array access
line 258, column 18: error: out of bounds array access
line 259, column 35: error: out of bounds array access
line 263, column 18: error: out of bounds array access
line 268, column 17: error: out of bounds array access
//........
-- internal assembly text --
!!NVfp4.1
OPTION NV_parameter_buffer_object2;
# cgc version 3.1.0001, build date Apr 30 2012
# command line args:
#vendor NVIDIA Corporation
#version 3.1.0.1
#profile gp4_1fp
#program main
#semantic depthTex
#semantic colorTex
#semantic normalAndAmbientTex
#semantic mInverseViewProjection
#semantic lightsInfo
//.......
Merci d'avance.
Partager