Watch
2
0
Fork
You've already forked raylib-cs
0

Sync of all the shaders from upstream + LoadFontData did not match anymore with C and crashed on MacOS

This commit is contained in:
Meatcorps 2026-05-24 12:19:24 +02:00
commit 7cd46c491f
82 changed files with 767 additions and 753 deletions

View file

@ -2,7 +2,7 @@
precision mediump float;
const int colors = 8;
const int MAX_INDEXED_COLORS = 8;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
@ -10,7 +10,8 @@ varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform ivec3 palette[colors];
uniform ivec3 palette[MAX_INDEXED_COLORS];
//uniform sampler2D palette; // Alternative to ivec3, palette provided as a 256x1 texture
void main()
{
@ -18,13 +19,13 @@ void main()
vec4 texelColor = texture2D(texture0, fragTexCoord)*fragColor;
// Convert the (normalized) texel color RED component (GB would work, too)
// to the palette index by scaling up from [0, 1] to [0, 255].
// to the palette index by scaling up from [0..1] to [0..255]
int index = int(texelColor.r*255.0);
ivec3 color = ivec3(0);
// NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value,
// a constantmust be used, so this logic...
// a constant must be used, so this logic...
if (index == 0) color = palette[0];
else if (index == 1) color = palette[1];
else if (index == 2) color = palette[2];
@ -34,8 +35,9 @@ void main()
else if (index == 6) color = palette[6];
else if (index == 7) color = palette[7];
//gl_FragColor = texture2D(palette, texelColor.xy); // Alternative to ivec3
// Calculate final fragment color. Note that the palette color components
// are defined in the range [0, 255] and need to be normalized to [0, 1]
// for OpenGL to work.
// are defined in the range [0..255] and need to be normalized to [0..1]
gl_FragColor = vec4(float(color.x)/255.0, float(color.y)/255.0, float(color.z)/255.0, texelColor.a);
}