35 out vec3 vFragPos; |
35 out vec3 vFragPos; |
36 out vec3 vNormal; |
36 out vec3 vNormal; |
37 uniform mat4 modelMatrix; |
37 uniform mat4 modelMatrix; |
38 uniform mat4 viewMatrix; |
38 uniform mat4 viewMatrix; |
39 uniform mat4 projectionMatrix; |
39 uniform mat4 projectionMatrix; |
|
40 uniform int fragmentStyle; |
|
41 |
|
42 const int FRAGSTYLE_Normal = 0; |
|
43 const int FRAGSTYLE_BfcGreen = 1; |
|
44 const int FRAGSTYLE_BfcRed = 2; |
|
45 const int FRAGSTYLE_Random = 3; |
40 |
46 |
41 void main() |
47 void main() |
42 { |
48 { |
43 mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); |
49 mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); |
44 vNormal = normalize(normalMatrix * normal); |
50 vNormal = normalize(normalMatrix * normal); |
45 vColor = color; |
51 if (fragmentStyle == FRAGSTYLE_BfcGreen) |
|
52 { |
|
53 vColor = vec4(0.2, 0.9, 0.2, 1.0); |
|
54 } |
|
55 else if (fragmentStyle == FRAGSTYLE_BfcRed) |
|
56 { |
|
57 vColor = vec4(0.9, 0.2, 0.2, 1.0); |
|
58 } |
|
59 else |
|
60 { |
|
61 vColor = color; |
|
62 } |
46 vFragPos = vec3(modelMatrix * vec4(position, 1.0)); |
63 vFragPos = vec3(modelMatrix * vec4(position, 1.0)); |
47 gl_Position = projectionMatrix * viewMatrix * vec4(vFragPos, 1.0); |
64 gl_Position = projectionMatrix * viewMatrix * vec4(vFragPos, 1.0); |
48 } |
65 } |
49 )"; |
66 )"; |
50 |
67 |