Specular ya deberia furula

This commit is contained in:
roberto.mc
2024-11-14 16:47:14 -06:00
parent 74f4f7c7eb
commit 52ef897137

View File

@@ -5,6 +5,7 @@ const char * vs =
"layout (location = 1) in float aPos_y;"
"layout (location = 2) in float aPos_z;"
"layout (location = 3) in float aPos_w;"
"layout (location = 4) in float aNormal_x;"
"layout (location = 5) in float aNormal_y;"
"layout (location = 6) in float aNormal_z;"
@@ -45,28 +46,32 @@ const char * fs_plain =
" FragColor = texture( palette, vec3( 0, 0, index ) ).rgba;"
"}";
const char * fs =
"#version 330 core\n"
"#version 330 core\n"
"uniform sampler2DArray palette;"
"uniform sampler2DArray palette;"
"in float index;"
"out vec4 FragColor;"
"in vec3 Normal;"
"in vec3 FragPos;"
"in float index;"
"out vec4 FragColor;"
"in vec3 Normal;"
"in vec3 FragPos;"
"uniform vec3 viewPos;\n"
"const float specularStrength = 0.5;\n"
"void main()"
"{"
"void main()"
"{"
" vec4 color = texture(palette, vec3(0, 0, index));\n"
" vec3 lightPos = vec3(0, 0, -15);\n"
" vec3 lightDir = normalize(lightPos - FragPos);\n"
" vec4 color = texture( palette, vec3( 0, 0, index ) ).rgba;"
" vec3 lightPos = vec3(0,0,-15);"
" vec3 lightDir = normalize(lightPos - FragPos);"
" float diffuse = max(dot(Normal, lightDir), 0.0);\n"
" float diffuse = max(dot(Normal, lightDir), 0.0);"
" float ambient = 0.5;"
" FragColor = (ambient + diffuse)*color;"
"}";
" vec3 viewDir = normalize(viewPos - FragPos);\n"
" vec3 reflectDir = reflect(-lightDir, Normal);\n"
" float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);\n"
" vec3 specular = specularStrength * spec * vec3(1.0); \n"
" vec3 result = (0.5 + 0.5 * diffuse) * color.rgb + specular;\n"
" FragColor = vec4(result, color.a);\n"
"}";