Fix illumination

This commit is contained in:
PedroEdiaz
2024-10-17 19:42:16 -06:00
parent fda999bfb1
commit 7c76e3901a
2 changed files with 16 additions and 19 deletions

View File

@@ -16,9 +16,9 @@ const char * vs =
"void main()"
"{"
" index=idx;"
" Normal = mat3(transpose(inverse(rot*mdl))) * aNormal;"
" gl_Position = fix * rot * mdl * vec4( aPos, 1.0 );\n"
"Normal = aNormal;"
"FragPos = vec3( rot * vec4(aPos, 1.0));"
" FragPos = vec3( rot * mdl * vec4(aPos, 1.0));"
"}";
@@ -35,16 +35,16 @@ const char * fs =
"void main()"
"{"
" vec4 color = texture( palette, vec3( 0, 0, index ) ).rgba;"
" vec3 lightColor = vec3(1,1,1);"
" vec3 lightPos = vec3(10,10,10);"
" vec3 lightPos = vec3(0,000,-15);"
" vec3 lightDir = normalize(lightPos - FragPos);"
" 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;"
" float ambient = 0.5;"
" FragColor = vec4((ambient + diffuse)*lightColor,1.0)*color;"
"}";

View File

@@ -38,8 +38,6 @@ void fill_normal( float * d, float * n )
glm_vec3_copy( norm_vec, (n+1)+i );
glm_vec3_copy( norm_vec, (n+1)+i+3 );
glm_vec3_copy( norm_vec, (n+1)+i+6 );
}
}
@@ -68,7 +66,6 @@ int main( void )
gload_program( shader, fs, FRAGMENT );
use_shader( shader );
load_fix_matrix( shader, (float)WIDTH/HEIGHT );
if( !( m_cube = create_mesh( d_cube ) ) )