Clean up codebase, rm texture, matrix -> load
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const char * vs =
|
||||
const char *vs =
|
||||
#ifdef EMSCRIPTEN
|
||||
"#version 300 es\n"
|
||||
"precision highp float;"
|
||||
@@ -15,94 +15,84 @@ const char * vs =
|
||||
"layout (location = 6) in float aNormal_z;"
|
||||
"layout (location = 7) in float aNormal_w;"
|
||||
|
||||
"uniform uint idx;"
|
||||
|
||||
"uniform uint i;"
|
||||
"uniform float angle;"
|
||||
"uniform float i;"
|
||||
"uniform vec4 color;"
|
||||
|
||||
"uniform mat4 fix;"
|
||||
"uniform mat4 rot;"
|
||||
"uniform mat4 mdl;"
|
||||
|
||||
"flat out uint index;"
|
||||
"out vec3 Normal;"
|
||||
"out vec3 FragPos;"
|
||||
"out vec4 Color;"
|
||||
|
||||
"mat2 rotate2d( float angle )"
|
||||
"{"
|
||||
"return mat2( cos(angle), sin(angle), -sin(angle), cos(angle) );"
|
||||
"return mat2( cos(angle), sin(angle), -sin(angle), cos(angle) );"
|
||||
"}"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
" index=idx;"
|
||||
" Color=color;"
|
||||
|
||||
" vec3 aNormal = vec3(aNormal_x,aNormal_y,aNormal_z);"
|
||||
" vec3 aPos = vec3(aPos_x,aPos_y,aPos_z);"
|
||||
|
||||
" aNormal[i] = (vec2(aNormal[i], aNormal_w) * rotate2d(angle))[0];"
|
||||
" aPos[i] = (vec2(aPos[i], aPos_w) * rotate2d(angle))[0];"
|
||||
" aNormal[int(i)] = (vec2(aNormal[int(i)], aNormal_w) * "
|
||||
"rotate2d(angle))[0];"
|
||||
" aPos[int(i)] = (vec2(aPos[int(i)], aPos_w) * rotate2d(angle))[0];"
|
||||
|
||||
" Normal = mat3(transpose(inverse(rot*mdl))) * aNormal;"
|
||||
" gl_Position = fix * rot * mdl * vec4( aPos, 1.0 );\n"
|
||||
" FragPos = vec3( rot * mdl * vec4(aPos, 1.0));"
|
||||
" Normal = mat3(transpose(inverse(rot))) * aNormal;"
|
||||
" gl_Position = fix * rot * vec4( aPos, 1.0 );\n"
|
||||
" FragPos = vec3( rot * vec4(aPos, 1.0));"
|
||||
"}";
|
||||
|
||||
|
||||
const char * fs_plain =
|
||||
const char *fs_plain =
|
||||
#ifdef EMSCRIPTEN
|
||||
"#version 300 es\n"
|
||||
|
||||
"precision highp float;"
|
||||
"precision highp sampler2DArray;"
|
||||
#else
|
||||
"#version 330 core\n"
|
||||
#endif
|
||||
"uniform sampler2DArray palette;"
|
||||
|
||||
"flat in uint index;"
|
||||
"out vec4 FragColor;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
"in vec4 Color;"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
" vec4 color = texture( palette, vec3(0,0,index)).rgba;"
|
||||
" FragColor = vec4(pow(vec3(color),vec3(1.0/2.2)),color.a);"
|
||||
" FragColor = vec4(pow(vec3(Color),vec3(1.0/2.2)),Color.a);"
|
||||
"}";
|
||||
|
||||
const char * fs =
|
||||
const char *fs =
|
||||
#ifdef EMSCRIPTEN
|
||||
"#version 300 es\n"
|
||||
"#version 300 es\n"
|
||||
"precision highp float;"
|
||||
"precision highp sampler2DArray;"
|
||||
#else
|
||||
"#version 330 core\n"
|
||||
"#version 330 core\n"
|
||||
#endif
|
||||
|
||||
"uniform sampler2DArray palette;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
"in vec4 Color;"
|
||||
|
||||
"flat in uint index;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
"out vec4 FragColor;"
|
||||
|
||||
"out vec4 FragColor;"
|
||||
"void main()"
|
||||
"{"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
" vec4 color = texture(palette, vec3(0, 0, index));\n"
|
||||
" vec3 viewPos = vec3(0, 0, -15);\n"
|
||||
" vec3 viewDir = normalize(viewPos - FragPos);\n"
|
||||
|
||||
" vec3 viewPos = vec3(0, 0, -15);\n"
|
||||
" vec3 viewDir = normalize(viewPos - FragPos);\n"
|
||||
" vec3 lightPos = viewPos;\n"
|
||||
" vec3 lightDir = normalize(lightPos - FragPos);\n"
|
||||
|
||||
" vec3 lightPos = viewPos;\n"
|
||||
" vec3 lightDir = normalize(lightPos - FragPos);\n"
|
||||
" vec3 halfwayDir = normalize(lightDir + viewDir);\n"
|
||||
|
||||
" vec3 halfwayDir = normalize(lightDir + viewDir);\n"
|
||||
" float specular = pow(abs(dot(normalize(Normal), halfwayDir)), 32.0);\n"
|
||||
" float diffuse = abs(dot(normalize(Normal), lightDir));\n"
|
||||
|
||||
" float specular = pow(abs(dot(normalize(Normal), halfwayDir)), 32.0);\n"
|
||||
" float diffuse = abs(dot(normalize(Normal), lightDir));\n"
|
||||
|
||||
" vec3 result = pow((0.5 + 0.5*diffuse + 1.5*specular) * color.rgb, vec3(1.0/2.2));\n"
|
||||
" FragColor = vec4(result, color.a);\n"
|
||||
"}";
|
||||
" vec3 result = pow((0.5 + 0.5*diffuse + 1.5*specular) * Color.rgb, "
|
||||
"vec3(1.0/2.2));\n"
|
||||
" FragColor = vec4(result, Color.a);\n"
|
||||
"}";
|
||||
|
||||
Reference in New Issue
Block a user