PPP
This commit is contained in:
@@ -2,6 +2,7 @@ const char * vs =
|
||||
"#version 330 core\n"
|
||||
|
||||
"layout (location = 0) in vec3 aPos;"
|
||||
"layout (location = 1) in vec3 aNormal;"
|
||||
|
||||
"uniform float idx;"
|
||||
"uniform mat4 fix;"
|
||||
@@ -9,13 +10,19 @@ const char * vs =
|
||||
"uniform mat4 mdl;"
|
||||
|
||||
"out float index;"
|
||||
"out vec3 Normal;"
|
||||
"out vec3 FragPos;"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
" index=idx;"
|
||||
" gl_Position = fix * rot * mdl * vec4( aPos, 1.0 );\n"
|
||||
"Normal = aNormal;"
|
||||
"FragPos = vec3( rot * vec4(aPos, 1.0));"
|
||||
"}";
|
||||
|
||||
|
||||
|
||||
const char * fs =
|
||||
"#version 330 core\n"
|
||||
|
||||
@@ -23,8 +30,21 @@ const char * fs =
|
||||
|
||||
"in float index;"
|
||||
"out vec4 FragColor;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
" FragColor = texture( palette, vec3( 0, 0, index ) ).rgba;"
|
||||
" vec3 lightColor = vec3(1,1,1);"
|
||||
" vec3 lightPos = vec3(10,10,10);"
|
||||
" vec3 norm = normalize(Normal);"
|
||||
|
||||
" vec3 lightDir = normalize(lightPos - FragPos);"
|
||||
|
||||
" float diffuse = max(dot(norm, lightDir), 0.0);"
|
||||
" float ambient = 0.1;"
|
||||
|
||||
" FragColor = vec4((ambient + diffuse)*lightColor,1.0)* texture( palette, vec3( 0, 0, index ) ).rgba;"
|
||||
"}";
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user