const char *vs = #ifdef EMSCRIPTEN "#version 300 es\n" "precision highp float;" #else "#version 330 core\n" #endif "layout (location = 0) in float aPos_x;" "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;" "layout (location = 7) in float aNormal_w;" "uniform float angle;" "uniform float i;" "uniform vec4 color;" "uniform mat4 fix;" "uniform mat4 rot;" "out vec3 Normal;" "out vec3 FragPos;" "out vec4 Color;" "mat2 rotate2d( float angle )" "{" "return mat2( cos(angle), sin(angle), -sin(angle), cos(angle) );" "}" "void main()" "{" " Color=color;" " vec3 aNormal = vec3(aNormal_x,aNormal_y,aNormal_z);" " vec3 aPos = vec3(aPos_x,aPos_y,aPos_z);" " 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))) * aNormal;" " gl_Position = fix * rot * vec4( aPos, 1.0 );\n" " FragPos = vec3( rot * vec4(aPos, 1.0));" "}"; const char *fs_plain = #ifdef EMSCRIPTEN "#version 300 es\n" "precision highp float;" #else "#version 330 core\n" #endif "out vec4 FragColor;" "in vec3 Normal;" "in vec3 FragPos;" "in vec4 Color;" "void main()" "{" " FragColor = vec4(pow(vec3(Color),vec3(1.0/2.2)),Color.a);" "}"; const char *fs = #ifdef EMSCRIPTEN "#version 300 es\n" "precision highp float;" #else "#version 330 core\n" #endif "in vec3 Normal;" "in vec3 FragPos;" "in vec4 Color;" "out vec4 FragColor;" "void main()" "{" " vec3 viewPos = vec3(0, 0, -15);\n" " vec3 viewDir = normalize(viewPos - FragPos);\n" " vec3 lightPos = viewPos;\n" " vec3 lightDir = normalize(lightPos - FragPos);\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" " 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" "}";