1
0
forked from mirrors/0ad

Removes the old code from the model_* shaders.

This commit is contained in:
Vladislav Belov
2024-12-09 22:47:14 +01:00
parent 6b18e58017
commit 4fb9a20c37
7 changed files with 15 additions and 55 deletions
@@ -13,12 +13,12 @@ void main()
{
vec2 coord = v_tex;
#if (USE_INSTANCING || USE_GPU_SKINNING) && (USE_PARALLAX || USE_NORMAL_MAP)
#if USE_INSTANCING && (USE_PARALLAX || USE_NORMAL_MAP)
vec3 bitangent = vec3(v_normal.w, v_tangent.w, v_lighting.w);
mat3 tbn = mat3(v_tangent.xyz, bitangent, v_normal.xyz);
#endif
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_PARALLAX
#if USE_INSTANCING && USE_PARALLAX
{
float h = SAMPLE_2D(GET_DRAW_TEXTURE_2D(normTex), coord).a;
@@ -82,7 +82,7 @@ void main()
vec3 normal = normalize(v_normal.xyz);
#endif
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_NORMAL_MAP
#if USE_INSTANCING && USE_NORMAL_MAP
normal = calculateNormal(normal, SAMPLE_2D(GET_DRAW_TEXTURE_2D(normTex), coord).rgb, tbn, effectSettings.x);
vec3 sundiffuse = max(dot(-sunDir, normal), 0.0) * sunColor;
#else
@@ -99,7 +99,7 @@ void main()
emissionWeight = s.a;
#endif
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_AO
#if USE_INSTANCING && USE_AO
float ao = SAMPLE_2D(GET_DRAW_TEXTURE_2D(aoTex), v_tex2).r;
#else
float ao = 1.0;
@@ -1,11 +1,6 @@
#include "common/shadows.h"
#include "common/stage.h"
#if USE_GPU_SKINNING
const int MAX_INFLUENCES = 4;
const int MAX_BONES = 64;
#endif
BEGIN_DRAW_TEXTURES
TEXTURE_2D(0, baseTex)
TEXTURE_2D(1, aoTex)
@@ -48,26 +43,23 @@ BEGIN_MATERIAL_UNIFORMS
#if USE_SHADOW
SHADOWS_UNIFORMS
#endif
#if USE_GPU_SKINNING
UNIFORM(mat4, skinBlendMatrices[MAX_BONES]);
#endif
END_MATERIAL_UNIFORMS
VERTEX_OUTPUT(0, vec4, v_lighting);
VERTEX_OUTPUT(1, vec2, v_tex);
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_AO
#if USE_INSTANCING && USE_AO
VERTEX_OUTPUT(2, vec2, v_tex2);
#endif
#if USE_NORMAL_MAP || USE_SPECULAR_MAP || USE_PARALLAX
VERTEX_OUTPUT(3, vec4, v_normal);
#if (USE_INSTANCING || USE_GPU_SKINNING) && (USE_NORMAL_MAP || USE_PARALLAX)
#if USE_INSTANCING && (USE_NORMAL_MAP || USE_PARALLAX)
VERTEX_OUTPUT(4, vec4, v_tangent);
//VERTEX_OUTPUT(5, vec3, v_bitangent);
#endif
#if USE_SPECULAR_MAP
VERTEX_OUTPUT(6, vec3, v_half);
#endif
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_PARALLAX
#if USE_INSTANCING && USE_PARALLAX
VERTEX_OUTPUT(7, vec3, v_eyeVec);
#endif
#endif
@@ -8,17 +8,13 @@
VERTEX_INPUT_ATTRIBUTE(0, vec3, a_vertex);
VERTEX_INPUT_ATTRIBUTE(1, vec3, a_normal);
#if (USE_INSTANCING || USE_GPU_SKINNING)
#if USE_INSTANCING
VERTEX_INPUT_ATTRIBUTE(2, vec4, a_tangent);
#endif
VERTEX_INPUT_ATTRIBUTE(3, vec2, a_uv0);
#if USE_AO
VERTEX_INPUT_ATTRIBUTE(4, vec2, a_uv1);
#endif
#if USE_GPU_SKINNING
VERTEX_INPUT_ATTRIBUTE(5, vec4, a_skinJoints);
VERTEX_INPUT_ATTRIBUTE(6, vec4, a_skinWeights);
#endif
vec4 fakeCos(vec4 x)
{
@@ -28,24 +24,6 @@ vec4 fakeCos(vec4 x)
void main()
{
#if USE_GPU_SKINNING
vec3 p = vec3(0.0);
vec3 n = vec3(0.0);
for (int i = 0; i < MAX_INFLUENCES; ++i) {
int joint = int(a_skinJoints[i]);
if (joint != 0xff) {
mat4 m = skinBlendMatrices[joint];
p += vec3(m * vec4(a_vertex, 1.0)) * a_skinWeights[i];
n += vec3(m * vec4(a_normal, 0.0)) * a_skinWeights[i];
}
}
vec4 position = instancingTransform * vec4(p, 1.0);
mat3 normalMatrix = mat3(instancingTransform[0].xyz, instancingTransform[1].xyz, instancingTransform[2].xyz);
vec3 normal = normalMatrix * normalize(n);
#if (USE_NORMAL_MAP || USE_PARALLAX)
vec3 tangent = normalMatrix * a_tangent.xyz;
#endif
#else
#if (USE_INSTANCING)
vec4 position = instancingTransform * vec4(a_vertex, 1.0);
mat3 normalMatrix = mat3(instancingTransform[0].xyz, instancingTransform[1].xyz, instancingTransform[2].xyz);
@@ -57,8 +35,6 @@ void main()
vec4 position = vec4(a_vertex, 1.0);
vec3 normal = a_normal;
#endif
#endif
#if USE_WIND
vec2 wind = windData.xy;
@@ -99,7 +75,7 @@ void main()
#if USE_NORMAL_MAP || USE_SPECULAR_MAP || USE_PARALLAX
v_normal.xyz = normal;
#if (USE_INSTANCING || USE_GPU_SKINNING) && (USE_NORMAL_MAP || USE_PARALLAX)
#if USE_INSTANCING && (USE_NORMAL_MAP || USE_PARALLAX)
v_tangent.xyz = tangent;
vec3 bitangent = cross(v_normal.xyz, v_tangent.xyz) * a_tangent.w;
v_normal.w = bitangent.x;
@@ -113,7 +89,7 @@ void main()
vec3 sunVec = -sunDir;
v_half = normalize(sunVec + normalize(eyeVec));
#endif
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_PARALLAX
#if USE_INSTANCING && USE_PARALLAX
v_eyeVec = eyeVec;
#endif
#endif
@@ -123,7 +99,7 @@ void main()
v_tex = a_uv0;
#if (USE_INSTANCING || USE_GPU_SKINNING) && USE_AO
#if USE_INSTANCING && USE_AO
v_tex2 = a_uv1;
#endif
@@ -6,9 +6,7 @@
<stream name="normal" attribute="a_normal"/>
<stream name="uv0" attribute="a_uv0"/>
<stream name="uv1" attribute="a_uv1" if="USE_AO"/>
<stream name="uv2" attribute="a_skinJoints" if="USE_GPU_SKINNING"/>
<stream name="uv3" attribute="a_skinWeights" if="USE_GPU_SKINNING"/>
<stream name="uv4" attribute="a_tangent" if="USE_INSTANCING || USE_GPU_SKINNING"/>
<stream name="uv2" attribute="a_tangent" if="USE_INSTANCING"/>
</vertex>
<fragment file="glsl/model_common.fs"/>
@@ -6,9 +6,7 @@
<stream name="normal" attribute="a_normal"/>
<stream name="uv0" attribute="a_uv0"/>
<stream name="uv1" attribute="a_uv1" if="USE_AO"/>
<stream name="uv2" attribute="a_skinJoints" if="USE_GPU_SKINNING"/>
<stream name="uv3" attribute="a_skinWeights" if="USE_GPU_SKINNING"/>
<stream name="uv4" attribute="a_tangent" if="USE_INSTANCING || USE_GPU_SKINNING"/>
<stream name="uv2" attribute="a_tangent" if="USE_INSTANCING"/>
</vertex>
<fragment file="glsl/model_solid.fs"/>
@@ -7,9 +7,7 @@
<stream name="normal" attribute="a_normal"/>
<stream name="uv0" attribute="a_uv0"/>
<stream name="uv1" attribute="a_uv1" if="USE_AO"/>
<stream name="uv2" attribute="a_skinJoints" if="USE_GPU_SKINNING"/>
<stream name="uv3" attribute="a_skinWeights" if="USE_GPU_SKINNING"/>
<stream name="uv4" attribute="a_tangent" if="USE_INSTANCING || USE_GPU_SKINNING"/>
<stream name="uv2" attribute="a_tangent" if="USE_INSTANCING"/>
</vertex>
<fragment file="glsl/model_solid_player.fs"/>
@@ -6,9 +6,7 @@
<stream name="normal" attribute="a_normal"/>
<stream name="uv0" attribute="a_uv0"/>
<stream name="uv1" attribute="a_uv1" if="USE_AO"/>
<stream name="uv2" attribute="a_skinJoints" if="USE_GPU_SKINNING"/>
<stream name="uv3" attribute="a_skinWeights" if="USE_GPU_SKINNING"/>
<stream name="uv4" attribute="a_tangent" if="USE_INSTANCING || USE_GPU_SKINNING"/>
<stream name="uv2" attribute="a_tangent" if="USE_INSTANCING"/>
</vertex>
<fragment file="glsl/model_solid_tex.fs"/>