Review some shaders to work on GLSL 100

Tested on Raspberry Pi... Just note that platform is very limited by GPU...
This commit is contained in:
raysan5
2019-12-04 19:52:53 +01:00
parent ff499fe57d
commit 3aad221b1e
4 changed files with 40 additions and 23 deletions

View File

@ -39,20 +39,22 @@ void main()
{
vec4 color = vec4(1.0);
float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
int value = int(scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale)); // Group pixels into boxes representing integer values
if ((value == 0) || (value == 1) || (value == 2)) gl_FragColor = vec4(1.0);
else
float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values
int valuei = int(value);
//if ((valuei == 0) || (valuei == 1) || (valuei == 2)) gl_FragColor = vec4(1.0);
//else
{
for (int i = 2; (i < max(2, sqrt(value) + 1)); i++)
//for (int i = 2; (i < int(max(2.0, sqrt(value) + 1.0))); i++)
// NOTE: On GLSL 100 for loops are restricted and loop condition must be a constant
// Tested on RPI, it seems loops are limited around 60 iteractions
for (int i = 2; i < 48; i++)
{
if ((value - i*floor(value/i)) == 0)
if ((value - float(i)*floor(value/float(i))) <= 0.0)
{
color = Colorizer(float(i), scale);
gl_FragColor = Colorizer(float(i), scale);
//break; // Uncomment to color by the largest factor instead
}
}
gl_FragColor = color;
}
}