Fix skin shader

TODO: test on vc4
This commit is contained in:
Shinovon 2026-05-03 06:33:11 +05:00
parent f484ef9460
commit 0ad6fe45d1
6 changed files with 21 additions and 86 deletions

View file

@ -6,56 +6,24 @@ const char *skin_vert_src =
"VSOUT vec4 v_color;\n"
"VSOUT vec3 v_tex0_fog;\n"
"mat4 getBoneMatrix(int idx) {\n"
" if(idx == 0) return u_boneMatrices[0];\n"
" if(idx == 1) return u_boneMatrices[1];\n"
" if(idx == 2) return u_boneMatrices[2];\n"
" if(idx == 3) return u_boneMatrices[3];\n"
" if(idx == 4) return u_boneMatrices[4];\n"
" if(idx == 5) return u_boneMatrices[5];\n"
" if(idx == 6) return u_boneMatrices[6];\n"
" if(idx == 7) return u_boneMatrices[7];\n"
" if(idx == 8) return u_boneMatrices[8];\n"
" if(idx == 9) return u_boneMatrices[9];\n"
" if(idx == 10) return u_boneMatrices[10];\n"
" if(idx == 11) return u_boneMatrices[11];\n"
" if(idx == 12) return u_boneMatrices[12];\n"
" if(idx == 13) return u_boneMatrices[13];\n"
" if(idx == 14) return u_boneMatrices[14];\n"
" if(idx == 15) return u_boneMatrices[15];\n"
" if(idx == 16) return u_boneMatrices[16];\n"
" if(idx == 17) return u_boneMatrices[17];\n"
" if(idx == 18) return u_boneMatrices[18];\n"
" if(idx == 19) return u_boneMatrices[19];\n"
" if(idx == 20) return u_boneMatrices[20];\n"
" if(idx == 21) return u_boneMatrices[21];\n"
" if(idx == 22) return u_boneMatrices[22];\n"
" if(idx == 23) return u_boneMatrices[23];\n"
" return u_boneMatrices[0];\n"
"}\n"
"void\n"
"main(void)\n"
"{\n"
" vec3 SkinVertex = vec3(0.0, 0.0, 0.0);\n"
" vec3 SkinNormal = vec3(0.0, 0.0, 0.0);\n"
" for(int i = 0; i < 4; i++){\n"
" SkinVertex += (getBoneMatrix(int(in_indices[i])) * vec4(in_pos, 1.0)).xyz * in_weights[i];\n"
" SkinNormal += (mat3(getBoneMatrix(int(in_indices[i]))) * in_normal) * in_weights[i];\n"
" }\n"
" \n"
" SkinVertex += (u_boneMatrices[int(in_indices.x)] * vec4(in_pos, 1.0)).xyz * in_weights.x;\n"
" SkinVertex += (u_boneMatrices[int(in_indices.y)] * vec4(in_pos, 1.0)).xyz * in_weights.y;\n"
" SkinVertex += (u_boneMatrices[int(in_indices.z)] * vec4(in_pos, 1.0)).xyz * in_weights.z;\n"
" SkinVertex += (u_boneMatrices[int(in_indices.w)] * vec4(in_pos, 1.0)).xyz * in_weights.w;\n"
" vec4 Vertex = u_world * vec4(SkinVertex, 1.0);\n"
" gl_Position = u_proj * u_view * Vertex;\n"
" vec3 Normal = mat3(u_world) * SkinNormal;\n"
" v_tex0_fog.xy = in_tex0;\n"
" v_color = in_color;\n"
" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n"
" v_color = clamp(v_color, 0.0, 1.0);\n"
" v_color *= u_matColor;\n"
" v_tex0_fog.z = DoFog(gl_Position.z);\n"
" v_tex0_fog = vec3(in_tex0.x, in_tex0.y, DoFog(gl_Position.w));\n"
"}\n"
;