Change PaletteReference.TextureIndex to an integer.

This commit is contained in:
Paul Chote
2023-10-23 16:31:01 +01:00
committed by Gustas
parent c3ff5d954a
commit 4547f3c2b9
9 changed files with 39 additions and 37 deletions

View File

@@ -4,7 +4,8 @@ precision mediump float;
#endif
uniform sampler2D Palette, DiffuseTexture;
uniform vec2 PaletteRows;
uniform vec2 Palettes;
uniform float PaletteRows;
uniform vec4 LightDirection;
uniform vec3 AmbientLight, DiffuseLight;
@@ -17,12 +18,12 @@ out vec4 fragColor;
void main()
{
vec4 x = texture(DiffuseTexture, vTexCoord.st);
vec4 color = texture(Palette, vec2(dot(x, vChannelMask), PaletteRows.x));
vec4 color = texture(Palette, vec2(dot(x, vChannelMask), (Palettes.x + 0.5) / PaletteRows));
if (color.a < 0.01)
discard;
vec4 y = texture(DiffuseTexture, vTexCoord.pq);
vec4 normal = (2.0 * texture(Palette, vec2(dot(y, vNormalsMask), PaletteRows.y)) - 1.0);
vec4 normal = (2.0 * texture(Palette, vec2(dot(y, vNormalsMask), (Palettes.y + 0.5) / PaletteRows)) - 1.0);
vec3 intensity = AmbientLight + DiffuseLight * max(dot(normal, LightDirection), 0.0);
fragColor = vec4(intensity * color.rgb, color.a);
}