This commit is contained in:
Your Name
2024-10-17 17:58:55 -06:00
parent 3137c23479
commit fda999bfb1
4 changed files with 51 additions and 26 deletions

View File

@@ -31,12 +31,6 @@ narray_float_t d_cube =
A B E
B E F
};
narray_float_t n_cube =
{
3 * 3 * 2 * 6,
A C E
C E G

View File

@@ -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;"
"}";