Bonjour,
Je voulais savoir où sont les erreurs de mon shader pour afficher du phong.
Voici les vertex et fragment shaders :
Code glsl : 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
 
#version 440
 
//vertexs
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec3 Tangent;
layout(location = 3) in vec2 UVcoord;
 
uniform mat4 MVP;
uniform mat4 V;
uniform mat4 M;
uniform mat4 NormalMatrix;
 
out vec3 L;
out vec3 C;
out vec3 N;
out vec2 UV;
 
void main()
{
	vec4 Ltmp = V * vec4(3.0, 5.0, 0.0, 1.0);
	vec4 Ptmp = V * M * vec4(Position, 1.0);
	vec3 P = Ptmp.xyz / Ptmp.w;
	L = normalize((Ltmp.xyz / Ltmp.w) - P);
	C = normalize(P - vec3(0.0));
	N = normalize(mat3(NormalMatrix) * Normal);
	UV = UVcoord;
 
 
	gl_Position = MVP * vec4(Position, 1.0);
}

Code glsl : 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
 
#version 440
 
in vec3 L;
in vec3 C;
in vec3 N;
in vec2 UV;
 
out vec4 Color;
 
uniform sampler2D samplerTexture;
 
void main()
{
	vec3 texcolor = vec3(texture(samplerTexture, UV));
	vec3 Ia = 0.1 * texcolor;
	vec3 Id = 0.5 * texcolor * max(dot(L, N), 0);
	vec3 R = normalize(-reflect(L, N));
	vec3 Is = 0.4 * vec3(1.0) * pow(max(dot(R, C), 0), 100.0);
	Color = vec4(Id, 1.0);
}

Ici NormalMatrix est égal à la transposée de l'inverse de la matrice modelview.

Mon résultat est bizarre quand mon cube tourne en autour de l'axe y :
Nom : Capture.JPG
Affichages : 205
Taille : 33,7 Ko

Je vous remercie d'avance