aboutsummaryrefslogtreecommitdiffstats
path: root/src/extras/shaders/leedsDefault.vert
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2021-01-19 11:38:51 +0100
committeraap <aap@papnet.eu>2021-01-19 11:38:51 +0100
commit8baae4c77ff85e6fb1cacd428162804080998069 (patch)
tree63c90940449949019d601f09421e234d734aa576 /src/extras/shaders/leedsDefault.vert
parentc295981c5ab4c85107a04ebaa637663e5acfbf45 (diff)
PSP rendering and shader cleanup
Diffstat (limited to 'src/extras/shaders/leedsDefault.vert')
-rw-r--r--src/extras/shaders/leedsDefault.vert51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/extras/shaders/leedsDefault.vert b/src/extras/shaders/leedsDefault.vert
new file mode 100644
index 00000000..9cb18a66
--- /dev/null
+++ b/src/extras/shaders/leedsDefault.vert
@@ -0,0 +1,51 @@
+#ifdef ENVMAP
+uniform mat4 u_texMatrix;
+#endif
+#ifdef SKIN
+uniform mat4 u_boneMatrices[64];
+#endif
+
+VSIN(ATTRIB_POS) vec3 in_pos;
+
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+#ifdef ENVMAP
+VSOUT vec2 v_tex1;
+#endif
+VSOUT float v_fog;
+
+void
+main(void)
+{
+#ifdef SKIN
+ vec3 SkinVertex = vec3(0.0, 0.0, 0.0);
+ vec3 SkinNormal = vec3(0.0, 0.0, 0.0);
+ for(int i = 0; i < 4; i++){
+ SkinVertex += (u_boneMatrices[int(in_indices[i])] * vec4(in_pos, 1.0)).xyz * in_weights[i];
+ SkinNormal += (mat3(u_boneMatrices[int(in_indices[i])]) * in_normal) * in_weights[i];
+ }
+
+ vec4 Vertex = u_world * vec4(SkinVertex, 1.0);
+ gl_Position = u_proj * u_view * Vertex;
+ vec3 Normal = mat3(u_world) * SkinNormal;
+#else
+ vec4 Vertex = u_world * vec4(in_pos, 1.0);
+ gl_Position = u_proj * u_view * Vertex;
+ vec3 Normal = mat3(u_world) * in_normal;
+#endif
+
+ v_tex0 = in_tex0;
+#ifdef ENVMAP
+ v_tex1 = (u_texMatrix * vec4(Normal, 1.0)).xy;
+#endif
+
+ v_color = in_color;
+ v_color.rgb += u_ambLight.rgb*surfAmbient;
+ v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;
+ // PS2 clamps before material color
+ // PSP clamps after...maybe another constant for this?
+ v_color = clamp(v_color, 0.0, 1.0);
+ v_color *= u_matColor;
+
+ v_fog = DoFog(gl_Position.w);
+}