Przeglądaj źródła

REVIEWED: Shaders formating to follow raylib code conventions

Ray 1 miesiąc temu
rodzic
commit
9b598f6bcf
62 zmienionych plików z 806 dodań i 806 usunięć
  1. 3 3
      examples/others/resources/shaders/glsl100/point_particle.fs
  2. 3 3
      examples/others/resources/shaders/glsl100/point_particle.vs
  3. 3 3
      examples/others/resources/shaders/glsl330/point_particle.fs
  4. 3 3
      examples/others/resources/shaders/glsl330/point_particle.vs
  5. 3 3
      examples/shaders/resources/shaders/glsl100/bloom.fs
  6. 4 4
      examples/shaders/resources/shaders/glsl100/cross_stitching.fs
  7. 1 1
      examples/shaders/resources/shaders/glsl100/cubes_panning.fs
  8. 4 4
      examples/shaders/resources/shaders/glsl100/deferred_shading.fs
  9. 6 6
      examples/shaders/resources/shaders/glsl100/eratosthenes.fs
  10. 7 7
      examples/shaders/resources/shaders/glsl100/fisheye.fs
  11. 4 2
      examples/shaders/resources/shaders/glsl100/hybrid_raster.fs
  12. 91 87
      examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs
  13. 21 23
      examples/shaders/resources/shaders/glsl100/julia_set.fs
  14. 1 1
      examples/shaders/resources/shaders/glsl100/lighting.fs
  15. 1 1
      examples/shaders/resources/shaders/glsl100/lightmap.fs
  16. 1 3
      examples/shaders/resources/shaders/glsl100/mask.fs
  17. 7 7
      examples/shaders/resources/shaders/glsl100/normalmap.fs
  18. 14 14
      examples/shaders/resources/shaders/glsl100/normalmap.vs
  19. 1 1
      examples/shaders/resources/shaders/glsl100/pbr.vs
  20. 132 132
      examples/shaders/resources/shaders/glsl100/raymarching.fs
  21. 2 2
      examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs
  22. 1 1
      examples/shaders/resources/shaders/glsl100/scanlines.fs
  23. 2 2
      examples/shaders/resources/shaders/glsl100/sobel.fs
  24. 0 1
      examples/shaders/resources/shaders/glsl100/vertex_displacement.fs
  25. 7 7
      examples/shaders/resources/shaders/glsl100/vertex_displacement.vs
  26. 5 7
      examples/shaders/resources/shaders/glsl100/wave.fs
  27. 3 2
      examples/shaders/resources/shaders/glsl100/write_depth.fs
  28. 4 4
      examples/shaders/resources/shaders/glsl120/cross_stitching.fs
  29. 7 7
      examples/shaders/resources/shaders/glsl120/fisheye.fs
  30. 1 1
      examples/shaders/resources/shaders/glsl120/lighting.fs
  31. 1 1
      examples/shaders/resources/shaders/glsl120/lightmap.fs
  32. 7 7
      examples/shaders/resources/shaders/glsl120/normalmap.fs
  33. 14 14
      examples/shaders/resources/shaders/glsl120/normalmap.vs
  34. 5 5
      examples/shaders/resources/shaders/glsl120/palette_switch.fs
  35. 1 1
      examples/shaders/resources/shaders/glsl120/pbr.vs
  36. 132 132
      examples/shaders/resources/shaders/glsl120/raymarching.fs
  37. 2 2
      examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs
  38. 1 1
      examples/shaders/resources/shaders/glsl120/scanlines.fs
  39. 3 3
      examples/shaders/resources/shaders/glsl120/shadowmap.fs
  40. 2 2
      examples/shaders/resources/shaders/glsl120/sobel.fs
  41. 4 4
      examples/shaders/resources/shaders/glsl330/cross_stitching.fs
  42. 1 1
      examples/shaders/resources/shaders/glsl330/cubes_panning.fs
  43. 8 8
      examples/shaders/resources/shaders/glsl330/deferred_shading.fs
  44. 6 6
      examples/shaders/resources/shaders/glsl330/eratosthenes.fs
  45. 7 7
      examples/shaders/resources/shaders/glsl330/fisheye.fs
  46. 3 3
      examples/shaders/resources/shaders/glsl330/gbuffer.vs
  47. 1 1
      examples/shaders/resources/shaders/glsl330/hybrid_raster.fs
  48. 79 79
      examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs
  49. 20 20
      examples/shaders/resources/shaders/glsl330/julia_set.fs
  50. 1 1
      examples/shaders/resources/shaders/glsl330/lighting.fs
  51. 1 1
      examples/shaders/resources/shaders/glsl330/lightmap.fs
  52. 7 7
      examples/shaders/resources/shaders/glsl330/normalmap.fs
  53. 7 7
      examples/shaders/resources/shaders/glsl330/normalmap.vs
  54. 1 1
      examples/shaders/resources/shaders/glsl330/pbr.vs
  55. 132 132
      examples/shaders/resources/shaders/glsl330/raymarching.fs
  56. 1 1
      examples/shaders/resources/shaders/glsl330/scanlines.fs
  57. 4 4
      examples/shaders/resources/shaders/glsl330/shadowmap.fs
  58. 2 2
      examples/shaders/resources/shaders/glsl330/sobel.fs
  59. 1 1
      examples/shaders/resources/shaders/glsl330/spotlight.fs
  60. 4 4
      examples/shaders/resources/shaders/glsl330/vertex_displacement.vs
  61. 5 5
      examples/shaders/resources/shaders/glsl330/wave.fs
  62. 1 1
      examples/text/resources/shaders/glsl330/alpha_discard.fs

+ 3 - 3
examples/others/resources/shaders/glsl100/point_particle.fs

@@ -10,7 +10,7 @@ uniform vec4 color;
 void main()
 void main()
 {
 {
     // Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
     // Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
-    // it. (0, 0) is the top left, (1, 1) the bottom right corner.
-    // Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges.
-    gl_FragColor = vec4(color.rgb, color.a * (1.0 - length(gl_PointCoord.xy - vec2(0.5))*2.0));
+    // it. (0, 0) is the top left, (1, 1) the bottom right corner
+    // Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges
+    gl_FragColor = vec4(color.rgb, color.a*(1.0 - length(gl_PointCoord.xy - vec2(0.5))*2.0));
 }
 }

+ 3 - 3
examples/others/resources/shaders/glsl100/point_particle.vs

@@ -16,9 +16,9 @@ void main()
     float period = vertexPosition.z;
     float period = vertexPosition.z;
 
 
     // Calculate final vertex position (jiggle it around a bit horizontally)
     // Calculate final vertex position (jiggle it around a bit horizontally)
-    pos += vec2(100.0, 0.0) * sin(period * currentTime);
-    gl_Position = mvp * vec4(pos.x, pos.y, 0.0, 1.0);
+    pos += vec2(100.0, 0.0)*sin(period*currentTime);
+    gl_Position = mvp*vec4(pos.x, pos.y, 0.0, 1.0);
 
 
     // Calculate the screen space size of this particle (also vary it over time)
     // Calculate the screen space size of this particle (also vary it over time)
-    gl_PointSize = 10.0 - 5.0 * abs(sin(period * currentTime));
+    gl_PointSize = 10.0 - 5.0*abs(sin(period*currentTime));
 }
 }

+ 3 - 3
examples/others/resources/shaders/glsl330/point_particle.fs

@@ -11,7 +11,7 @@ out vec4 finalColor;
 void main()
 void main()
 {
 {
     // Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
     // Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
-    // it. (0, 0) is the top left, (1, 1) the bottom right corner.
-    // Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges.
-    finalColor = vec4(color.rgb, color.a * (1 - length(gl_PointCoord.xy - vec2(0.5))*2));
+    // it. (0, 0) is the top left, (1, 1) the bottom right corner
+    // Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges
+    finalColor = vec4(color.rgb, color.a*(1 - length(gl_PointCoord.xy - vec2(0.5))*2));
 }
 }

+ 3 - 3
examples/others/resources/shaders/glsl330/point_particle.vs

@@ -16,9 +16,9 @@ void main()
     float period = vertexPosition.z;
     float period = vertexPosition.z;
 
 
     // Calculate final vertex position (jiggle it around a bit horizontally)
     // Calculate final vertex position (jiggle it around a bit horizontally)
-    pos += vec2(100, 0) * sin(period * currentTime);
-    gl_Position = mvp * vec4(pos, 0.0, 1.0);
+    pos += vec2(100, 0)*sin(period*currentTime);
+    gl_Position = mvp*vec4(pos, 0.0, 1.0);
 
 
     // Calculate the screen space size of this particle (also vary it over time)
     // Calculate the screen space size of this particle (also vary it over time)
-    gl_PointSize = 10 - 5 * abs(sin(period * currentTime));
+    gl_PointSize = 10 - 5*abs(sin(period*currentTime));
 }
 }

+ 3 - 3
examples/shaders/resources/shaders/glsl100/bloom.fs

@@ -12,9 +12,9 @@ uniform vec4 colDiffuse;
 
 
 // NOTE: Add your custom variables here
 // NOTE: Add your custom variables here
 
 
-const vec2 size = vec2(800, 450);   // render size
-const float samples = 5.0;          // pixels per axis; higher = bigger glow, worse performance
-const float quality = 2.5;             // lower = smaller glow, better quality
+const vec2 size = vec2(800, 450);   // Framebuffer size
+const float samples = 5.0;          // Pixels per axis; higher = bigger glow, worse performance
+const float quality = 2.5;          // Defines size factor: Lower = smaller glow, better quality
 
 
 void main()
 void main()
 {
 {

+ 4 - 4
examples/shaders/resources/shaders/glsl100/cross_stitching.fs

@@ -23,8 +23,8 @@ vec4 PostFX(sampler2D tex, vec2 uv)
 {
 {
     vec4 c = vec4(0.0);
     vec4 c = vec4(0.0);
     float size = stitchingSize;
     float size = stitchingSize;
-    vec2 cPos = uv * vec2(renderWidth, renderHeight);
-    vec2 tlPos = floor(cPos / vec2(size, size));
+    vec2 cPos = uv*vec2(renderWidth, renderHeight);
+    vec2 tlPos = floor(cPos/vec2(size, size));
     tlPos *= size;
     tlPos *= size;
 
 
     int remX = int(mod(cPos.x, size));
     int remX = int(mod(cPos.x, size));
@@ -38,11 +38,11 @@ vec4 PostFX(sampler2D tex, vec2 uv)
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     {
     {
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
-        else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        else c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
     }
     }
     else
     else
     {
     {
-        if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        if (invert == 1) c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
         else c = vec4(0.0, 0.0, 0.0, 1.0);
         else c = vec4(0.0, 0.0, 0.0, 1.0);
     }
     }
 
 

+ 1 - 1
examples/shaders/resources/shaders/glsl100/cubes_panning.fs

@@ -16,7 +16,7 @@ float angle = 0.0;
 vec2 VectorRotateTime(vec2 v, float speed)
 vec2 VectorRotateTime(vec2 v, float speed)
 {
 {
     float time = uTime*speed;
     float time = uTime*speed;
-    float localTime = fract(time);  // The time domain this works on is 1 sec.
+    float localTime = fract(time);  // The time domain this works on is 1 sec
 
 
     if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
     if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
     else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0);
     else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0);

+ 4 - 4
examples/shaders/resources/shaders/glsl100/deferred_shading.fs

@@ -13,9 +13,9 @@ uniform sampler2D gAlbedoSpec;
 
 
 struct Light {
 struct Light {
     int enabled;
     int enabled;
-    int type; // Unused in this demo.
+    int type;       // Unused in this demo
     vec3 position;
     vec3 position;
-    vec3 target; // Unused in this demo.
+    vec3 target;    // Unused in this demo
     vec4 color;
     vec4 color;
 };
 };
 
 
@@ -38,7 +38,7 @@ void main()
 
 
     for (int i = 0; i < NR_LIGHTS; ++i)
     for (int i = 0; i < NR_LIGHTS; ++i)
     {
     {
-        if(lights[i].enabled == 0) continue;
+        if (lights[i].enabled == 0) continue;
         vec3 lightDirection = lights[i].position - fragPosition;
         vec3 lightDirection = lights[i].position - fragPosition;
         vec3 diffuse = max(dot(normal, lightDirection), 0.0)*albedo*lights[i].color.xyz;
         vec3 diffuse = max(dot(normal, lightDirection), 0.0)*albedo*lights[i].color.xyz;
 
 
@@ -48,7 +48,7 @@ void main()
 
 
         // Attenuation
         // Attenuation
         float distance = length(lights[i].position - fragPosition);
         float distance = length(lights[i].position - fragPosition);
-        float attenuation = 1.0/(1.0 + LINEAR * distance + QUADRATIC*distance*distance);
+        float attenuation = 1.0/(1.0 + LINEAR*distance + QUADRATIC*distance*distance);
         diffuse *= attenuation;
         diffuse *= attenuation;
         specular *= attenuation;
         specular *= attenuation;
         ambient += diffuse + specular;
         ambient += diffuse + specular;

+ 6 - 6
examples/shaders/resources/shaders/glsl100/eratosthenes.fs

@@ -7,12 +7,12 @@ precision mediump float;
   The Sieve of Eratosthenes -- a simple shader by ProfJski
   The Sieve of Eratosthenes -- a simple shader by ProfJski
   An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
   An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
 
 
-  The screen is divided into a square grid of boxes, each representing an integer value.
-  Each integer is tested to see if it is a prime number.  Primes are colored white.
-  Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer.
+  The screen is divided into a square grid of boxes, each representing an integer value
+  Each integer is tested to see if it is a prime number.  Primes are colored white
+  Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer
 
 
-  You can change the scale variable to make a larger or smaller grid.
-  Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers.
+  You can change the scale variable to make a larger or smaller grid
+  Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers
 
 
   WARNING: If you make scale too large, your GPU may bog down!
   WARNING: If you make scale too large, your GPU may bog down!
 
 
@@ -38,7 +38,7 @@ vec4 Colorizer(float counter, float maxSize)
 void main()
 void main()
 {
 {
     vec4 color = vec4(1.0);
     vec4 color = vec4(1.0);
-    float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
+    float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid
     float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale);  // Group pixels into boxes representing integer values
     float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale);  // Group pixels into boxes representing integer values
     int valuei = int(value);
     int valuei = int(value);
 
 

+ 7 - 7
examples/shaders/resources/shaders/glsl100/fisheye.fs

@@ -17,22 +17,22 @@ const float PI = 3.1415926535;
 void main()
 void main()
 {
 {
     float aperture = 178.0;
     float aperture = 178.0;
-    float apertureHalf = 0.5 * aperture * (PI / 180.0);
+    float apertureHalf = 0.5*aperture*(PI/180.0);
     float maxFactor = sin(apertureHalf);
     float maxFactor = sin(apertureHalf);
 
 
     vec2 uv = vec2(0.0);
     vec2 uv = vec2(0.0);
-    vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
+    vec2 xy = 2.0*fragTexCoord.xy - 1.0;
     float d = length(xy);
     float d = length(xy);
 
 
     if (d < (2.0 - maxFactor))
     if (d < (2.0 - maxFactor))
     {
     {
-        d = length(xy * maxFactor);
-        float z = sqrt(1.0 - d * d);
-        float r = atan(d, z) / PI;
+        d = length(xy*maxFactor);
+        float z = sqrt(1.0 - d*d);
+        float r = atan(d, z)/PI;
         float phi = atan(xy.y, xy.x);
         float phi = atan(xy.y, xy.x);
 
 
-        uv.x = r * cos(phi) + 0.5;
-        uv.y = r * sin(phi) + 0.5;
+        uv.x = r*cos(phi) + 0.5;
+        uv.y = r*sin(phi) + 0.5;
     }
     }
     else
     else
     {
     {

+ 4 - 2
examples/shaders/resources/shaders/glsl100/hybrid_raster.fs

@@ -1,4 +1,5 @@
-#version 100             
+#version 100
+
 #extension GL_EXT_frag_depth : enable   // Extension required for writing depth         
 #extension GL_EXT_frag_depth : enable   // Extension required for writing depth         
 precision mediump float;                // Precision required for OpenGL ES2 (WebGL)
 precision mediump float;                // Precision required for OpenGL ES2 (WebGL)
 
 
@@ -11,6 +12,7 @@ uniform vec4 colDiffuse;
 void main()
 void main()
 {
 {
     vec4 texelColor = texture2D(texture0, fragTexCoord);
     vec4 texelColor = texture2D(texture0, fragTexCoord);
+
     gl_FragColor = texelColor*colDiffuse*fragColor;
     gl_FragColor = texelColor*colDiffuse*fragColor;
-	gl_FragDepthEXT = gl_FragCoord.z;
+    gl_FragDepthEXT = gl_FragCoord.z;
 }
 }

+ 91 - 87
examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs

@@ -1,9 +1,9 @@
-#version 100             
+#version 100
+
 #extension GL_EXT_frag_depth : enable           //Extension required for writing depth
 #extension GL_EXT_frag_depth : enable           //Extension required for writing depth
 #extension GL_OES_standard_derivatives : enable //Extension used for fwidth()
 #extension GL_OES_standard_derivatives : enable //Extension used for fwidth()
 precision mediump float;                // Precision required for OpenGL ES2 (WebGL)
 precision mediump float;                // Precision required for OpenGL ES2 (WebGL)
 
 
-
 // Input vertex attributes (from vertex shader)
 // Input vertex attributes (from vertex shader)
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying vec4 fragColor;
 varying vec4 fragColor;
@@ -19,21 +19,22 @@ uniform vec2 screenCenter;
 
 
 #define ZERO 0
 #define ZERO 0
 
 
-// https://learnopengl.com/Advanced-OpenGL/Depth-testing
-float CalcDepth(in vec3 rd, in float Idist){
+// SRC: https://learnopengl.com/Advanced-OpenGL/Depth-testing
+float CalcDepth(in vec3 rd, in float Idist)
+{
     float local_z = dot(normalize(camDir),rd)*Idist;
     float local_z = dot(normalize(camDir),rd)*Idist;
     return (1.0/(local_z) - 1.0/0.01)/(1.0/1000.0 -1.0/0.01);
     return (1.0/(local_z) - 1.0/0.01)/(1.0/1000.0 -1.0/0.01);
 }
 }
 
 
-// https://iquilezles.org/articles/distfunctions/
-float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
+// SRC: https://iquilezles.org/articles/distfunctions/
+float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w)
 {
 {
     p.x = abs(p.x);
     p.x = abs(p.x);
     float l = length(p.xy);
     float l = length(p.xy);
     p.xy = mat2(-c.x, c.y, 
     p.xy = mat2(-c.x, c.y, 
               c.y, c.x)*p.xy;
               c.y, c.x)*p.xy;
     p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
     p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
-                (p.x>0.0)?p.y:l );
+                (p.x>0.0)?p.y:l);
     p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
     p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
     
     
     vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
     vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
@@ -44,67 +45,70 @@ float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
 // r = sphere's radius
 // r = sphere's radius
 // h = cutting's plane's position
 // h = cutting's plane's position
 // t = thickness
 // t = thickness
-float sdSixWayCutHollowSphere( vec3 p, float r, float h, float t )
+float sdSixWayCutHollowSphere(vec3 p, float r, float h, float t)
 {
 {
     // Six way symetry Transformation
     // Six way symetry Transformation
     vec3 ap = abs(p);
     vec3 ap = abs(p);
-    if(ap.x < max(ap.y, ap.z)){
-        if(ap.y < ap.z) ap.xz = ap.zx;
+    if (ap.x < max(ap.y, ap.z)){
+        if (ap.y < ap.z) ap.xz = ap.zx;
         else ap.xy = ap.yx;
         else ap.xy = ap.yx;
     }
     }
 
 
-    vec2 q = vec2( length(ap.yz), ap.x );
+    vec2 q = vec2(length(ap.yz), ap.x);
     
     
     float w = sqrt(r*r-h*h);
     float w = sqrt(r*r-h*h);
     
     
-    return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : 
-                            abs(length(q)-r) ) - t;
+    return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : abs(length(q)-r)) - t;
 }
 }
 
 
-// https://iquilezles.org/articles/boxfunctions
-vec2 iBox( in vec3 ro, in vec3 rd, in vec3 rad ) 
+// SRC: https://iquilezles.org/articles/boxfunctions
+vec2 iBox(in vec3 ro, in vec3 rd, in vec3 rad) 
 {
 {
     vec3 m = 1.0/rd;
     vec3 m = 1.0/rd;
     vec3 n = m*ro;
     vec3 n = m*ro;
     vec3 k = abs(m)*rad;
     vec3 k = abs(m)*rad;
     vec3 t1 = -n - k;
     vec3 t1 = -n - k;
     vec3 t2 = -n + k;
     vec3 t2 = -n + k;
-	return vec2( max( max( t1.x, t1.y ), t1.z ),
-	             min( min( t2.x, t2.y ), t2.z ) );
+
+    return vec2(max(max(t1.x, t1.y), t1.z),
+                 min(min(t2.x, t2.y), t2.z));
 }
 }
 
 
-vec2 opU( vec2 d1, vec2 d2 )
+vec2 opU(vec2 d1, vec2 d2)
 {
 {
-	return (d1.x<d2.x) ? d1 : d2;
+    return (d1.x<d2.x) ? d1 : d2;
 }
 }
 
 
-vec2 map( in vec3 pos ){
-    vec2 res = vec2( sdHorseshoe(  pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5) ), 11.5 ) ;
-    res = opU(res, vec2( sdSixWayCutHollowSphere(  pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5 ), 4.5 )) ;
+vec2 map(in vec3 pos)
+{
+    vec2 res = vec2(sdHorseshoe(pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5)), 11.5) ;
+    res = opU(res, vec2(sdSixWayCutHollowSphere(pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5), 4.5)) ;
+
     return res;
     return res;
 }
 }
 
 
-// https://www.shadertoy.com/view/Xds3zN
-vec2 raycast( in vec3 ro, in vec3 rd ){
+// SRC: https://www.shadertoy.com/view/Xds3zN
+vec2 raycast(in vec3 ro, in vec3 rd)
+{
     vec2 res = vec2(-1.0,-1.0);
     vec2 res = vec2(-1.0,-1.0);
 
 
     float tmin = 1.0;
     float tmin = 1.0;
     float tmax = 20.0;
     float tmax = 20.0;
 
 
-    // raytrace floor plane
+    // Raytrace floor plane
     float tp1 = (-ro.y)/rd.y;
     float tp1 = (-ro.y)/rd.y;
-    if( tp1>0.0 )
+    if (tp1>0.0)
     {
     {
-        tmax = min( tmax, tp1 );
-        res = vec2( tp1, 1.0 );
+        tmax = min(tmax, tp1);
+        res = vec2(tp1, 1.0);
     }
     }
 
 
     float t = tmin;
     float t = tmin;
-    for( int i=0; i<70 ; i++ )
+    for (int i=0; i<70 ; i++)
     {
     {
-        if(t>tmax) break;
-        vec2 h = map( ro+rd*t );
-        if( abs(h.x)<(0.0001*t) )
+        if (t>tmax) break;
+        vec2 h = map(ro+rd*t);
+        if (abs(h.x) < (0.0001*t))
         { 
         { 
             res = vec2(t,h.y); 
             res = vec2(t,h.y); 
             break;
             break;
@@ -117,54 +121,54 @@ vec2 raycast( in vec3 ro, in vec3 rd ){
 
 
 
 
 // https://iquilezles.org/articles/rmshadows
 // https://iquilezles.org/articles/rmshadows
-float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
 {
 {
     // bounding volume
     // bounding volume
-    float tp = (0.8-ro.y)/rd.y; if( tp>0.0 ) tmax = min( tmax, tp );
+    float tp = (0.8-ro.y)/rd.y; if (tp>0.0) tmax = min(tmax, tp);
 
 
     float res = 1.0;
     float res = 1.0;
     float t = mint;
     float t = mint;
-    for( int i=ZERO; i<24; i++ )
+    for (int i=ZERO; i<24; i++)
     {
     {
-		float h = map( ro + rd*t ).x;
+        float h = map(ro + rd*t).x;
         float s = clamp(8.0*h/t,0.0,1.0);
         float s = clamp(8.0*h/t,0.0,1.0);
-        res = min( res, s );
-        t += clamp( h, 0.01, 0.2 );
-        if( res<0.004 || t>tmax ) break;
+        res = min(res, s);
+        t += clamp(h, 0.01, 0.2);
+        if (res<0.004 || t>tmax) break;
     }
     }
-    res = clamp( res, 0.0, 1.0 );
+    res = clamp(res, 0.0, 1.0);
     return res*res*(3.0-2.0*res);
     return res*res*(3.0-2.0*res);
 }
 }
 
 
 
 
 // https://iquilezles.org/articles/normalsSDF
 // https://iquilezles.org/articles/normalsSDF
-vec3 calcNormal( in vec3 pos )
+vec3 calcNormal(in vec3 pos)
 {
 {
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
-    return normalize( e.xyy*map( pos + e.xyy ).x + 
-					  e.yyx*map( pos + e.yyx ).x + 
-					  e.yxy*map( pos + e.yxy ).x + 
-					  e.xxx*map( pos + e.xxx ).x );
+    return normalize(e.xyy*map(pos + e.xyy).x + 
+                     e.yyx*map(pos + e.yyx).x + 
+                     e.yxy*map(pos + e.yxy).x + 
+                     e.xxx*map(pos + e.xxx).x);
 }
 }
 
 
 // https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
 // https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
-float calcAO( in vec3 pos, in vec3 nor )
+float calcAO(in vec3 pos, in vec3 nor)
 {
 {
-	float occ = 0.0;
+    float occ = 0.0;
     float sca = 1.0;
     float sca = 1.0;
-    for( int i=ZERO; i<5; i++ )
+    for (int i=ZERO; i<5; i++)
     {
     {
         float h = 0.01 + 0.12*float(i)/4.0;
         float h = 0.01 + 0.12*float(i)/4.0;
-        float d = map( pos + h*nor ).x;
+        float d = map(pos + h*nor).x;
         occ += (h-d)*sca;
         occ += (h-d)*sca;
         sca *= 0.95;
         sca *= 0.95;
-        if( occ>0.35 ) break;
+        if (occ>0.35) break;
     }
     }
-    return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ) * (0.5+0.5*nor.y);
+    return clamp(1.0 - 3.0*occ, 0.0, 1.0)*(0.5+0.5*nor.y);
 }
 }
 
 
 // https://iquilezles.org/articles/checkerfiltering
 // https://iquilezles.org/articles/checkerfiltering
-float checkersGradBox( in vec2 p )
+float checkersGradBox(in vec2 p)
 {
 {
     // filter kernel
     // filter kernel
     vec2 w = fwidth(p) + 0.001;
     vec2 w = fwidth(p) + 0.001;
@@ -175,7 +179,7 @@ float checkersGradBox( in vec2 p )
 }
 }
 
 
 // https://www.shadertoy.com/view/tdS3DG
 // https://www.shadertoy.com/view/tdS3DG
-vec4 render( in vec3 ro, in vec3 rd)
+vec4 render(in vec3 ro, in vec3 rd)
 { 
 { 
     // background
     // background
     vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
     vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
@@ -183,37 +187,37 @@ vec4 render( in vec3 ro, in vec3 rd)
     // raycast scene
     // raycast scene
     vec2 res = raycast(ro,rd);
     vec2 res = raycast(ro,rd);
     float t = res.x;
     float t = res.x;
-	float m = res.y;
-    if( m>-0.5 )
+    float m = res.y;
+    if (m>-0.5)
     {
     {
         vec3 pos = ro + t*rd;
         vec3 pos = ro + t*rd;
-        vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal( pos );
-        vec3 ref = reflect( rd, nor );
+        vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
+        vec3 ref = reflect(rd, nor);
         
         
         // material        
         // material        
-        col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
+        col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
         float ks = 1.0;
         float ks = 1.0;
         
         
-        if( m<1.5 )
+        if (m<1.5)
         {
         {
-            float f = checkersGradBox( 3.0*pos.xz);
+            float f = checkersGradBox(3.0*pos.xz);
             col = 0.15 + f*vec3(0.05);
             col = 0.15 + f*vec3(0.05);
             ks = 0.4;
             ks = 0.4;
         }
         }
 
 
         // lighting
         // lighting
-        float occ = calcAO( pos, nor );
+        float occ = calcAO(pos, nor);
         
         
-		vec3 lin = vec3(0.0);
+        vec3 lin = vec3(0.0);
 
 
         // sun
         // sun
         {
         {
-            vec3  lig = normalize( vec3(-0.5, 0.4, -0.6) );
-            vec3  hal = normalize( lig-rd );
-            float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
-          //if( dif>0.0001 )
-        	      dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
-			float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
+            vec3  lig = normalize(vec3(-0.5, 0.4, -0.6));
+            vec3  hal = normalize(lig-rd);
+            float dif = clamp(dot(nor, lig), 0.0, 1.0);
+            //if (dif>0.0001)
+                dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
+            float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0);
                   spe *= dif;
                   spe *= dif;
                   spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
                   spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
                 //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
                 //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
@@ -222,35 +226,35 @@ vec4 render( in vec3 ro, in vec3 rd)
         }
         }
         // sky
         // sky
         {
         {
-            float dif = sqrt(clamp( 0.5+0.5*nor.y, 0.0, 1.0 ));
+            float dif = sqrt(clamp(0.5+0.5*nor.y, 0.0, 1.0));
                   dif *= occ;
                   dif *= occ;
-            float spe = smoothstep( -0.2, 0.2, ref.y );
+            float spe = smoothstep(-0.2, 0.2, ref.y);
                   spe *= dif;
                   spe *= dif;
-                  spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0 );
-          //if( spe>0.001 )
-                  spe *= calcSoftshadow( pos, ref, 0.02, 2.5 );
+                  spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0);
+          //if (spe>0.001)
+                  spe *= calcSoftshadow(pos, ref, 0.02, 2.5);
             lin += col*0.60*dif*vec3(0.40,0.60,1.15);
             lin += col*0.60*dif*vec3(0.40,0.60,1.15);
             lin +=     2.00*spe*vec3(0.40,0.60,1.30)*ks;
             lin +=     2.00*spe*vec3(0.40,0.60,1.30)*ks;
         }
         }
         // back
         // back
         {
         {
-        	float dif = clamp( dot( nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
+            float dif = clamp(dot(nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
                   dif *= occ;
                   dif *= occ;
-        	lin += col*0.55*dif*vec3(0.25,0.25,0.25);
+            lin += col*0.55*dif*vec3(0.25,0.25,0.25);
         }
         }
         // sss
         // sss
         {
         {
             float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
             float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
                   dif *= occ;
                   dif *= occ;
-        	lin += col*0.25*dif*vec3(1.00,1.00,1.00);
+            lin += col*0.25*dif*vec3(1.00,1.00,1.00);
         }
         }
         
         
-		col = lin;
+        col = lin;
 
 
-        col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
+        col = mix(col, vec3(0.7,0.7,0.9), 1.0-exp(-0.0001*t*t*t));
     }
     }
 
 
-	return vec4(vec3( clamp(col,0.0,1.0) ),t);
+    return vec4(vec3(clamp(col,0.0,1.0)),t);
 }
 }
 
 
 vec3 CalcRayDir(vec2 nCoord){
 vec3 CalcRayDir(vec2 nCoord){
@@ -261,11 +265,11 @@ vec3 CalcRayDir(vec2 nCoord){
 
 
 mat3 setCamera()
 mat3 setCamera()
 {
 {
-	vec3 cw = normalize(camDir);
-	vec3 cp = vec3(0.0, 1.0 ,0.0);
-	vec3 cu = normalize( cross(cw,cp) );
-	vec3 cv =          ( cross(cu,cw) );
-    return mat3( cu, cv, cw );
+    vec3 cw = normalize(camDir);
+    vec3 cp = vec3(0.0, 1.0 ,0.0);
+    vec3 cu = normalize(cross(cw,cp));
+    vec3 cv =          (cross(cu,cw));
+    return mat3(cu, cv, cw);
 }
 }
 
 
 void main()
 void main()
@@ -275,14 +279,14 @@ void main()
 
 
     // focal length
     // focal length
     float fl = length(camDir);
     float fl = length(camDir);
-    vec3 rd = ca * normalize( vec3(nCoord,fl) );
+    vec3 rd = ca*normalize(vec3(nCoord,fl));
     vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
     vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
     float depth = gl_FragCoord.z;
     float depth = gl_FragCoord.z;
     {
     {
-        vec4 res = render( camPos - vec3(0.0, 0.0, 0.0) , rd );
+        vec4 res = render(camPos - vec3(0.0, 0.0, 0.0) , rd);
         color = res.xyz;
         color = res.xyz;
         depth = CalcDepth(rd,res.w);
         depth = CalcDepth(rd,res.w);
     }
     }
     gl_FragColor = vec4(color , 1.0);
     gl_FragColor = vec4(color , 1.0);
-	gl_FragDepthEXT = depth;
+    gl_FragDepthEXT = depth;
 }
 }

+ 21 - 23
examples/shaders/resources/shaders/glsl100/julia_set.fs

@@ -1,19 +1,17 @@
-#version 100
-
-precision mediump float;
+#version 120
 
 
 // Input vertex attributes (from vertex shader)
 // Input vertex attributes (from vertex shader)
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying vec4 fragColor;
 varying vec4 fragColor;
 
 
 uniform vec2 c;                 // c.x = real, c.y = imaginary component. Equation done is z^2 + c
 uniform vec2 c;                 // c.x = real, c.y = imaginary component. Equation done is z^2 + c
-uniform vec2 offset;            // Offset of the scale.
-uniform float zoom;             // Zoom of the scale.
+uniform vec2 offset;            // Offset of the scale
+uniform float zoom;             // Zoom of the scale
 
 
 // NOTE: Maximum number of shader for-loop iterations depend on GPU,
 // NOTE: Maximum number of shader for-loop iterations depend on GPU,
 // for example, on RasperryPi for this examply only supports up to 60
 // for example, on RasperryPi for this examply only supports up to 60
-const int maxIterations = 48;     // Max iterations to do.
-const float colorCycles = 1.0;    // Number of times the color palette repeats.
+const int maxIterations = 48;     // Max iterations to do
+const float colorCycles = 1.0;    // Number of times the color palette repeats
 
 
 // Square a complex number
 // Square a complex number
 vec2 ComplexSquare(vec2 z)
 vec2 ComplexSquare(vec2 z)
@@ -32,22 +30,22 @@ vec3 Hsv2rgb(vec3 c)
 void main()
 void main()
 {
 {
     /**********************************************************************************************
     /**********************************************************************************************
-      Julia sets use a function z^2 + c, where c is a constant.
-      This function is iterated until the nature of the point is determined.
+      Julia sets use a function z^2 + c, where c is a constant
+      This function is iterated until the nature of the point is determined
 
 
       If the magnitude of the number becomes greater than 2, then from that point onward
       If the magnitude of the number becomes greater than 2, then from that point onward
-      the number will get bigger and bigger, and will never get smaller (tends towards infinity).
-      2^2 = 4, 4^2 = 8 and so on.
-      So at 2 we stop iterating.
+      the number will get bigger and bigger, and will never get smaller (tends towards infinity)
+      2^2 = 4, 4^2 = 8 and so on
+      So at 2 we stop iterating
 
 
-      If the number is below 2, we keep iterating.
+      If the number is below 2, we keep iterating
       But when do we stop iterating if the number is always below 2 (it converges)?
       But when do we stop iterating if the number is always below 2 (it converges)?
-      That is what maxIterations is for.
-      Then we can divide the iterations by the maxIterations value to get a normalized value that we can
-      then map to a color.
+      That is what maxIterations is for
+      Then we can divide the iterations by the maxIterations value to get a normalized value
+      that we can then map to a color
 
 
-      We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
-      And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power).
+      We use dot product (z.x*z.x + z.y*z.y) to determine the magnitude (length) squared
+      And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power)
     *************************************************************************************************/
     *************************************************************************************************/
 
 
     // The pixel coordinates are scaled so they are on the mandelbrot scale
     // The pixel coordinates are scaled so they are on the mandelbrot scale
@@ -65,18 +63,18 @@ void main()
         iter = iterations;
         iter = iterations;
     }
     }
 
 
-    // Another few iterations decreases errors in the smoothing calculation.
-    // See http://linas.org/art-gallery/escape/escape.html for more information.
+    // Another few iterations decreases errors in the smoothing calculation
+    // See http://linas.org/art-gallery/escape/escape.html for more information
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
 
 
-    // This last part smooths the color (again see link above).
+    // This last part smooths the color (again see link above)
     float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
     float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
 
 
-    // Normalize the value so it is between 0 and 1.
+    // Normalize the value so it is between 0 and 1
     float norm = smoothVal/float(maxIterations);
     float norm = smoothVal/float(maxIterations);
 
 
-    // If in set, color black. 0.999 allows for some float accuracy error.
+    // If in set, color black. 0.999 allows for some float accuracy error
     if (norm > 0.999) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
     if (norm > 0.999) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
     else gl_FragColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0, 1.0)), 1.0);
     else gl_FragColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0, 1.0)), 1.0);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl100/lighting.fs

@@ -40,7 +40,7 @@ void main()
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 specular = vec3(0.0);
     vec3 specular = vec3(0.0);
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     // NOTE: Implement here your fragment shader code
     // NOTE: Implement here your fragment shader code
 
 

+ 1 - 1
examples/shaders/resources/shaders/glsl100/lightmap.fs

@@ -18,5 +18,5 @@ void main()
     vec4 texelColor = texture2D(texture0, fragTexCoord);
     vec4 texelColor = texture2D(texture0, fragTexCoord);
     vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
     vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
 
 
-    gl_FragColor = texelColor * texelColor2;
+    gl_FragColor = texelColor*texelColor2;
 }
 }

+ 1 - 3
examples/shaders/resources/shaders/glsl100/mask.fs

@@ -1,6 +1,4 @@
-#version 100
-
-precision mediump float;
+#version 120
 
 
 // Input vertex attributes (from vertex shader)
 // Input vertex attributes (from vertex shader)
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;

+ 7 - 7
examples/shaders/resources/shaders/glsl100/normalmap.fs

@@ -34,21 +34,21 @@ void main()
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
 
 
         //Transform normal values to the range -1.0 ... 1.0
         //Transform normal values to the range -1.0 ... 1.0
-        normal = normalize(normal * 2.0 - 1.0);
+        normal = normalize(normal*2.0 - 1.0);
 
 
         //Transform the normal from tangent-space to world-space for lighting calculation
         //Transform the normal from tangent-space to world-space for lighting calculation
-        normal = normalize(normal * TBN);
+        normal = normalize(normal*TBN);
     }
     }
     else
     else
     {
     {
         normal = normalize(fragNormal);
         normal = normalize(fragNormal);
     }
     }
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
-    vec3 lightDot = lightColor * NdotL;
+    vec3 lightDot = lightColor*NdotL;
 
 
     float specCo = 0.0;
     float specCo = 0.0;
 
 
@@ -56,9 +56,9 @@ void main()
 
 
     specular += specCo;
     specular += specCo;
 
 
-    finalColor = (texelColor * ((tint + vec4(specular, 1.0)) * vec4(lightDot, 1.0)));
-    finalColor += texelColor * (vec4(1.0, 1.0, 1.0, 1.0) / 40.0) * tint;
+    finalColor = (texelColor*((tint + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
+    finalColor += texelColor*(vec4(1.0, 1.0, 1.0, 1.0)/40.0)*tint;
 
 
     // Gamma correction
     // Gamma correction
-    gl_FragColor = pow(finalColor, vec4(1.0 / 2.2));
+    gl_FragColor = pow(finalColor, vec4(1.0/2.2));
 }
 }

+ 14 - 14
examples/shaders/resources/shaders/glsl100/normalmap.vs

@@ -27,15 +27,15 @@ mat3 inverse(mat3 m)
     float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
     float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
     float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
     float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
 
 
-    float b01 = a22 * a11 - a12 * a21;
-    float b11 = -a22 * a10 + a12 * a20;
-    float b21 = a21 * a10 - a11 * a20;
+    float b01 = a22*a11 - a12*a21;
+    float b11 = -a22*a10 + a12*a20;
+    float b21 = a21*a10 - a11*a20;
 
 
-    float det = a00 * b01 + a01 * b11 + a02 * b21;
+    float det = a00*b01 + a01*b11 + a02*b21;
 
 
-    return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
-        b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
-        b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
+    return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
+        b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
+        b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
 }
 }
 
 
 // https://github.com/glslify/glsl-transpose
 // https://github.com/glslify/glsl-transpose
@@ -49,21 +49,21 @@ mat3 transpose(mat3 m)
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
 
 
     // Compute fragment position based on model transformations
     // Compute fragment position based on model transformations
-    fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
+    fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
 
 
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
-    fragNormal = normalize(normalMatrix * vertexNormal);
+    fragNormal = normalize(normalMatrix*vertexNormal);
 
 
-    vec3 fragTangent = normalize(normalMatrix * vertexTangent.xyz);
-    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal) * fragNormal);
+    vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
+    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
 
 
-    vec3 fragBinormal = normalize(normalMatrix * vertexBinormal);
+    vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
     fragBinormal = cross(fragNormal, fragTangent);
     fragBinormal = cross(fragNormal, fragTangent);
 
 
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
@@ -72,5 +72,5 @@ void main()
 
 
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
 
 
-    gl_Position = mvp * vec4(vertexPosition, 1.0);
+    gl_Position = mvp*vec4(vertexPosition, 1.0);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl100/pbr.vs

@@ -52,7 +52,7 @@ mat3 transpose(mat3 m)
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent
     // Compute binormal from vertex normal and tangent
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));

+ 132 - 132
examples/shaders/resources/shaders/glsl100/raymarching.fs

@@ -34,7 +34,7 @@ uniform vec2 resolution;
 // SOFTWARE.
 // SOFTWARE.
 
 
 // A list of useful distance function to simple primitives, and an example on how to
 // A list of useful distance function to simple primitives, and an example on how to
-// do some interesting boolean operations, repetition and displacement.
+// do some interesting boolean operations, repetition and displacement
 //
 //
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 
 
@@ -42,38 +42,38 @@ uniform vec2 resolution;
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float sdPlane( vec3 p )
+float sdPlane(vec3 p)
 {
 {
     return p.y;
     return p.y;
 }
 }
 
 
-float sdSphere( vec3 p, float s )
+float sdSphere(vec3 p, float s)
 {
 {
     return length(p)-s;
     return length(p)-s;
 }
 }
 
 
-float sdBox( vec3 p, vec3 b )
+float sdBox(vec3 p, vec3 b)
 {
 {
     vec3 d = abs(p) - b;
     vec3 d = abs(p) - b;
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdEllipsoid( in vec3 p, in vec3 r )
+float sdEllipsoid(in vec3 p, in vec3 r)
 {
 {
-    return (length( p/r ) - 1.0) * min(min(r.x,r.y),r.z);
+    return (length(p/r) - 1.0)*min(min(r.x,r.y),r.z);
 }
 }
 
 
-float udRoundBox( vec3 p, vec3 b, float r )
+float udRoundBox(vec3 p, vec3 b, float r)
 {
 {
     return length(max(abs(p)-b,0.0))-r;
     return length(max(abs(p)-b,0.0))-r;
 }
 }
 
 
-float sdTorus( vec3 p, vec2 t )
+float sdTorus(vec3 p, vec2 t)
 {
 {
-    return length( vec2(length(p.xz)-t.x,p.y) )-t.y;
+    return length(vec2(length(p.xz)-t.x,p.y))-t.y;
 }
 }
 
 
-float sdHexPrism( vec3 p, vec2 h )
+float sdHexPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
 #if 0
 #if 0
@@ -85,24 +85,24 @@ float sdHexPrism( vec3 p, vec2 h )
 #endif
 #endif
 }
 }
 
 
-float sdCapsule( vec3 p, vec3 a, vec3 b, float r )
+float sdCapsule(vec3 p, vec3 a, vec3 b, float r)
 {
 {
     vec3 pa = p-a, ba = b-a;
     vec3 pa = p-a, ba = b-a;
-    float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
-    return length( pa - ba*h ) - r;
+    float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);
+    return length(pa - ba*h) - r;
 }
 }
 
 
-float sdEquilateralTriangle(  in vec2 p )
+float sdEquilateralTriangle( in vec2 p)
 {
 {
     const float k = sqrt(3.0);
     const float k = sqrt(3.0);
     p.x = abs(p.x) - 1.0;
     p.x = abs(p.x) - 1.0;
     p.y = p.y + 1.0/k;
     p.y = p.y + 1.0/k;
-    if( p.x + k*p.y > 0.0 ) p = vec2( p.x - k*p.y, -k*p.x - p.y )/2.0;
-    p.x += 2.0 - 2.0*clamp( (p.x+2.0)/2.0, 0.0, 1.0 );
+    if (p.x + k*p.y > 0.0) p = vec2(p.x - k*p.y, -k*p.x - p.y)/2.0;
+    p.x += 2.0 - 2.0*clamp((p.x+2.0)/2.0, 0.0, 1.0);
     return -length(p)*sign(p.y);
     return -length(p)*sign(p.y);
 }
 }
 
 
-float sdTriPrism( vec3 p, vec2 h )
+float sdTriPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
     float d1 = q.z-h.y;
     float d1 = q.z-h.y;
@@ -117,95 +117,95 @@ float sdTriPrism( vec3 p, vec2 h )
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdCylinder( vec3 p, vec2 h )
+float sdCylinder(vec3 p, vec2 h)
 {
 {
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdCone( in vec3 p, in vec3 c )
+float sdCone(in vec3 p, in vec3 c)
 {
 {
-    vec2 q = vec2( length(p.xz), p.y );
+    vec2 q = vec2(length(p.xz), p.y);
     float d1 = -q.y-c.z;
     float d1 = -q.y-c.z;
-    float d2 = max( dot(q,c.xy), q.y);
+    float d2 = max(dot(q,c.xy), q.y);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdConeSection( in vec3 p, in float h, in float r1, in float r2 )
+float sdConeSection(in vec3 p, in float h, in float r1, in float r2)
 {
 {
     float d1 = -p.y - h;
     float d1 = -p.y - h;
     float q = p.y - h;
     float q = p.y - h;
     float si = 0.5*(r1-r2)/h;
     float si = 0.5*(r1-r2)/h;
-    float d2 = max( sqrt( dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q );
+    float d2 = max(sqrt(dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height }
+float sdPryamid4(vec3 p, vec3 h) // h = { cos a, sin a, height }
 {
 {
     // Tetrahedron = Octahedron - Cube
     // Tetrahedron = Octahedron - Cube
-    float box = sdBox( p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z) );
+    float box = sdBox(p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z));
 
 
     float d = 0.0;
     float d = 0.0;
-    d = max( d, abs( dot(p, vec3( -h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y, h.x )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y,-h.x )) ));
+    d = max(d, abs(dot(p, vec3(-h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( 0, h.y, h.x))));
+    d = max(d, abs(dot(p, vec3( 0, h.y,-h.x))));
     float octa = d - h.z;
     float octa = d - h.z;
     return max(-box,octa); // Subtraction
     return max(-box,octa); // Subtraction
  }
  }
 
 
-float length2( vec2 p )
+float length2(vec2 p)
 {
 {
-    return sqrt( p.x*p.x + p.y*p.y );
+    return sqrt(p.x*p.x + p.y*p.y);
 }
 }
 
 
-float length6( vec2 p )
+float length6(vec2 p)
 {
 {
     p = p*p*p; p = p*p;
     p = p*p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/6.0 );
+    return pow(p.x + p.y, 1.0/6.0);
 }
 }
 
 
-float length8( vec2 p )
+float length8(vec2 p)
 {
 {
     p = p*p; p = p*p; p = p*p;
     p = p*p; p = p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/8.0 );
+    return pow(p.x + p.y, 1.0/8.0);
 }
 }
 
 
-float sdTorus82( vec3 p, vec2 t )
+float sdTorus82(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdTorus88( vec3 p, vec2 t )
+float sdTorus88(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdCylinder6( vec3 p, vec2 h )
+float sdCylinder6(vec3 p, vec2 h)
 {
 {
-    return max( length6(p.xz)-h.x, abs(p.y)-h.y );
+    return max(length6(p.xz)-h.x, abs(p.y)-h.y);
 }
 }
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float opS( float d1, float d2 )
+float opS(float d1, float d2)
 {
 {
     return max(-d2,d1);
     return max(-d2,d1);
 }
 }
 
 
-vec2 opU( vec2 d1, vec2 d2 )
+vec2 opU(vec2 d1, vec2 d2)
 {
 {
     return (d1.x<d2.x) ? d1 : d2;
     return (d1.x<d2.x) ? d1 : d2;
 }
 }
 
 
-vec3 opRep( vec3 p, vec3 c )
+vec3 opRep(vec3 p, vec3 c)
 {
 {
     return mod(p,c)-0.5*c;
     return mod(p,c)-0.5*c;
 }
 }
 
 
-vec3 opTwist( vec3 p )
+vec3 opTwist(vec3 p)
 {
 {
     float  c = cos(10.0*p.y+10.0);
     float  c = cos(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
@@ -215,110 +215,110 @@ vec3 opTwist( vec3 p )
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-vec2 map( in vec3 pos )
-{
-    vec2 res = opU( vec2( sdPlane(     pos), 1.0 ),
-                    vec2( sdSphere(    pos-vec3( 0.0,0.25, 0.0), 0.25 ), 46.9 ) );
-    res = opU( res, vec2( sdBox(       pos-vec3( 1.0,0.25, 0.0), vec3(0.25) ), 3.0 ) );
-    res = opU( res, vec2( udRoundBox(  pos-vec3( 1.0,0.25, 1.0), vec3(0.15), 0.1 ), 41.0 ) );
-    res = opU( res, vec2( sdTorus(     pos-vec3( 0.0,0.25, 1.0), vec2(0.20,0.05) ), 25.0 ) );
-    res = opU( res, vec2( sdCapsule(   pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1  ), 31.9 ) );
-    res = opU( res, vec2( sdTriPrism(  pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05) ),43.5 ) );
-    res = opU( res, vec2( sdCylinder(  pos-vec3( 1.0,0.30,-1.0), vec2(0.1,0.2) ), 8.0 ) );
-    res = opU( res, vec2( sdCone(      pos-vec3( 0.0,0.50,-1.0), vec3(0.8,0.6,0.3) ), 55.0 ) );
-    res = opU( res, vec2( sdTorus82(   pos-vec3( 0.0,0.25, 2.0), vec2(0.20,0.05) ),50.0 ) );
-    res = opU( res, vec2( sdTorus88(   pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05) ),43.0 ) );
-    res = opU( res, vec2( sdCylinder6( pos-vec3( 1.0,0.30, 2.0), vec2(0.1,0.2) ), 12.0 ) );
-    res = opU( res, vec2( sdHexPrism(  pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05) ),17.0 ) );
-    res = opU( res, vec2( sdPryamid4(  pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25) ),37.0 ) );
-    res = opU( res, vec2( opS( udRoundBox(  pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
-                               sdSphere(    pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0 ) );
-    res = opU( res, vec2( opS( sdTorus82(  pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
-                               sdCylinder(  opRep( vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0 ) );
-    res = opU( res, vec2( 0.5*sdSphere(    pos-vec3(-2.0,0.25,-1.0), 0.2 ) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0 ) );
-    res = opU( res, vec2( 0.5*sdTorus( opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7 ) );
-    res = opU( res, vec2( sdConeSection( pos-vec3( 0.0,0.35,-2.0), 0.15, 0.2, 0.1 ), 13.67 ) );
-    res = opU( res, vec2( sdEllipsoid( pos-vec3( 1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05) ), 43.17 ) );
+vec2 map(in vec3 pos)
+{
+    vec2 res = opU(vec2(sdPlane(    pos), 1.0),
+                    vec2(sdSphere(   pos-vec3(0.0,0.25, 0.0), 0.25), 46.9));
+    res = opU(res, vec2(sdBox(      pos-vec3(1.0,0.25, 0.0), vec3(0.25)), 3.0));
+    res = opU(res, vec2(udRoundBox( pos-vec3(1.0,0.25, 1.0), vec3(0.15), 0.1), 41.0));
+    res = opU(res, vec2(sdTorus(    pos-vec3(0.0,0.25, 1.0), vec2(0.20,0.05)), 25.0));
+    res = opU(res, vec2(sdCapsule(  pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1 ), 31.9));
+    res = opU(res, vec2(sdTriPrism( pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05)),43.5));
+    res = opU(res, vec2(sdCylinder( pos-vec3(1.0,0.30,-1.0), vec2(0.1,0.2)), 8.0));
+    res = opU(res, vec2(sdCone(     pos-vec3(0.0,0.50,-1.0), vec3(0.8,0.6,0.3)), 55.0));
+    res = opU(res, vec2(sdTorus82(  pos-vec3(0.0,0.25, 2.0), vec2(0.20,0.05)),50.0));
+    res = opU(res, vec2(sdTorus88(  pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05)),43.0));
+    res = opU(res, vec2(sdCylinder6(pos-vec3(1.0,0.30, 2.0), vec2(0.1,0.2)), 12.0));
+    res = opU(res, vec2(sdHexPrism( pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05)),17.0));
+    res = opU(res, vec2(sdPryamid4( pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25)),37.0));
+    res = opU(res, vec2(opS(udRoundBox( pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
+                               sdSphere(   pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0));
+    res = opU(res, vec2(opS(sdTorus82( pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
+                               sdCylinder( opRep(vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0));
+    res = opU(res, vec2(0.5*sdSphere(   pos-vec3(-2.0,0.25,-1.0), 0.2) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0));
+    res = opU(res, vec2(0.5*sdTorus(opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7));
+    res = opU(res, vec2(sdConeSection(pos-vec3(0.0,0.35,-2.0), 0.15, 0.2, 0.1), 13.67));
+    res = opU(res, vec2(sdEllipsoid(pos-vec3(1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05)), 43.17));
 
 
     return res;
     return res;
 }
 }
 
 
-vec2 castRay( in vec3 ro, in vec3 rd )
+vec2 castRay(in vec3 ro, in vec3 rd)
 {
 {
     float tmin = 0.2;
     float tmin = 0.2;
     float tmax = 30.0;
     float tmax = 30.0;
 
 
 #if 1
 #if 1
     // bounding volume
     // bounding volume
-    float tp1 = (0.0-ro.y)/rd.y; if( tp1>0.0 ) tmax = min( tmax, tp1 );
-    float tp2 = (1.6-ro.y)/rd.y; if( tp2>0.0 ) { if( ro.y>1.6 ) tmin = max( tmin, tp2 );
-                                                 else           tmax = min( tmax, tp2 ); }
+    float tp1 = (0.0-ro.y)/rd.y; if (tp1>0.0) tmax = min(tmax, tp1);
+    float tp2 = (1.6-ro.y)/rd.y; if (tp2>0.0) { if (ro.y>1.6) tmin = max(tmin, tp2);
+                                                 else           tmax = min(tmax, tp2); }
 #endif
 #endif
 
 
     float t = tmin;
     float t = tmin;
     float m = -1.0;
     float m = -1.0;
-    for( int i=0; i<64; i++ )
+    for (int i=0; i<64; i++)
     {
     {
         float precis = 0.0005*t;
         float precis = 0.0005*t;
-        vec2 res = map( ro+rd*t );
-        if( res.x<precis || t>tmax ) break;
+        vec2 res = map(ro+rd*t);
+        if (res.x<precis || t>tmax) break;
         t += res.x;
         t += res.x;
         m = res.y;
         m = res.y;
     }
     }
 
 
-    if( t>tmax ) m=-1.0;
-    return vec2( t, m );
+    if (t>tmax) m=-1.0;
+    return vec2(t, m);
 }
 }
 
 
 
 
-float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
 {
 {
     float res = 1.0;
     float res = 1.0;
     float t = mint;
     float t = mint;
-    for( int i=0; i<16; i++ )
+    for (int i=0; i<16; i++)
     {
     {
-        float h = map( ro + rd*t ).x;
-        res = min( res, 8.0*h/t );
-        t += clamp( h, 0.02, 0.10 );
-        if( h<0.001 || t>tmax ) break;
+        float h = map(ro + rd*t).x;
+        res = min(res, 8.0*h/t);
+        t += clamp(h, 0.02, 0.10);
+        if (h<0.001 || t>tmax) break;
     }
     }
-    return clamp( res, 0.0, 1.0 );
+    return clamp(res, 0.0, 1.0);
 }
 }
 
 
-vec3 calcNormal( in vec3 pos )
+vec3 calcNormal(in vec3 pos)
 {
 {
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
-    return normalize( e.xyy*map( pos + e.xyy ).x +
-                      e.yyx*map( pos + e.yyx ).x +
-                      e.yxy*map( pos + e.yxy ).x +
-                      e.xxx*map( pos + e.xxx ).x );
+    return normalize(e.xyy*map(pos + e.xyy).x +
+                      e.yyx*map(pos + e.yyx).x +
+                      e.yxy*map(pos + e.yxy).x +
+                      e.xxx*map(pos + e.xxx).x);
     /*
     /*
-    vec3 eps = vec3( 0.0005, 0.0, 0.0 );
+    vec3 eps = vec3(0.0005, 0.0, 0.0);
     vec3 nor = vec3(
     vec3 nor = vec3(
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
-        map(pos+eps.yyx).x - map(pos-eps.yyx).x );
+        map(pos+eps.yyx).x - map(pos-eps.yyx).x);
     return normalize(nor);
     return normalize(nor);
     */
     */
 }
 }
 
 
-float calcAO( in vec3 pos, in vec3 nor )
+float calcAO(in vec3 pos, in vec3 nor)
 {
 {
     float occ = 0.0;
     float occ = 0.0;
     float sca = 1.0;
     float sca = 1.0;
-    for( int i=0; i<5; i++ )
+    for (int i=0; i<5; i++)
     {
     {
         float hr = 0.01 + 0.12*float(i)/4.0;
         float hr = 0.01 + 0.12*float(i)/4.0;
-        vec3 aopos =  nor * hr + pos;
-        float dd = map( aopos ).x;
+        vec3 aopos =  nor*hr + pos;
+        float dd = map(aopos).x;
         occ += -(dd-hr)*sca;
         occ += -(dd-hr)*sca;
         sca *= 0.95;
         sca *= 0.95;
     }
     }
-    return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
+    return clamp(1.0 - 3.0*occ, 0.0, 1.0);
 }
 }
 
 
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
-float checkersGradBox( in vec2 p )
+float checkersGradBox(in vec2 p)
 {
 {
     // filter kernel
     // filter kernel
     vec2 w = fwidth(p) + 0.001;
     vec2 w = fwidth(p) + 0.001;
@@ -328,43 +328,43 @@ float checkersGradBox( in vec2 p )
     return 0.5 - 0.5*i.x*i.y;
     return 0.5 - 0.5*i.x*i.y;
 }
 }
 
 
-vec3 render( in vec3 ro, in vec3 rd )
+vec3 render(in vec3 ro, in vec3 rd)
 {
 {
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec2 res = castRay(ro,rd);
     vec2 res = castRay(ro,rd);
     float t = res.x;
     float t = res.x;
     float m = res.y;
     float m = res.y;
-    if( m>-0.5 )
+    if (m>-0.5)
     {
     {
         vec3 pos = ro + t*rd;
         vec3 pos = ro + t*rd;
-        vec3 nor = calcNormal( pos );
-        vec3 ref = reflect( rd, nor );
+        vec3 nor = calcNormal(pos);
+        vec3 ref = reflect(rd, nor);
 
 
         // material
         // material
-        col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) );
-        if( m<1.5 )
+        col = 0.45 + 0.35*sin(vec3(0.05,0.08,0.10)*(m-1.0));
+        if (m<1.5)
         {
         {
 
 
-            float f = checkersGradBox( 5.0*pos.xz );
+            float f = checkersGradBox(5.0*pos.xz);
             col = 0.3 + f*vec3(0.1);
             col = 0.3 + f*vec3(0.1);
         }
         }
 
 
         // lighting
         // lighting
-        float occ = calcAO( pos, nor );
-        vec3  lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) );
-        vec3  hal = normalize( lig-rd );
-        float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 );
-        float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
-        float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
-        float dom = smoothstep( -0.1, 0.1, ref.y );
-        float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
-
-        dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
-        dom *= calcSoftshadow( pos, ref, 0.02, 2.5 );
-
-        float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)*
+        float occ = calcAO(pos, nor);
+        vec3  lig = normalize(vec3(cos(-0.4*runTime), sin(0.7*runTime), -0.6));
+        vec3  hal = normalize(lig-rd);
+        float amb = clamp(0.5+0.5*nor.y, 0.0, 1.0);
+        float dif = clamp(dot(nor, lig), 0.0, 1.0);
+        float bac = clamp(dot(nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
+        float dom = smoothstep(-0.1, 0.1, ref.y);
+        float fre = pow(clamp(1.0+dot(nor,rd),0.0,1.0), 2.0);
+
+        dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
+        dom *= calcSoftshadow(pos, ref, 0.02, 2.5);
+
+        float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0)*
                     dif *
                     dif *
-                    (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 ));
+                    (0.04 + 0.96*pow(clamp(1.0+dot(hal,rd),0.0,1.0), 5.0));
 
 
         vec3 lin = vec3(0.0);
         vec3 lin = vec3(0.0);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
@@ -375,51 +375,51 @@ vec3 render( in vec3 ro, in vec3 rd )
         col = col*lin;
         col = col*lin;
         col += 10.00*spe*vec3(1.00,0.90,0.70);
         col += 10.00*spe*vec3(1.00,0.90,0.70);
 
 
-        col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) );
+        col = mix(col, vec3(0.8,0.9,1.0), 1.0-exp(-0.0002*t*t*t));
     }
     }
 
 
-    return vec3( clamp(col,0.0,1.0) );
+    return vec3(clamp(col,0.0,1.0));
 }
 }
 
 
-mat3 setCamera( in vec3 ro, in vec3 ta, float cr )
+mat3 setCamera(in vec3 ro, in vec3 ta, float cr)
 {
 {
     vec3 cw = normalize(ta-ro);
     vec3 cw = normalize(ta-ro);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
-    vec3 cu = normalize( cross(cw,cp) );
-    vec3 cv = normalize( cross(cu,cw) );
-    return mat3( cu, cv, cw );
+    vec3 cu = normalize(cross(cw,cp));
+    vec3 cv = normalize(cross(cu,cw));
+    return mat3(cu, cv, cw);
 }
 }
 
 
 void main()
 void main()
 {
 {
     vec3 tot = vec3(0.0);
     vec3 tot = vec3(0.0);
 #if AA>1
 #if AA>1
-    for( int m=0; m<AA; m++ )
-    for( int n=0; n<AA; n++ )
+    for (int m=0; m<AA; m++)
+    for (int n=0; n<AA; n++)
     {
     {
         // pixel coordinates
         // pixel coordinates
-        vec2 o = vec2(float(m),float(n)) / float(AA) - 0.5;
+        vec2 o = vec2(float(m),float(n))/float(AA) - 0.5;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
 #else
 #else
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
 #endif
 #endif
 
 
         // RAY: Camera is provided from raylib
         // RAY: Camera is provided from raylib
-        //vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) );
+        //vec3 ro = vec3(-0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x));
 
 
         vec3 ro = viewEye;
         vec3 ro = viewEye;
         vec3 ta = viewCenter;
         vec3 ta = viewCenter;
 
 
         // camera-to-world transformation
         // camera-to-world transformation
-        mat3 ca = setCamera( ro, ta, 0.0 );
+        mat3 ca = setCamera(ro, ta, 0.0);
         // ray direction
         // ray direction
-        vec3 rd = ca * normalize( vec3(p.xy,2.0) );
+        vec3 rd = ca*normalize(vec3(p.xy,2.0));
 
 
         // render
         // render
-        vec3 col = render( ro, rd );
+        vec3 col = render(ro, rd);
 
 
         // gamma
         // gamma
-        col = pow( col, vec3(0.4545) );
+        col = pow(col, vec3(0.4545));
 
 
         tot += col;
         tot += col;
 #if AA>1
 #if AA>1
@@ -427,5 +427,5 @@ void main()
     tot /= float(AA*AA);
     tot /= float(AA*AA);
 #endif
 #endif
 
 
-    gl_FragColor = vec4( tot, 1.0 );
+    gl_FragColor = vec4(tot, 1.0);
 }
 }

+ 2 - 2
examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs

@@ -1,9 +1,9 @@
-// Note: SDF by Iñigo Quilez is licensed under MIT License
-
 #version 100
 #version 100
 
 
 precision mediump float;
 precision mediump float;
 
 
+// NOTE: SDF by Iñigo Quilez, licensed under MIT License
+
 // Input vertex attributes (from vertex shader)
 // Input vertex attributes (from vertex shader)
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying vec4 fragColor;
 varying vec4 fragColor;

+ 1 - 1
examples/shaders/resources/shaders/glsl100/scanlines.fs

@@ -35,7 +35,7 @@ void main()
     fragColor = color;
     fragColor = color;
 */
 */
     // Scanlines method 2
     // Scanlines method 2
-    float globalPos = (fragTexCoord.y + offset) * frequency;
+    float globalPos = (fragTexCoord.y + offset)*frequency;
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
 
 
     vec4 color = texture2D(texture0, fragTexCoord);
     vec4 color = texture2D(texture0, fragTexCoord);

+ 2 - 2
examples/shaders/resources/shaders/glsl100/sobel.fs

@@ -20,10 +20,10 @@ void main()
 
 
     vec4 horizEdge = vec4(0.0);
     vec4 horizEdge = vec4(0.0);
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
-    horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y    ))*2.0;
+    horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y   ))*2.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
-    horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y    ))*2.0;
+    horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y   ))*2.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
 
 
     vec4 vertEdge = vec4(0.0);
     vec4 vertEdge = vec4(0.0);

+ 0 - 1
examples/shaders/resources/shaders/glsl100/vertex_displacement.fs

@@ -6,7 +6,6 @@ precision mediump float;
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying float height;
 varying float height;
 
 
-
 void main()
 void main()
 {
 {
     vec4 darkblue = vec4(0.0, 0.13, 0.18, 1.0);
     vec4 darkblue = vec4(0.0, 0.13, 0.18, 1.0);

+ 7 - 7
examples/shaders/resources/shaders/glsl100/vertex_displacement.vs

@@ -23,23 +23,23 @@ varying float height;
 void main()
 void main()
 {
 {
     // Calculate animated texture coordinates based on time and vertex position
     // Calculate animated texture coordinates based on time and vertex position
-    vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x * 0.1), cos(time + vertexPosition.z * 0.1)) * 0.3);
+    vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x*0.1), cos(time + vertexPosition.z*0.1))*0.3);
 
 
     // Normalize animated texture coordinates to range [0, 1]
     // Normalize animated texture coordinates to range [0, 1]
-    animatedTexCoord = animatedTexCoord * 0.5 + 0.5;
+    animatedTexCoord = animatedTexCoord*0.5 + 0.5;
 
 
     // Fetch displacement from the perlin noise map
     // Fetch displacement from the perlin noise map
-    float displacement = texture2D(perlinNoiseMap, animatedTexCoord).r * 7.0; // Amplified displacement
+    float displacement = texture2D(perlinNoiseMap, animatedTexCoord).r*7.0; // Amplified displacement
 
 
     // Displace vertex position
     // Displace vertex position
     vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
     vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
 
 
     // Send vertex attributes to fragment shader
     // Send vertex attributes to fragment shader
-    fragPosition = vec3(matModel * vec4(displacedPosition, 1.0));
+    fragPosition = vec3(matModel*vec4(displacedPosition, 1.0));
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
-    fragNormal = normalize(vec3(matNormal * vec4(vertexNormal, 1.0)));
-    height = displacedPosition.y * 0.2; // send height to fragment shader for coloring
+    fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
+    height = displacedPosition.y*0.2; // send height to fragment shader for coloring
 
 
     // Calculate final vertex position
     // Calculate final vertex position
-    gl_Position = mvp * vec4(displacedPosition, 1.0);
+    gl_Position = mvp*vec4(displacedPosition, 1.0);
 }
 }

+ 5 - 7
examples/shaders/resources/shaders/glsl100/wave.fs

@@ -11,9 +11,7 @@ uniform sampler2D texture0;
 uniform vec4 colDiffuse;
 uniform vec4 colDiffuse;
 
 
 uniform float seconds;
 uniform float seconds;
-
 uniform vec2 size;
 uniform vec2 size;
-
 uniform float freqX;
 uniform float freqX;
 uniform float freqY;
 uniform float freqY;
 uniform float ampX;
 uniform float ampX;
@@ -22,15 +20,15 @@ uniform float speedX;
 uniform float speedY;
 uniform float speedY;
 
 
 void main() {
 void main() {
-    float pixelWidth = 1.0 / size.x;
-    float pixelHeight = 1.0 / size.y;
-    float aspect = pixelHeight / pixelWidth;
+    float pixelWidth = 1.0/size.x;
+    float pixelHeight = 1.0/size.y;
+    float aspect = pixelHeight/pixelWidth;
     float boxLeft = 0.0;
     float boxLeft = 0.0;
     float boxTop = 0.0;
     float boxTop = 0.0;
 
 
     vec2 p = fragTexCoord;
     vec2 p = fragTexCoord;
-    p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
-    p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
+    p.x += cos((fragTexCoord.y - boxTop)*freqX/(pixelWidth*750.0) + (seconds*speedX))*ampX*pixelWidth;
+    p.y += sin((fragTexCoord.x - boxLeft)*freqY*aspect/(pixelHeight*750.0) + (seconds*speedY))*ampY*pixelHeight;
 
 
     gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
     gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
 }
 }

+ 3 - 2
examples/shaders/resources/shaders/glsl100/write_depth.fs

@@ -1,6 +1,7 @@
-#version 100             
+#version 100
+
 #extension GL_EXT_frag_depth : enable          
 #extension GL_EXT_frag_depth : enable          
-precision mediump float;                // Precision required for OpenGL ES2 (WebGL)
+precision mediump float;
 
 
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying vec4 fragColor;
 varying vec4 fragColor;

+ 4 - 4
examples/shaders/resources/shaders/glsl120/cross_stitching.fs

@@ -21,8 +21,8 @@ vec4 PostFX(sampler2D tex, vec2 uv)
 {
 {
     vec4 c = vec4(0.0);
     vec4 c = vec4(0.0);
     float size = stitchingSize;
     float size = stitchingSize;
-    vec2 cPos = uv * vec2(renderWidth, renderHeight);
-    vec2 tlPos = floor(cPos / vec2(size, size));
+    vec2 cPos = uv*vec2(renderWidth, renderHeight);
+    vec2 tlPos = floor(cPos/vec2(size, size));
     tlPos *= size;
     tlPos *= size;
 
 
     int remX = int(mod(cPos.x, size));
     int remX = int(mod(cPos.x, size));
@@ -36,11 +36,11 @@ vec4 PostFX(sampler2D tex, vec2 uv)
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     {
     {
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
-        else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        else c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
     }
     }
     else
     else
     {
     {
-        if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        if (invert == 1) c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
         else c = vec4(0.0, 0.0, 0.0, 1.0);
         else c = vec4(0.0, 0.0, 0.0, 1.0);
     }
     }
 
 

+ 7 - 7
examples/shaders/resources/shaders/glsl120/fisheye.fs

@@ -15,22 +15,22 @@ const float PI = 3.1415926535;
 void main()
 void main()
 {
 {
     float aperture = 178.0;
     float aperture = 178.0;
-    float apertureHalf = 0.5 * aperture * (PI / 180.0);
+    float apertureHalf = 0.5*aperture*(PI/180.0);
     float maxFactor = sin(apertureHalf);
     float maxFactor = sin(apertureHalf);
 
 
     vec2 uv = vec2(0.0);
     vec2 uv = vec2(0.0);
-    vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
+    vec2 xy = 2.0*fragTexCoord.xy - 1.0;
     float d = length(xy);
     float d = length(xy);
 
 
     if (d < (2.0 - maxFactor))
     if (d < (2.0 - maxFactor))
     {
     {
-        d = length(xy * maxFactor);
-        float z = sqrt(1.0 - d * d);
-        float r = atan(d, z) / PI;
+        d = length(xy*maxFactor);
+        float z = sqrt(1.0 - d*d);
+        float r = atan(d, z)/PI;
         float phi = atan(xy.y, xy.x);
         float phi = atan(xy.y, xy.x);
 
 
-        uv.x = r * cos(phi) + 0.5;
-        uv.y = r * sin(phi) + 0.5;
+        uv.x = r*cos(phi) + 0.5;
+        uv.y = r*sin(phi) + 0.5;
     }
     }
     else
     else
     {
     {

+ 1 - 1
examples/shaders/resources/shaders/glsl120/lighting.fs

@@ -38,7 +38,7 @@ void main()
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 specular = vec3(0.0);
     vec3 specular = vec3(0.0);
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     // NOTE: Implement here your fragment shader code
     // NOTE: Implement here your fragment shader code
 
 

+ 1 - 1
examples/shaders/resources/shaders/glsl120/lightmap.fs

@@ -16,5 +16,5 @@ void main()
     vec4 texelColor = texture2D(texture0, fragTexCoord);
     vec4 texelColor = texture2D(texture0, fragTexCoord);
     vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
     vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
 
 
-    gl_FragColor = texelColor * texelColor2;
+    gl_FragColor = texelColor*texelColor2;
 }
 }

+ 7 - 7
examples/shaders/resources/shaders/glsl120/normalmap.fs

@@ -32,21 +32,21 @@ void main()
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
 
 
         //Transform normal values to the range -1.0 ... 1.0
         //Transform normal values to the range -1.0 ... 1.0
-        normal = normalize(normal * 2.0 - 1.0);
+        normal = normalize(normal*2.0 - 1.0);
 
 
         //Transform the normal from tangent-space to world-space for lighting calculation
         //Transform the normal from tangent-space to world-space for lighting calculation
-        normal = normalize(normal * TBN);
+        normal = normalize(normal*TBN);
     }
     }
     else
     else
     {
     {
         normal = normalize(fragNormal);
         normal = normalize(fragNormal);
     }
     }
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
-    vec3 lightDot = lightColor * NdotL;
+    vec3 lightDot = lightColor*NdotL;
 
 
     float specCo = 0.0;
     float specCo = 0.0;
 
 
@@ -54,9 +54,9 @@ void main()
 
 
     specular += specCo;
     specular += specCo;
 
 
-    finalColor = (texelColor * ((tint + vec4(specular, 1.0)) * vec4(lightDot, 1.0)));
-    finalColor += texelColor * (vec4(1.0, 1.0, 1.0, 1.0) / 40.0) * tint;
+    finalColor = (texelColor*((tint + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
+    finalColor += texelColor*(vec4(1.0, 1.0, 1.0, 1.0)/40.0)*tint;
 
 
     // Gamma correction
     // Gamma correction
-    gl_FragColor = pow(finalColor, vec4(1.0 / 2.2));
+    gl_FragColor = pow(finalColor, vec4(1.0/2.2));
 }
 }

+ 14 - 14
examples/shaders/resources/shaders/glsl120/normalmap.vs

@@ -27,15 +27,15 @@ mat3 inverse(mat3 m)
     float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
     float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
     float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
     float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
 
 
-    float b01 = a22 * a11 - a12 * a21;
-    float b11 = -a22 * a10 + a12 * a20;
-    float b21 = a21 * a10 - a11 * a20;
+    float b01 = a22*a11 - a12*a21;
+    float b11 = -a22*a10 + a12*a20;
+    float b21 = a21*a10 - a11*a20;
 
 
-    float det = a00 * b01 + a01 * b11 + a02 * b21;
+    float det = a00*b01 + a01*b11 + a02*b21;
 
 
-    return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
-        b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
-        b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
+    return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
+        b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
+        b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
 }
 }
 
 
 // https://github.com/glslify/glsl-transpose
 // https://github.com/glslify/glsl-transpose
@@ -49,21 +49,21 @@ mat3 transpose(mat3 m)
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
 
 
     // Compute fragment position based on model transformations
     // Compute fragment position based on model transformations
-    fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
+    fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
 
 
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
-    fragNormal = normalize(normalMatrix * vertexNormal);
+    fragNormal = normalize(normalMatrix*vertexNormal);
 
 
-    vec3 fragTangent = normalize(normalMatrix * vertexTangent.xyz);
-    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal) * fragNormal);
+    vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
+    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
 
 
-    vec3 fragBinormal = normalize(normalMatrix * vertexBinormal);
+    vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
     fragBinormal = cross(fragNormal, fragTangent);
     fragBinormal = cross(fragNormal, fragTangent);
 
 
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
@@ -72,5 +72,5 @@ void main()
 
 
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
 
 
-    gl_Position = mvp * vec4(vertexPosition, 1.0);
+    gl_Position = mvp*vec4(vertexPosition, 1.0);
 }
 }

+ 5 - 5
examples/shaders/resources/shaders/glsl120/palette_switch.fs

@@ -13,15 +13,15 @@ uniform ivec3 palette[colors];
 void main()
 void main()
 {
 {
     // Texel color fetching from texture sampler
     // Texel color fetching from texture sampler
-    vec4 texelColor = texture(texture0, fragTexCoord) * fragColor;
+    vec4 texelColor = texture(texture0, fragTexCoord)*fragColor;
 
 
     // Convert the (normalized) texel color RED component (GB would work, too)
     // Convert the (normalized) texel color RED component (GB would work, too)
-    // to the palette index by scaling up from [0, 1] to [0, 255].
-    int index = int(texelColor.r * 255.0);
+    // to the palette index by scaling up from [0, 1] to [0, 255]
+    int index = int(texelColor.r*255.0);
     ivec3 color = palette[index];
     ivec3 color = palette[index];
 
 
     // Calculate final fragment color. Note that the palette color components
     // 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]
     // are defined in the range [0, 255] and need to be normalized to [0, 1]
-    // for OpenGL to work.
-    gl_FragColor = vec4(color / 255.0, texelColor.a);
+    // for OpenGL to work
+    gl_FragColor = vec4(color/255.0, texelColor.a);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl120/pbr.vs

@@ -52,7 +52,7 @@ mat3 transpose(mat3 m)
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent
     // Compute binormal from vertex normal and tangent
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));

+ 132 - 132
examples/shaders/resources/shaders/glsl120/raymarching.fs

@@ -30,7 +30,7 @@ uniform vec2 resolution;
 // SOFTWARE.
 // SOFTWARE.
 
 
 // A list of useful distance function to simple primitives, and an example on how to
 // A list of useful distance function to simple primitives, and an example on how to
-// do some interesting boolean operations, repetition and displacement.
+// do some interesting boolean operations, repetition and displacement
 //
 //
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 
 
@@ -38,38 +38,38 @@ uniform vec2 resolution;
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float sdPlane( vec3 p )
+float sdPlane(vec3 p)
 {
 {
     return p.y;
     return p.y;
 }
 }
 
 
-float sdSphere( vec3 p, float s )
+float sdSphere(vec3 p, float s)
 {
 {
     return length(p)-s;
     return length(p)-s;
 }
 }
 
 
-float sdBox( vec3 p, vec3 b )
+float sdBox(vec3 p, vec3 b)
 {
 {
     vec3 d = abs(p) - b;
     vec3 d = abs(p) - b;
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdEllipsoid( in vec3 p, in vec3 r )
+float sdEllipsoid(in vec3 p, in vec3 r)
 {
 {
-    return (length( p/r ) - 1.0) * min(min(r.x,r.y),r.z);
+    return (length(p/r) - 1.0)*min(min(r.x,r.y),r.z);
 }
 }
 
 
-float udRoundBox( vec3 p, vec3 b, float r )
+float udRoundBox(vec3 p, vec3 b, float r)
 {
 {
     return length(max(abs(p)-b,0.0))-r;
     return length(max(abs(p)-b,0.0))-r;
 }
 }
 
 
-float sdTorus( vec3 p, vec2 t )
+float sdTorus(vec3 p, vec2 t)
 {
 {
-    return length( vec2(length(p.xz)-t.x,p.y) )-t.y;
+    return length(vec2(length(p.xz)-t.x,p.y))-t.y;
 }
 }
 
 
-float sdHexPrism( vec3 p, vec2 h )
+float sdHexPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
 #if 0
 #if 0
@@ -81,24 +81,24 @@ float sdHexPrism( vec3 p, vec2 h )
 #endif
 #endif
 }
 }
 
 
-float sdCapsule( vec3 p, vec3 a, vec3 b, float r )
+float sdCapsule(vec3 p, vec3 a, vec3 b, float r)
 {
 {
     vec3 pa = p-a, ba = b-a;
     vec3 pa = p-a, ba = b-a;
-    float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
-    return length( pa - ba*h ) - r;
+    float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);
+    return length(pa - ba*h) - r;
 }
 }
 
 
-float sdEquilateralTriangle(  in vec2 p )
+float sdEquilateralTriangle( in vec2 p)
 {
 {
     const float k = sqrt(3.0);
     const float k = sqrt(3.0);
     p.x = abs(p.x) - 1.0;
     p.x = abs(p.x) - 1.0;
     p.y = p.y + 1.0/k;
     p.y = p.y + 1.0/k;
-    if( p.x + k*p.y > 0.0 ) p = vec2( p.x - k*p.y, -k*p.x - p.y )/2.0;
-    p.x += 2.0 - 2.0*clamp( (p.x+2.0)/2.0, 0.0, 1.0 );
+    if (p.x + k*p.y > 0.0) p = vec2(p.x - k*p.y, -k*p.x - p.y)/2.0;
+    p.x += 2.0 - 2.0*clamp((p.x+2.0)/2.0, 0.0, 1.0);
     return -length(p)*sign(p.y);
     return -length(p)*sign(p.y);
 }
 }
 
 
-float sdTriPrism( vec3 p, vec2 h )
+float sdTriPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
     float d1 = q.z-h.y;
     float d1 = q.z-h.y;
@@ -113,95 +113,95 @@ float sdTriPrism( vec3 p, vec2 h )
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdCylinder( vec3 p, vec2 h )
+float sdCylinder(vec3 p, vec2 h)
 {
 {
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdCone( in vec3 p, in vec3 c )
+float sdCone(in vec3 p, in vec3 c)
 {
 {
-    vec2 q = vec2( length(p.xz), p.y );
+    vec2 q = vec2(length(p.xz), p.y);
     float d1 = -q.y-c.z;
     float d1 = -q.y-c.z;
-    float d2 = max( dot(q,c.xy), q.y);
+    float d2 = max(dot(q,c.xy), q.y);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdConeSection( in vec3 p, in float h, in float r1, in float r2 )
+float sdConeSection(in vec3 p, in float h, in float r1, in float r2)
 {
 {
     float d1 = -p.y - h;
     float d1 = -p.y - h;
     float q = p.y - h;
     float q = p.y - h;
     float si = 0.5*(r1-r2)/h;
     float si = 0.5*(r1-r2)/h;
-    float d2 = max( sqrt( dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q );
+    float d2 = max(sqrt(dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height }
+float sdPryamid4(vec3 p, vec3 h) // h = { cos a, sin a, height }
 {
 {
     // Tetrahedron = Octahedron - Cube
     // Tetrahedron = Octahedron - Cube
-    float box = sdBox( p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z) );
+    float box = sdBox(p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z));
 
 
     float d = 0.0;
     float d = 0.0;
-    d = max( d, abs( dot(p, vec3( -h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y, h.x )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y,-h.x )) ));
+    d = max(d, abs(dot(p, vec3(-h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( 0, h.y, h.x))));
+    d = max(d, abs(dot(p, vec3( 0, h.y,-h.x))));
     float octa = d - h.z;
     float octa = d - h.z;
     return max(-box,octa); // Subtraction
     return max(-box,octa); // Subtraction
  }
  }
 
 
-float length2( vec2 p )
+float length2(vec2 p)
 {
 {
-    return sqrt( p.x*p.x + p.y*p.y );
+    return sqrt(p.x*p.x + p.y*p.y);
 }
 }
 
 
-float length6( vec2 p )
+float length6(vec2 p)
 {
 {
     p = p*p*p; p = p*p;
     p = p*p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/6.0 );
+    return pow(p.x + p.y, 1.0/6.0);
 }
 }
 
 
-float length8( vec2 p )
+float length8(vec2 p)
 {
 {
     p = p*p; p = p*p; p = p*p;
     p = p*p; p = p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/8.0 );
+    return pow(p.x + p.y, 1.0/8.0);
 }
 }
 
 
-float sdTorus82( vec3 p, vec2 t )
+float sdTorus82(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdTorus88( vec3 p, vec2 t )
+float sdTorus88(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdCylinder6( vec3 p, vec2 h )
+float sdCylinder6(vec3 p, vec2 h)
 {
 {
-    return max( length6(p.xz)-h.x, abs(p.y)-h.y );
+    return max(length6(p.xz)-h.x, abs(p.y)-h.y);
 }
 }
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float opS( float d1, float d2 )
+float opS(float d1, float d2)
 {
 {
     return max(-d2,d1);
     return max(-d2,d1);
 }
 }
 
 
-vec2 opU( vec2 d1, vec2 d2 )
+vec2 opU(vec2 d1, vec2 d2)
 {
 {
     return (d1.x<d2.x) ? d1 : d2;
     return (d1.x<d2.x) ? d1 : d2;
 }
 }
 
 
-vec3 opRep( vec3 p, vec3 c )
+vec3 opRep(vec3 p, vec3 c)
 {
 {
     return mod(p,c)-0.5*c;
     return mod(p,c)-0.5*c;
 }
 }
 
 
-vec3 opTwist( vec3 p )
+vec3 opTwist(vec3 p)
 {
 {
     float  c = cos(10.0*p.y+10.0);
     float  c = cos(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
@@ -211,110 +211,110 @@ vec3 opTwist( vec3 p )
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-vec2 map( in vec3 pos )
-{
-    vec2 res = opU( vec2( sdPlane(     pos), 1.0 ),
-                    vec2( sdSphere(    pos-vec3( 0.0,0.25, 0.0), 0.25 ), 46.9 ) );
-    res = opU( res, vec2( sdBox(       pos-vec3( 1.0,0.25, 0.0), vec3(0.25) ), 3.0 ) );
-    res = opU( res, vec2( udRoundBox(  pos-vec3( 1.0,0.25, 1.0), vec3(0.15), 0.1 ), 41.0 ) );
-    res = opU( res, vec2( sdTorus(     pos-vec3( 0.0,0.25, 1.0), vec2(0.20,0.05) ), 25.0 ) );
-    res = opU( res, vec2( sdCapsule(   pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1  ), 31.9 ) );
-    res = opU( res, vec2( sdTriPrism(  pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05) ),43.5 ) );
-    res = opU( res, vec2( sdCylinder(  pos-vec3( 1.0,0.30,-1.0), vec2(0.1,0.2) ), 8.0 ) );
-    res = opU( res, vec2( sdCone(      pos-vec3( 0.0,0.50,-1.0), vec3(0.8,0.6,0.3) ), 55.0 ) );
-    res = opU( res, vec2( sdTorus82(   pos-vec3( 0.0,0.25, 2.0), vec2(0.20,0.05) ),50.0 ) );
-    res = opU( res, vec2( sdTorus88(   pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05) ),43.0 ) );
-    res = opU( res, vec2( sdCylinder6( pos-vec3( 1.0,0.30, 2.0), vec2(0.1,0.2) ), 12.0 ) );
-    res = opU( res, vec2( sdHexPrism(  pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05) ),17.0 ) );
-    res = opU( res, vec2( sdPryamid4(  pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25) ),37.0 ) );
-    res = opU( res, vec2( opS( udRoundBox(  pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
-                               sdSphere(    pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0 ) );
-    res = opU( res, vec2( opS( sdTorus82(  pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
-                               sdCylinder(  opRep( vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0 ) );
-    res = opU( res, vec2( 0.5*sdSphere(    pos-vec3(-2.0,0.25,-1.0), 0.2 ) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0 ) );
-    res = opU( res, vec2( 0.5*sdTorus( opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7 ) );
-    res = opU( res, vec2( sdConeSection( pos-vec3( 0.0,0.35,-2.0), 0.15, 0.2, 0.1 ), 13.67 ) );
-    res = opU( res, vec2( sdEllipsoid( pos-vec3( 1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05) ), 43.17 ) );
+vec2 map(in vec3 pos)
+{
+    vec2 res = opU(vec2(sdPlane(    pos), 1.0),
+                    vec2(sdSphere(   pos-vec3(0.0,0.25, 0.0), 0.25), 46.9));
+    res = opU(res, vec2(sdBox(      pos-vec3(1.0,0.25, 0.0), vec3(0.25)), 3.0));
+    res = opU(res, vec2(udRoundBox( pos-vec3(1.0,0.25, 1.0), vec3(0.15), 0.1), 41.0));
+    res = opU(res, vec2(sdTorus(    pos-vec3(0.0,0.25, 1.0), vec2(0.20,0.05)), 25.0));
+    res = opU(res, vec2(sdCapsule(  pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1 ), 31.9));
+    res = opU(res, vec2(sdTriPrism( pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05)),43.5));
+    res = opU(res, vec2(sdCylinder( pos-vec3(1.0,0.30,-1.0), vec2(0.1,0.2)), 8.0));
+    res = opU(res, vec2(sdCone(     pos-vec3(0.0,0.50,-1.0), vec3(0.8,0.6,0.3)), 55.0));
+    res = opU(res, vec2(sdTorus82(  pos-vec3(0.0,0.25, 2.0), vec2(0.20,0.05)),50.0));
+    res = opU(res, vec2(sdTorus88(  pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05)),43.0));
+    res = opU(res, vec2(sdCylinder6(pos-vec3(1.0,0.30, 2.0), vec2(0.1,0.2)), 12.0));
+    res = opU(res, vec2(sdHexPrism( pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05)),17.0));
+    res = opU(res, vec2(sdPryamid4( pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25)),37.0));
+    res = opU(res, vec2(opS(udRoundBox( pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
+                               sdSphere(   pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0));
+    res = opU(res, vec2(opS(sdTorus82( pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
+                               sdCylinder( opRep(vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0));
+    res = opU(res, vec2(0.5*sdSphere(   pos-vec3(-2.0,0.25,-1.0), 0.2) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0));
+    res = opU(res, vec2(0.5*sdTorus(opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7));
+    res = opU(res, vec2(sdConeSection(pos-vec3(0.0,0.35,-2.0), 0.15, 0.2, 0.1), 13.67));
+    res = opU(res, vec2(sdEllipsoid(pos-vec3(1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05)), 43.17));
 
 
     return res;
     return res;
 }
 }
 
 
-vec2 castRay( in vec3 ro, in vec3 rd )
+vec2 castRay(in vec3 ro, in vec3 rd)
 {
 {
     float tmin = 0.2;
     float tmin = 0.2;
     float tmax = 30.0;
     float tmax = 30.0;
 
 
 #if 1
 #if 1
     // bounding volume
     // bounding volume
-    float tp1 = (0.0-ro.y)/rd.y; if( tp1>0.0 ) tmax = min( tmax, tp1 );
-    float tp2 = (1.6-ro.y)/rd.y; if( tp2>0.0 ) { if( ro.y>1.6 ) tmin = max( tmin, tp2 );
-                                                 else           tmax = min( tmax, tp2 ); }
+    float tp1 = (0.0-ro.y)/rd.y; if (tp1>0.0) tmax = min(tmax, tp1);
+    float tp2 = (1.6-ro.y)/rd.y; if (tp2>0.0) { if (ro.y>1.6) tmin = max(tmin, tp2);
+                                                 else           tmax = min(tmax, tp2); }
 #endif
 #endif
 
 
     float t = tmin;
     float t = tmin;
     float m = -1.0;
     float m = -1.0;
-    for( int i=0; i<64; i++ )
+    for (int i=0; i<64; i++)
     {
     {
         float precis = 0.0005*t;
         float precis = 0.0005*t;
-        vec2 res = map( ro+rd*t );
-        if( res.x<precis || t>tmax ) break;
+        vec2 res = map(ro+rd*t);
+        if (res.x<precis || t>tmax) break;
         t += res.x;
         t += res.x;
         m = res.y;
         m = res.y;
     }
     }
 
 
-    if( t>tmax ) m=-1.0;
-    return vec2( t, m );
+    if (t>tmax) m=-1.0;
+    return vec2(t, m);
 }
 }
 
 
 
 
-float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
 {
 {
     float res = 1.0;
     float res = 1.0;
     float t = mint;
     float t = mint;
-    for( int i=0; i<16; i++ )
+    for (int i=0; i<16; i++)
     {
     {
-        float h = map( ro + rd*t ).x;
-        res = min( res, 8.0*h/t );
-        t += clamp( h, 0.02, 0.10 );
-        if( h<0.001 || t>tmax ) break;
+        float h = map(ro + rd*t).x;
+        res = min(res, 8.0*h/t);
+        t += clamp(h, 0.02, 0.10);
+        if (h<0.001 || t>tmax) break;
     }
     }
-    return clamp( res, 0.0, 1.0 );
+    return clamp(res, 0.0, 1.0);
 }
 }
 
 
-vec3 calcNormal( in vec3 pos )
+vec3 calcNormal(in vec3 pos)
 {
 {
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
-    return normalize( e.xyy*map( pos + e.xyy ).x +
-                      e.yyx*map( pos + e.yyx ).x +
-                      e.yxy*map( pos + e.yxy ).x +
-                      e.xxx*map( pos + e.xxx ).x );
+    return normalize(e.xyy*map(pos + e.xyy).x +
+                      e.yyx*map(pos + e.yyx).x +
+                      e.yxy*map(pos + e.yxy).x +
+                      e.xxx*map(pos + e.xxx).x);
     /*
     /*
-    vec3 eps = vec3( 0.0005, 0.0, 0.0 );
+    vec3 eps = vec3(0.0005, 0.0, 0.0);
     vec3 nor = vec3(
     vec3 nor = vec3(
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
-        map(pos+eps.yyx).x - map(pos-eps.yyx).x );
+        map(pos+eps.yyx).x - map(pos-eps.yyx).x);
     return normalize(nor);
     return normalize(nor);
     */
     */
 }
 }
 
 
-float calcAO( in vec3 pos, in vec3 nor )
+float calcAO(in vec3 pos, in vec3 nor)
 {
 {
     float occ = 0.0;
     float occ = 0.0;
     float sca = 1.0;
     float sca = 1.0;
-    for( int i=0; i<5; i++ )
+    for (int i=0; i<5; i++)
     {
     {
         float hr = 0.01 + 0.12*float(i)/4.0;
         float hr = 0.01 + 0.12*float(i)/4.0;
-        vec3 aopos =  nor * hr + pos;
-        float dd = map( aopos ).x;
+        vec3 aopos =  nor*hr + pos;
+        float dd = map(aopos).x;
         occ += -(dd-hr)*sca;
         occ += -(dd-hr)*sca;
         sca *= 0.95;
         sca *= 0.95;
     }
     }
-    return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
+    return clamp(1.0 - 3.0*occ, 0.0, 1.0);
 }
 }
 
 
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
-float checkersGradBox( in vec2 p )
+float checkersGradBox(in vec2 p)
 {
 {
     // filter kernel
     // filter kernel
     vec2 w = fwidth(p) + 0.001;
     vec2 w = fwidth(p) + 0.001;
@@ -324,43 +324,43 @@ float checkersGradBox( in vec2 p )
     return 0.5 - 0.5*i.x*i.y;
     return 0.5 - 0.5*i.x*i.y;
 }
 }
 
 
-vec3 render( in vec3 ro, in vec3 rd )
+vec3 render(in vec3 ro, in vec3 rd)
 {
 {
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec2 res = castRay(ro,rd);
     vec2 res = castRay(ro,rd);
     float t = res.x;
     float t = res.x;
     float m = res.y;
     float m = res.y;
-    if( m>-0.5 )
+    if (m>-0.5)
     {
     {
         vec3 pos = ro + t*rd;
         vec3 pos = ro + t*rd;
-        vec3 nor = calcNormal( pos );
-        vec3 ref = reflect( rd, nor );
+        vec3 nor = calcNormal(pos);
+        vec3 ref = reflect(rd, nor);
 
 
         // material
         // material
-        col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) );
-        if( m<1.5 )
+        col = 0.45 + 0.35*sin(vec3(0.05,0.08,0.10)*(m-1.0));
+        if (m<1.5)
         {
         {
 
 
-            float f = checkersGradBox( 5.0*pos.xz );
+            float f = checkersGradBox(5.0*pos.xz);
             col = 0.3 + f*vec3(0.1);
             col = 0.3 + f*vec3(0.1);
         }
         }
 
 
         // lighting
         // lighting
-        float occ = calcAO( pos, nor );
-        vec3  lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) );
-        vec3  hal = normalize( lig-rd );
-        float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 );
-        float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
-        float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
-        float dom = smoothstep( -0.1, 0.1, ref.y );
-        float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
-
-        dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
-        dom *= calcSoftshadow( pos, ref, 0.02, 2.5 );
-
-        float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)*
+        float occ = calcAO(pos, nor);
+        vec3  lig = normalize(vec3(cos(-0.4*runTime), sin(0.7*runTime), -0.6));
+        vec3  hal = normalize(lig-rd);
+        float amb = clamp(0.5+0.5*nor.y, 0.0, 1.0);
+        float dif = clamp(dot(nor, lig), 0.0, 1.0);
+        float bac = clamp(dot(nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
+        float dom = smoothstep(-0.1, 0.1, ref.y);
+        float fre = pow(clamp(1.0+dot(nor,rd),0.0,1.0), 2.0);
+
+        dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
+        dom *= calcSoftshadow(pos, ref, 0.02, 2.5);
+
+        float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0)*
                     dif *
                     dif *
-                    (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 ));
+                    (0.04 + 0.96*pow(clamp(1.0+dot(hal,rd),0.0,1.0), 5.0));
 
 
         vec3 lin = vec3(0.0);
         vec3 lin = vec3(0.0);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
@@ -371,51 +371,51 @@ vec3 render( in vec3 ro, in vec3 rd )
         col = col*lin;
         col = col*lin;
         col += 10.00*spe*vec3(1.00,0.90,0.70);
         col += 10.00*spe*vec3(1.00,0.90,0.70);
 
 
-        col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) );
+        col = mix(col, vec3(0.8,0.9,1.0), 1.0-exp(-0.0002*t*t*t));
     }
     }
 
 
-    return vec3( clamp(col,0.0,1.0) );
+    return vec3(clamp(col,0.0,1.0));
 }
 }
 
 
-mat3 setCamera( in vec3 ro, in vec3 ta, float cr )
+mat3 setCamera(in vec3 ro, in vec3 ta, float cr)
 {
 {
     vec3 cw = normalize(ta-ro);
     vec3 cw = normalize(ta-ro);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
-    vec3 cu = normalize( cross(cw,cp) );
-    vec3 cv = normalize( cross(cu,cw) );
-    return mat3( cu, cv, cw );
+    vec3 cu = normalize(cross(cw,cp));
+    vec3 cv = normalize(cross(cu,cw));
+    return mat3(cu, cv, cw);
 }
 }
 
 
 void main()
 void main()
 {
 {
     vec3 tot = vec3(0.0);
     vec3 tot = vec3(0.0);
 #if AA>1
 #if AA>1
-    for( int m=0; m<AA; m++ )
-    for( int n=0; n<AA; n++ )
+    for (int m=0; m<AA; m++)
+    for (int n=0; n<AA; n++)
     {
     {
         // pixel coordinates
         // pixel coordinates
-        vec2 o = vec2(float(m),float(n)) / float(AA) - 0.5;
+        vec2 o = vec2(float(m),float(n))/float(AA) - 0.5;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
 #else
 #else
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
 #endif
 #endif
 
 
         // RAY: Camera is provided from raylib
         // RAY: Camera is provided from raylib
-        //vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) );
+        //vec3 ro = vec3(-0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x));
 
 
         vec3 ro = viewEye;
         vec3 ro = viewEye;
         vec3 ta = viewCenter;
         vec3 ta = viewCenter;
 
 
         // camera-to-world transformation
         // camera-to-world transformation
-        mat3 ca = setCamera( ro, ta, 0.0 );
+        mat3 ca = setCamera(ro, ta, 0.0);
         // ray direction
         // ray direction
-        vec3 rd = ca * normalize( vec3(p.xy,2.0) );
+        vec3 rd = ca*normalize(vec3(p.xy,2.0));
 
 
         // render
         // render
-        vec3 col = render( ro, rd );
+        vec3 col = render(ro, rd);
 
 
         // gamma
         // gamma
-        col = pow( col, vec3(0.4545) );
+        col = pow(col, vec3(0.4545));
 
 
         tot += col;
         tot += col;
 #if AA>1
 #if AA>1
@@ -423,5 +423,5 @@ void main()
     tot /= float(AA*AA);
     tot /= float(AA*AA);
 #endif
 #endif
 
 
-    gl_FragColor = vec4( tot, 1.0 );
+    gl_FragColor = vec4(tot, 1.0);
 }
 }

+ 2 - 2
examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs

@@ -1,7 +1,7 @@
-// Note: SDF by Iñigo Quilez is licensed under MIT License
-
 #version 120
 #version 120
 
 
+// NOTE: SDF by Iñigo Quilez, licensed under MIT License
+
 // Input vertex attributes (from vertex shader)
 // Input vertex attributes (from vertex shader)
 varying vec2 fragTexCoord;
 varying vec2 fragTexCoord;
 varying vec4 fragColor;
 varying vec4 fragColor;

+ 1 - 1
examples/shaders/resources/shaders/glsl120/scanlines.fs

@@ -33,7 +33,7 @@ void main()
     fragColor = color;
     fragColor = color;
 */
 */
     // Scanlines method 2
     // Scanlines method 2
-    float globalPos = (fragTexCoord.y + offset) * frequency;
+    float globalPos = (fragTexCoord.y + offset)*frequency;
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
 
 
     vec4 color = texture2D(texture0, fragTexCoord);
     vec4 color = texture2D(texture0, fragTexCoord);

+ 3 - 3
examples/shaders/resources/shaders/glsl120/shadowmap.fs

@@ -52,7 +52,7 @@ void main()
     vec2 sampleCoords = fragPosLightSpace.xy;
     vec2 sampleCoords = fragPosLightSpace.xy;
     float curDepth = fragPosLightSpace.z;
     float curDepth = fragPosLightSpace.z;
 
 
-    // Slope-scale depth bias: depth biasing reduces "shadow acne" artifacts, where dark stripes appear all over the scene.
+    // Slope-scale depth bias: depth biasing reduces "shadow acne" artifacts, where dark stripes appear all over the scene
     // The solution is adding a small bias to the depth
     // The solution is adding a small bias to the depth
     // In this case, the bias is proportional to the slope of the surface, relative to the light
     // In this case, the bias is proportional to the slope of the surface, relative to the light
     float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008);
     float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008);
@@ -61,8 +61,8 @@ void main()
     
     
     // PCF (percentage-closer filtering) algorithm:
     // PCF (percentage-closer filtering) algorithm:
     // Instead of testing if just one point is closer to the current point,
     // Instead of testing if just one point is closer to the current point,
-    // we test the surrounding points as well.
-    // This blurs shadow edges, hiding aliasing artifacts.
+    // we test the surrounding points as well
+    // This blurs shadow edges, hiding aliasing artifacts
     vec2 texelSize = vec2(1.0/float(shadowMapResolution));
     vec2 texelSize = vec2(1.0/float(shadowMapResolution));
     for (int x = -1; x <= 1; x++)
     for (int x = -1; x <= 1; x++)
     {
     {

+ 2 - 2
examples/shaders/resources/shaders/glsl120/sobel.fs

@@ -18,10 +18,10 @@ void main()
 
 
     vec4 horizEdge = vec4(0.0);
     vec4 horizEdge = vec4(0.0);
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
-    horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y    ))*2.0;
+    horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y   ))*2.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
-    horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y    ))*2.0;
+    horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y   ))*2.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
     horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
 
 
     vec4 vertEdge = vec4(0.0);
     vec4 vertEdge = vec4(0.0);

+ 4 - 4
examples/shaders/resources/shaders/glsl330/cross_stitching.fs

@@ -25,8 +25,8 @@ vec4 PostFX(sampler2D tex, vec2 uv)
 {
 {
     vec4 c = vec4(0.0);
     vec4 c = vec4(0.0);
     float size = stitchingSize;
     float size = stitchingSize;
-    vec2 cPos = uv * vec2(renderWidth, renderHeight);
-    vec2 tlPos = floor(cPos / vec2(size, size));
+    vec2 cPos = uv*vec2(renderWidth, renderHeight);
+    vec2 tlPos = floor(cPos/vec2(size, size));
     tlPos *= size;
     tlPos *= size;
 
 
     int remX = int(mod(cPos.x, size));
     int remX = int(mod(cPos.x, size));
@@ -40,11 +40,11 @@ vec4 PostFX(sampler2D tex, vec2 uv)
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
     {
     {
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
         if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
-        else c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        else c = texture(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
     }
     }
     else
     else
     {
     {
-        if (invert == 1) c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+        if (invert == 1) c = texture(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
         else c = vec4(0.0, 0.0, 0.0, 1.0);
         else c = vec4(0.0, 0.0, 0.0, 1.0);
     }
     }
 
 

+ 1 - 1
examples/shaders/resources/shaders/glsl330/cubes_panning.fs

@@ -17,7 +17,7 @@ float angle = 0.0;
 vec2 VectorRotateTime(vec2 v, float speed)
 vec2 VectorRotateTime(vec2 v, float speed)
 {
 {
     float time = uTime*speed;
     float time = uTime*speed;
-    float localTime = fract(time);  // The time domain this works on is 1 sec.
+    float localTime = fract(time);  // The time domain this works on is 1 sec
 
 
     if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
     if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
     else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4*sin(2*PI*localTime - PI/2);
     else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4*sin(2*PI*localTime - PI/2);

+ 8 - 8
examples/shaders/resources/shaders/glsl330/deferred_shading.fs

@@ -10,9 +10,9 @@ uniform sampler2D gAlbedoSpec;
 
 
 struct Light {
 struct Light {
     int enabled;
     int enabled;
-    int type; // Unused in this demo.
+    int type;       // Unused in this demo
     vec3 position;
     vec3 position;
-    vec3 target; // Unused in this demo.
+    vec3 target;    // Unused in this demo
     vec4 color;
     vec4 color;
 };
 };
 
 
@@ -29,22 +29,22 @@ void main() {
     vec3 albedo = texture(gAlbedoSpec, texCoord).rgb;
     vec3 albedo = texture(gAlbedoSpec, texCoord).rgb;
     float specular = texture(gAlbedoSpec, texCoord).a;
     float specular = texture(gAlbedoSpec, texCoord).a;
 
 
-    vec3 ambient = albedo * vec3(0.1f);
+    vec3 ambient = albedo*vec3(0.1f);
     vec3 viewDirection = normalize(viewPosition - fragPosition);
     vec3 viewDirection = normalize(viewPosition - fragPosition);
 
 
-    for(int i = 0; i < NR_LIGHTS; ++i)
+    for (int i = 0; i < NR_LIGHTS; ++i)
     {
     {
-        if(lights[i].enabled == 0) continue;
+        if (lights[i].enabled == 0) continue;
         vec3 lightDirection = lights[i].position - fragPosition;
         vec3 lightDirection = lights[i].position - fragPosition;
-        vec3 diffuse = max(dot(normal, lightDirection), 0.0) * albedo * lights[i].color.xyz;
+        vec3 diffuse = max(dot(normal, lightDirection), 0.0)*albedo*lights[i].color.xyz;
 
 
         vec3 halfwayDirection = normalize(lightDirection + viewDirection);
         vec3 halfwayDirection = normalize(lightDirection + viewDirection);
         float spec = pow(max(dot(normal, halfwayDirection), 0.0), 32.0);
         float spec = pow(max(dot(normal, halfwayDirection), 0.0), 32.0);
-        vec3 specular = specular * spec * lights[i].color.xyz;
+        vec3 specular = specular*spec*lights[i].color.xyz;
 
 
         // Attenuation
         // Attenuation
         float distance = length(lights[i].position - fragPosition);
         float distance = length(lights[i].position - fragPosition);
-        float attenuation = 1.0 / (1.0 + LINEAR * distance + QUADRATIC * distance * distance);
+        float attenuation = 1.0/(1.0 + LINEAR*distance + QUADRATIC*distance*distance);
         diffuse *= attenuation;
         diffuse *= attenuation;
         specular *= attenuation;
         specular *= attenuation;
         ambient += diffuse + specular;
         ambient += diffuse + specular;

+ 6 - 6
examples/shaders/resources/shaders/glsl330/eratosthenes.fs

@@ -5,12 +5,12 @@
   The Sieve of Eratosthenes -- a simple shader by ProfJski
   The Sieve of Eratosthenes -- a simple shader by ProfJski
   An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
   An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
 
 
-  The screen is divided into a square grid of boxes, each representing an integer value.
-  Each integer is tested to see if it is a prime number.  Primes are colored white.
-  Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer.
+  The screen is divided into a square grid of boxes, each representing an integer value
+  Each integer is tested to see if it is a prime number.  Primes are colored white
+  Non-primes are colored with a color that indicates the smallest factor which evenly divides our integer
 
 
-  You can change the scale variable to make a larger or smaller grid.
-  Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers.
+  You can change the scale variable to make a larger or smaller grid
+  Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers
 
 
   WARNING: If you make scale too large, your GPU may bog down!
   WARNING: If you make scale too large, your GPU may bog down!
 
 
@@ -39,7 +39,7 @@ vec4 Colorizer(float counter, float maxSize)
 void main()
 void main()
 {
 {
     vec4 color = vec4(1.0);
     vec4 color = vec4(1.0);
-    float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
+    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
     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)) finalColor = vec4(1.0);
     if ((value == 0) || (value == 1) || (value == 2)) finalColor = vec4(1.0);

+ 7 - 7
examples/shaders/resources/shaders/glsl330/fisheye.fs

@@ -14,22 +14,22 @@ const float PI = 3.1415926535;
 void main()
 void main()
 {
 {
     float aperture = 178.0;
     float aperture = 178.0;
-    float apertureHalf = 0.5 * aperture * (PI / 180.0);
+    float apertureHalf = 0.5*aperture*(PI/180.0);
     float maxFactor = sin(apertureHalf);
     float maxFactor = sin(apertureHalf);
 
 
     vec2 uv = vec2(0);
     vec2 uv = vec2(0);
-    vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
+    vec2 xy = 2.0*fragTexCoord.xy - 1.0;
     float d = length(xy);
     float d = length(xy);
 
 
     if (d < (2.0 - maxFactor))
     if (d < (2.0 - maxFactor))
     {
     {
-        d = length(xy * maxFactor);
-        float z = sqrt(1.0 - d * d);
-        float r = atan(d, z) / PI;
+        d = length(xy*maxFactor);
+        float z = sqrt(1.0 - d*d);
+        float r = atan(d, z)/PI;
         float phi = atan(xy.y, xy.x);
         float phi = atan(xy.y, xy.x);
 
 
-        uv.x = r * cos(phi) + 0.5;
-        uv.y = r * sin(phi) + 0.5;
+        uv.x = r*cos(phi) + 0.5;
+        uv.y = r*sin(phi) + 0.5;
     }
     }
     else
     else
     {
     {

+ 3 - 3
examples/shaders/resources/shaders/glsl330/gbuffer.vs

@@ -13,12 +13,12 @@ uniform mat4 matProjection;
 
 
 void main()
 void main()
 {
 {
-    vec4 worldPos = matModel * vec4(vertexPosition, 1.0);
+    vec4 worldPos = matModel*vec4(vertexPosition, 1.0);
     fragPosition = worldPos.xyz; 
     fragPosition = worldPos.xyz; 
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
 
 
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
-    fragNormal = normalMatrix * vertexNormal;
+    fragNormal = normalMatrix*vertexNormal;
 
 
-    gl_Position = matProjection * matView * worldPos;
+    gl_Position = matProjection*matView*worldPos;
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl330/hybrid_raster.fs

@@ -18,5 +18,5 @@ void main()
     vec4 texelColor = texture(texture0, fragTexCoord);
     vec4 texelColor = texture(texture0, fragTexCoord);
     
     
     gl_FragColor = texelColor*colDiffuse*fragColor;
     gl_FragColor = texelColor*colDiffuse*fragColor;
-	gl_FragDepth = gl_FragCoord.z;
+    gl_FragDepth = gl_FragCoord.z;
 }
 }

+ 79 - 79
examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs

@@ -22,14 +22,14 @@ float CalcDepth(in vec3 rd, in float Idist){
 }
 }
 
 
 // https://iquilezles.org/articles/distfunctions/
 // https://iquilezles.org/articles/distfunctions/
-float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
+float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w)
 {
 {
     p.x = abs(p.x);
     p.x = abs(p.x);
     float l = length(p.xy);
     float l = length(p.xy);
     p.xy = mat2(-c.x, c.y, 
     p.xy = mat2(-c.x, c.y, 
               c.y, c.x)*p.xy;
               c.y, c.x)*p.xy;
     p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
     p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
-                (p.x>0.0)?p.y:l );
+                (p.x>0.0)?p.y:l);
     p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
     p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
     
     
     vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
     vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
@@ -40,48 +40,48 @@ float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
 // r = sphere's radius
 // r = sphere's radius
 // h = cutting's plane's position
 // h = cutting's plane's position
 // t = thickness
 // t = thickness
-float sdSixWayCutHollowSphere( vec3 p, float r, float h, float t )
+float sdSixWayCutHollowSphere(vec3 p, float r, float h, float t)
 {
 {
     // Six way symetry Transformation
     // Six way symetry Transformation
     vec3 ap = abs(p);
     vec3 ap = abs(p);
-    if(ap.x < max(ap.y, ap.z)){
-        if(ap.y < ap.z) ap.xz = ap.zx;
+    if (ap.x < max(ap.y, ap.z)){
+        if (ap.y < ap.z) ap.xz = ap.zx;
         else ap.xy = ap.yx;
         else ap.xy = ap.yx;
     }
     }
 
 
-    vec2 q = vec2( length(ap.yz), ap.x );
+    vec2 q = vec2(length(ap.yz), ap.x);
     
     
     float w = sqrt(r*r-h*h);
     float w = sqrt(r*r-h*h);
     
     
     return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : 
     return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : 
-                            abs(length(q)-r) ) - t;
+                            abs(length(q)-r)) - t;
 }
 }
 
 
 // https://iquilezles.org/articles/boxfunctions
 // https://iquilezles.org/articles/boxfunctions
-vec2 iBox( in vec3 ro, in vec3 rd, in vec3 rad ) 
+vec2 iBox(in vec3 ro, in vec3 rd, in vec3 rad) 
 {
 {
     vec3 m = 1.0/rd;
     vec3 m = 1.0/rd;
     vec3 n = m*ro;
     vec3 n = m*ro;
     vec3 k = abs(m)*rad;
     vec3 k = abs(m)*rad;
     vec3 t1 = -n - k;
     vec3 t1 = -n - k;
     vec3 t2 = -n + k;
     vec3 t2 = -n + k;
-	return vec2( max( max( t1.x, t1.y ), t1.z ),
-	             min( min( t2.x, t2.y ), t2.z ) );
+    return vec2(max(max(t1.x, t1.y), t1.z),
+                 min(min(t2.x, t2.y), t2.z));
 }
 }
 
 
-vec2 opU( vec2 d1, vec2 d2 )
+vec2 opU(vec2 d1, vec2 d2)
 {
 {
-	return (d1.x<d2.x) ? d1 : d2;
+    return (d1.x<d2.x) ? d1 : d2;
 }
 }
 
 
-vec2 map( in vec3 pos ){
-    vec2 res = vec2( sdHorseshoe(  pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5) ), 11.5 ) ;
-    res = opU(res, vec2( sdSixWayCutHollowSphere(  pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5 ), 4.5 )) ;
+vec2 map(in vec3 pos){
+    vec2 res = vec2(sdHorseshoe( pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5)), 11.5) ;
+    res = opU(res, vec2(sdSixWayCutHollowSphere( pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5), 4.5)) ;
     return res;
     return res;
 }
 }
 
 
 // https://www.shadertoy.com/view/Xds3zN
 // https://www.shadertoy.com/view/Xds3zN
-vec2 raycast( in vec3 ro, in vec3 rd ){
+vec2 raycast(in vec3 ro, in vec3 rd){
     vec2 res = vec2(-1.0,-1.0);
     vec2 res = vec2(-1.0,-1.0);
 
 
     float tmin = 1.0;
     float tmin = 1.0;
@@ -89,18 +89,18 @@ vec2 raycast( in vec3 ro, in vec3 rd ){
 
 
     // raytrace floor plane
     // raytrace floor plane
     float tp1 = (-ro.y)/rd.y;
     float tp1 = (-ro.y)/rd.y;
-    if( tp1>0.0 )
+    if (tp1>0.0)
     {
     {
-        tmax = min( tmax, tp1 );
-        res = vec2( tp1, 1.0 );
+        tmax = min(tmax, tp1);
+        res = vec2(tp1, 1.0);
     }
     }
 
 
     float t = tmin;
     float t = tmin;
-    for( int i=0; i<70 ; i++ )
+    for (int i=0; i<70 ; i++)
     {
     {
-        if(t>tmax) break;
-        vec2 h = map( ro+rd*t );
-        if( abs(h.x)<(0.0001*t) )
+        if (t>tmax) break;
+        vec2 h = map(ro+rd*t);
+        if (abs(h.x)<(0.0001*t))
         { 
         { 
             res = vec2(t,h.y); 
             res = vec2(t,h.y); 
             break;
             break;
@@ -113,54 +113,54 @@ vec2 raycast( in vec3 ro, in vec3 rd ){
 
 
 
 
 // https://iquilezles.org/articles/rmshadows
 // https://iquilezles.org/articles/rmshadows
-float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
 {
 {
     // bounding volume
     // bounding volume
-    float tp = (0.8-ro.y)/rd.y; if( tp>0.0 ) tmax = min( tmax, tp );
+    float tp = (0.8-ro.y)/rd.y; if (tp>0.0) tmax = min(tmax, tp);
 
 
     float res = 1.0;
     float res = 1.0;
     float t = mint;
     float t = mint;
-    for( int i=ZERO; i<24; i++ )
+    for (int i=ZERO; i<24; i++)
     {
     {
-		float h = map( ro + rd*t ).x;
+        float h = map(ro + rd*t).x;
         float s = clamp(8.0*h/t,0.0,1.0);
         float s = clamp(8.0*h/t,0.0,1.0);
-        res = min( res, s );
-        t += clamp( h, 0.01, 0.2 );
-        if( res<0.004 || t>tmax ) break;
+        res = min(res, s);
+        t += clamp(h, 0.01, 0.2);
+        if (res<0.004 || t>tmax) break;
     }
     }
-    res = clamp( res, 0.0, 1.0 );
+    res = clamp(res, 0.0, 1.0);
     return res*res*(3.0-2.0*res);
     return res*res*(3.0-2.0*res);
 }
 }
 
 
 
 
 // https://iquilezles.org/articles/normalsSDF
 // https://iquilezles.org/articles/normalsSDF
-vec3 calcNormal( in vec3 pos )
+vec3 calcNormal(in vec3 pos)
 {
 {
-    vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
-    return normalize( e.xyy*map( pos + e.xyy ).x + 
-					  e.yyx*map( pos + e.yyx ).x + 
-					  e.yxy*map( pos + e.yxy ).x + 
-					  e.xxx*map( pos + e.xxx ).x );
+    vec2 e = vec2(1.0, -1.0)*0.5773*0.0005;
+    return normalize(e.xyy*map(pos + e.xyy).x + 
+                     e.yyx*map(pos + e.yyx).x + 
+                     e.yxy*map(pos + e.yxy).x + 
+                     e.xxx*map(pos + e.xxx).x);
 }
 }
 
 
 // https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
 // https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
-float calcAO( in vec3 pos, in vec3 nor )
+float calcAO(in vec3 pos, in vec3 nor)
 {
 {
-	float occ = 0.0;
+    float occ = 0.0;
     float sca = 1.0;
     float sca = 1.0;
-    for( int i=ZERO; i<5; i++ )
+    for (int i=ZERO; i<5; i++)
     {
     {
         float h = 0.01 + 0.12*float(i)/4.0;
         float h = 0.01 + 0.12*float(i)/4.0;
-        float d = map( pos + h*nor ).x;
+        float d = map(pos + h*nor).x;
         occ += (h-d)*sca;
         occ += (h-d)*sca;
         sca *= 0.95;
         sca *= 0.95;
-        if( occ>0.35 ) break;
+        if (occ>0.35) break;
     }
     }
-    return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ) * (0.5+0.5*nor.y);
+    return clamp(1.0 - 3.0*occ, 0.0, 1.0)*(0.5+0.5*nor.y);
 }
 }
 
 
 // https://iquilezles.org/articles/checkerfiltering
 // https://iquilezles.org/articles/checkerfiltering
-float checkersGradBox( in vec2 p )
+float checkersGradBox(in vec2 p)
 {
 {
     // filter kernel
     // filter kernel
     vec2 w = fwidth(p) + 0.001;
     vec2 w = fwidth(p) + 0.001;
@@ -171,7 +171,7 @@ float checkersGradBox( in vec2 p )
 }
 }
 
 
 // https://www.shadertoy.com/view/tdS3DG
 // https://www.shadertoy.com/view/tdS3DG
-vec4 render( in vec3 ro, in vec3 rd)
+vec4 render(in vec3 ro, in vec3 rd)
 { 
 { 
     // background
     // background
     vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
     vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
@@ -179,37 +179,37 @@ vec4 render( in vec3 ro, in vec3 rd)
     // raycast scene
     // raycast scene
     vec2 res = raycast(ro,rd);
     vec2 res = raycast(ro,rd);
     float t = res.x;
     float t = res.x;
-	float m = res.y;
-    if( m>-0.5 )
+    float m = res.y;
+    if (m>-0.5)
     {
     {
         vec3 pos = ro + t*rd;
         vec3 pos = ro + t*rd;
-        vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal( pos );
-        vec3 ref = reflect( rd, nor );
+        vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
+        vec3 ref = reflect(rd, nor);
         
         
         // material        
         // material        
-        col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
+        col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
         float ks = 1.0;
         float ks = 1.0;
         
         
-        if( m<1.5 )
+        if (m<1.5)
         {
         {
-            float f = checkersGradBox( 3.0*pos.xz);
+            float f = checkersGradBox(3.0*pos.xz);
             col = 0.15 + f*vec3(0.05);
             col = 0.15 + f*vec3(0.05);
             ks = 0.4;
             ks = 0.4;
         }
         }
 
 
         // lighting
         // lighting
-        float occ = calcAO( pos, nor );
+        float occ = calcAO(pos, nor);
         
         
-		vec3 lin = vec3(0.0);
+        vec3 lin = vec3(0.0);
 
 
         // sun
         // sun
         {
         {
-            vec3  lig = normalize( vec3(-0.5, 0.4, -0.6) );
-            vec3  hal = normalize( lig-rd );
-            float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
-          //if( dif>0.0001 )
-        	      dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
-			float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
+            vec3  lig = normalize(vec3(-0.5, 0.4, -0.6));
+            vec3  hal = normalize(lig-rd);
+            float dif = clamp(dot(nor, lig), 0.0, 1.0);
+          //if (dif>0.0001)
+                  dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
+            float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0);
                   spe *= dif;
                   spe *= dif;
                   spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
                   spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
                 //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
                 //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
@@ -218,35 +218,35 @@ vec4 render( in vec3 ro, in vec3 rd)
         }
         }
         // sky
         // sky
         {
         {
-            float dif = sqrt(clamp( 0.5+0.5*nor.y, 0.0, 1.0 ));
+            float dif = sqrt(clamp(0.5+0.5*nor.y, 0.0, 1.0));
                   dif *= occ;
                   dif *= occ;
-            float spe = smoothstep( -0.2, 0.2, ref.y );
+            float spe = smoothstep(-0.2, 0.2, ref.y);
                   spe *= dif;
                   spe *= dif;
-                  spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0 );
-          //if( spe>0.001 )
-                  spe *= calcSoftshadow( pos, ref, 0.02, 2.5 );
+                  spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0);
+          //if (spe>0.001)
+                  spe *= calcSoftshadow(pos, ref, 0.02, 2.5);
             lin += col*0.60*dif*vec3(0.40,0.60,1.15);
             lin += col*0.60*dif*vec3(0.40,0.60,1.15);
             lin +=     2.00*spe*vec3(0.40,0.60,1.30)*ks;
             lin +=     2.00*spe*vec3(0.40,0.60,1.30)*ks;
         }
         }
         // back
         // back
         {
         {
-        	float dif = clamp( dot( nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
+            float dif = clamp(dot(nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
                   dif *= occ;
                   dif *= occ;
-        	lin += col*0.55*dif*vec3(0.25,0.25,0.25);
+            lin += col*0.55*dif*vec3(0.25,0.25,0.25);
         }
         }
         // sss
         // sss
         {
         {
             float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
             float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
                   dif *= occ;
                   dif *= occ;
-        	lin += col*0.25*dif*vec3(1.00,1.00,1.00);
+            lin += col*0.25*dif*vec3(1.00,1.00,1.00);
         }
         }
         
         
-		col = lin;
+        col = lin;
 
 
-        col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
+        col = mix(col, vec3(0.7,0.7,0.9), 1.0-exp(-0.0001*t*t*t));
     }
     }
 
 
-	return vec4(vec3( clamp(col,0.0,1.0) ),t);
+    return vec4(vec3(clamp(col,0.0,1.0)),t);
 }
 }
 
 
 vec3 CalcRayDir(vec2 nCoord){
 vec3 CalcRayDir(vec2 nCoord){
@@ -257,11 +257,11 @@ vec3 CalcRayDir(vec2 nCoord){
 
 
 mat3 setCamera()
 mat3 setCamera()
 {
 {
-	vec3 cw = normalize(camDir);
-	vec3 cp = vec3(0.0, 1.0 ,0.0);
-	vec3 cu = normalize( cross(cw,cp) );
-	vec3 cv =          ( cross(cu,cw) );
-    return mat3( cu, cv, cw );
+    vec3 cw = normalize(camDir);
+    vec3 cp = vec3(0.0, 1.0 ,0.0);
+    vec3 cu = normalize(cross(cw,cp));
+    vec3 cv =          (cross(cu,cw));
+    return mat3(cu, cv, cw);
 }
 }
 
 
 void main()
 void main()
@@ -271,14 +271,14 @@ void main()
 
 
     // focal length
     // focal length
     float fl = length(camDir);
     float fl = length(camDir);
-    vec3 rd = ca * normalize( vec3(nCoord,fl) );
+    vec3 rd = ca*normalize(vec3(nCoord,fl));
     vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
     vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
     float depth = gl_FragCoord.z;
     float depth = gl_FragCoord.z;
     {
     {
-        vec4 res = render( camPos - vec3(0.0, 0.0, 0.0) , rd );
+        vec4 res = render(camPos - vec3(0.0, 0.0, 0.0) , rd);
         color = res.xyz;
         color = res.xyz;
         depth = CalcDepth(rd,res.w);
         depth = CalcDepth(rd,res.w);
     }
     }
     gl_FragColor = vec4(color , 1.0);
     gl_FragColor = vec4(color , 1.0);
-	gl_FragDepth = depth;
+    gl_FragDepth = depth;
 }
 }

+ 20 - 20
examples/shaders/resources/shaders/glsl330/julia_set.fs

@@ -8,11 +8,11 @@ in vec4 fragColor;
 out vec4 finalColor;
 out vec4 finalColor;
 
 
 uniform vec2 c;                 // c.x = real, c.y = imaginary component. Equation done is z^2 + c
 uniform vec2 c;                 // c.x = real, c.y = imaginary component. Equation done is z^2 + c
-uniform vec2 offset;            // Offset of the scale.
-uniform float zoom;             // Zoom of the scale.
+uniform vec2 offset;            // Offset of the scale
+uniform float zoom;             // Zoom of the scale
 
 
-const int maxIterations = 255;     // Max iterations to do.
-const float colorCycles = 2.0;    // Number of times the color palette repeats. Can show higher detail for higher iteration numbers.
+const int maxIterations = 255;  // Max iterations to do
+const float colorCycles = 2.0;  // Number of times the color palette repeats. Can show higher detail for higher iteration numbers
 
 
 // Square a complex number
 // Square a complex number
 vec2 ComplexSquare(vec2 z)
 vec2 ComplexSquare(vec2 z)
@@ -31,22 +31,22 @@ vec3 Hsv2rgb(vec3 c)
 void main()
 void main()
 {
 {
     /**********************************************************************************************
     /**********************************************************************************************
-      Julia sets use a function z^2 + c, where c is a constant.
-      This function is iterated until the nature of the point is determined.
+      Julia sets use a function z^2 + c, where c is a constant
+      This function is iterated until the nature of the point is determined
 
 
       If the magnitude of the number becomes greater than 2, then from that point onward
       If the magnitude of the number becomes greater than 2, then from that point onward
-      the number will get bigger and bigger, and will never get smaller (tends towards infinity).
-      2^2 = 4, 4^2 = 8 and so on.
-      So at 2 we stop iterating.
+      the number will get bigger and bigger, and will never get smaller (tends towards infinity)
+      2^2 = 4, 4^2 = 8 and so on
+      So at 2 we stop iterating
 
 
-      If the number is below 2, we keep iterating.
+      If the number is below 2, we keep iterating
       But when do we stop iterating if the number is always below 2 (it converges)?
       But when do we stop iterating if the number is always below 2 (it converges)?
-      That is what maxIterations is for.
-      Then we can divide the iterations by the maxIterations value to get a normalized value that we can
-      then map to a color.
+      That is what maxIterations is for
+      Then we can divide the iterations by the maxIterations value to get a normalized value
+      that we can then map to a color
 
 
-      We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
-      And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power).
+      We use dot product (z.x*z.x + z.y*z.y) to determine the magnitude (length) squared
+      And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power)
     *************************************************************************************************/
     *************************************************************************************************/
 
 
     // The pixel coordinates are scaled so they are on the mandelbrot scale
     // The pixel coordinates are scaled so they are on the mandelbrot scale
@@ -63,18 +63,18 @@ void main()
         if (dot(z, z) > 4.0) break;
         if (dot(z, z) > 4.0) break;
     }
     }
 
 
-    // Another few iterations decreases errors in the smoothing calculation.
-    // See http://linas.org/art-gallery/escape/escape.html for more information.
+    // Another few iterations decreases errors in the smoothing calculation
+    // See http://linas.org/art-gallery/escape/escape.html for more information
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
     z = ComplexSquare(z) + c;
 
 
-    // This last part smooths the color (again see link above).
+    // This last part smooths the color (again see link above)
     float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0));
     float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0));
 
 
-    // Normalize the value so it is between 0 and 1.
+    // Normalize the value so it is between 0 and 1
     float norm = smoothVal/float(maxIterations);
     float norm = smoothVal/float(maxIterations);
 
 
-    // If in set, color black. 0.999 allows for some float accuracy error.
+    // If in set, color black. 0.999 allows for some float accuracy error
     if (norm > 0.999) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
     if (norm > 0.999) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
     else finalColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0, 1.0)), 1.0);
     else finalColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0, 1.0)), 1.0);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl330/lighting.fs

@@ -41,7 +41,7 @@ void main()
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 viewD = normalize(viewPos - fragPosition);
     vec3 specular = vec3(0.0);
     vec3 specular = vec3(0.0);
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     // NOTE: Implement here your fragment shader code
     // NOTE: Implement here your fragment shader code
 
 

+ 1 - 1
examples/shaders/resources/shaders/glsl330/lightmap.fs

@@ -19,5 +19,5 @@ void main()
     vec4 texelColor = texture(texture0, fragTexCoord);
     vec4 texelColor = texture(texture0, fragTexCoord);
     vec4 texelColor2 = texture(texture1, fragTexCoord2);
     vec4 texelColor2 = texture(texture1, fragTexCoord2);
 
 
-    finalColor = texelColor * texelColor2;
+    finalColor = texelColor*texelColor2;
 }
 }

+ 7 - 7
examples/shaders/resources/shaders/glsl330/normalmap.fs

@@ -36,21 +36,21 @@ void main()
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
         normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
 
 
         //Transform normal values to the range -1.0 ... 1.0
         //Transform normal values to the range -1.0 ... 1.0
-        normal = normalize(normal * 2.0 - 1.0);
+        normal = normalize(normal*2.0 - 1.0);
 
 
         //Transform the normal from tangent-space to world-space for lighting calculation
         //Transform the normal from tangent-space to world-space for lighting calculation
-        normal = normalize(normal * TBN);
+        normal = normalize(normal*TBN);
     }
     }
     else
     else
     {
     {
         normal = normalize(fragNormal);
         normal = normalize(fragNormal);
     }
     }
 
 
-    vec4 tint = colDiffuse * fragColor;
+    vec4 tint = colDiffuse*fragColor;
 
 
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     vec3 lightColor = vec3(1.0, 1.0, 1.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
     float NdotL = max(dot(normal, lightDir), 0.0);
-    vec3 lightDot = lightColor * NdotL;
+    vec3 lightDot = lightColor*NdotL;
 
 
     float specCo = 0.0;
     float specCo = 0.0;
 
 
@@ -58,10 +58,10 @@ void main()
 
 
     specular += specCo;
     specular += specCo;
 
 
-    finalColor = (texelColor * ((tint + vec4(specular, 1.0)) * vec4(lightDot, 1.0)));
-    finalColor += texelColor * (vec4(1.0, 1.0, 1.0, 1.0) / 40.0) * tint;
+    finalColor = (texelColor*((tint + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
+    finalColor += texelColor*(vec4(1.0, 1.0, 1.0, 1.0)/40.0)*tint;
 
 
     // Gamma correction
     // Gamma correction
-    finalColor = pow(finalColor, vec4(1.0 / 2.2));
+    finalColor = pow(finalColor, vec4(1.0/2.2));
     //finalColor = vec4(normal, 1.0);
     //finalColor = vec4(normal, 1.0);
 }
 }

+ 7 - 7
examples/shaders/resources/shaders/glsl330/normalmap.vs

@@ -21,21 +21,21 @@ out mat3 TBN;
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
     // Compute binormal from vertex normal and tangent. W component is the tangent handedness
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
 
 
     // Compute fragment position based on model transformations
     // Compute fragment position based on model transformations
-    fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
+    fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
 
 
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
     //Create TBN matrix for transforming the normal map values from tangent-space to world-space
-    fragNormal = normalize(normalMatrix * vertexNormal);
+    fragNormal = normalize(normalMatrix*vertexNormal);
 
 
-    vec3 fragTangent = normalize(normalMatrix * vertexTangent.xyz);
-    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal) * fragNormal);
+    vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
+    fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
 
 
-    vec3 fragBinormal = normalize(normalMatrix * vertexBinormal);
+    vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
     fragBinormal = cross(fragNormal, fragTangent);
     fragBinormal = cross(fragNormal, fragTangent);
 
 
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
     TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
@@ -44,5 +44,5 @@ void main()
 
 
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
 
 
-    gl_Position = mvp * vec4(vertexPosition, 1.0);
+    gl_Position = mvp*vec4(vertexPosition, 1.0);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl330/pbr.vs

@@ -26,7 +26,7 @@ const float normalOffset = 0.1;
 void main()
 void main()
 {
 {
     // Compute binormal from vertex normal and tangent
     // Compute binormal from vertex normal and tangent
-    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
+    vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
 
 
     // Compute fragment normal based on normal transformations
     // Compute fragment normal based on normal transformations
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));
     mat3 normalMatrix = transpose(inverse(mat3(matModel)));

+ 132 - 132
examples/shaders/resources/shaders/glsl330/raymarching.fs

@@ -33,7 +33,7 @@ uniform vec2 resolution;
 // SOFTWARE.
 // SOFTWARE.
 
 
 // A list of useful distance function to simple primitives, and an example on how to
 // A list of useful distance function to simple primitives, and an example on how to
-// do some interesting boolean operations, repetition and displacement.
+// do some interesting boolean operations, repetition and displacement
 //
 //
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 // More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
 
 
@@ -41,38 +41,38 @@ uniform vec2 resolution;
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float sdPlane( vec3 p )
+float sdPlane(vec3 p)
 {
 {
     return p.y;
     return p.y;
 }
 }
 
 
-float sdSphere( vec3 p, float s )
+float sdSphere(vec3 p, float s)
 {
 {
     return length(p)-s;
     return length(p)-s;
 }
 }
 
 
-float sdBox( vec3 p, vec3 b )
+float sdBox(vec3 p, vec3 b)
 {
 {
     vec3 d = abs(p) - b;
     vec3 d = abs(p) - b;
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
     return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdEllipsoid( in vec3 p, in vec3 r )
+float sdEllipsoid(in vec3 p, in vec3 r)
 {
 {
-    return (length( p/r ) - 1.0) * min(min(r.x,r.y),r.z);
+    return (length(p/r) - 1.0)*min(min(r.x,r.y),r.z);
 }
 }
 
 
-float udRoundBox( vec3 p, vec3 b, float r )
+float udRoundBox(vec3 p, vec3 b, float r)
 {
 {
     return length(max(abs(p)-b,0.0))-r;
     return length(max(abs(p)-b,0.0))-r;
 }
 }
 
 
-float sdTorus( vec3 p, vec2 t )
+float sdTorus(vec3 p, vec2 t)
 {
 {
-    return length( vec2(length(p.xz)-t.x,p.y) )-t.y;
+    return length(vec2(length(p.xz)-t.x,p.y))-t.y;
 }
 }
 
 
-float sdHexPrism( vec3 p, vec2 h )
+float sdHexPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
 #if 0
 #if 0
@@ -84,24 +84,24 @@ float sdHexPrism( vec3 p, vec2 h )
 #endif
 #endif
 }
 }
 
 
-float sdCapsule( vec3 p, vec3 a, vec3 b, float r )
+float sdCapsule(vec3 p, vec3 a, vec3 b, float r)
 {
 {
     vec3 pa = p-a, ba = b-a;
     vec3 pa = p-a, ba = b-a;
-    float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
-    return length( pa - ba*h ) - r;
+    float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);
+    return length(pa - ba*h) - r;
 }
 }
 
 
-float sdEquilateralTriangle(  in vec2 p )
+float sdEquilateralTriangle( in vec2 p)
 {
 {
     const float k = sqrt(3.0);
     const float k = sqrt(3.0);
     p.x = abs(p.x) - 1.0;
     p.x = abs(p.x) - 1.0;
     p.y = p.y + 1.0/k;
     p.y = p.y + 1.0/k;
-    if( p.x + k*p.y > 0.0 ) p = vec2( p.x - k*p.y, -k*p.x - p.y )/2.0;
-    p.x += 2.0 - 2.0*clamp( (p.x+2.0)/2.0, 0.0, 1.0 );
+    if (p.x + k*p.y > 0.0) p = vec2(p.x - k*p.y, -k*p.x - p.y)/2.0;
+    p.x += 2.0 - 2.0*clamp((p.x+2.0)/2.0, 0.0, 1.0);
     return -length(p)*sign(p.y);
     return -length(p)*sign(p.y);
 }
 }
 
 
-float sdTriPrism( vec3 p, vec2 h )
+float sdTriPrism(vec3 p, vec2 h)
 {
 {
     vec3 q = abs(p);
     vec3 q = abs(p);
     float d1 = q.z-h.y;
     float d1 = q.z-h.y;
@@ -116,95 +116,95 @@ float sdTriPrism( vec3 p, vec2 h )
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdCylinder( vec3 p, vec2 h )
+float sdCylinder(vec3 p, vec2 h)
 {
 {
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   vec2 d = abs(vec2(length(p.xz),p.y)) - h;
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
   return min(max(d.x,d.y),0.0) + length(max(d,0.0));
 }
 }
 
 
-float sdCone( in vec3 p, in vec3 c )
+float sdCone(in vec3 p, in vec3 c)
 {
 {
-    vec2 q = vec2( length(p.xz), p.y );
+    vec2 q = vec2(length(p.xz), p.y);
     float d1 = -q.y-c.z;
     float d1 = -q.y-c.z;
-    float d2 = max( dot(q,c.xy), q.y);
+    float d2 = max(dot(q,c.xy), q.y);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdConeSection( in vec3 p, in float h, in float r1, in float r2 )
+float sdConeSection(in vec3 p, in float h, in float r1, in float r2)
 {
 {
     float d1 = -p.y - h;
     float d1 = -p.y - h;
     float q = p.y - h;
     float q = p.y - h;
     float si = 0.5*(r1-r2)/h;
     float si = 0.5*(r1-r2)/h;
-    float d2 = max( sqrt( dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q );
+    float d2 = max(sqrt(dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
     return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
 }
 }
 
 
-float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height }
+float sdPryamid4(vec3 p, vec3 h) // h = { cos a, sin a, height }
 {
 {
     // Tetrahedron = Octahedron - Cube
     // Tetrahedron = Octahedron - Cube
-    float box = sdBox( p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z) );
+    float box = sdBox(p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z));
 
 
     float d = 0.0;
     float d = 0.0;
-    d = max( d, abs( dot(p, vec3( -h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  h.x, h.y, 0 )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y, h.x )) ));
-    d = max( d, abs( dot(p, vec3(  0, h.y,-h.x )) ));
+    d = max(d, abs(dot(p, vec3(-h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( h.x, h.y, 0))));
+    d = max(d, abs(dot(p, vec3( 0, h.y, h.x))));
+    d = max(d, abs(dot(p, vec3( 0, h.y,-h.x))));
     float octa = d - h.z;
     float octa = d - h.z;
     return max(-box,octa); // Subtraction
     return max(-box,octa); // Subtraction
  }
  }
 
 
-float length2( vec2 p )
+float length2(vec2 p)
 {
 {
-    return sqrt( p.x*p.x + p.y*p.y );
+    return sqrt(p.x*p.x + p.y*p.y);
 }
 }
 
 
-float length6( vec2 p )
+float length6(vec2 p)
 {
 {
     p = p*p*p; p = p*p;
     p = p*p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/6.0 );
+    return pow(p.x + p.y, 1.0/6.0);
 }
 }
 
 
-float length8( vec2 p )
+float length8(vec2 p)
 {
 {
     p = p*p; p = p*p; p = p*p;
     p = p*p; p = p*p; p = p*p;
-    return pow( p.x + p.y, 1.0/8.0 );
+    return pow(p.x + p.y, 1.0/8.0);
 }
 }
 
 
-float sdTorus82( vec3 p, vec2 t )
+float sdTorus82(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     vec2 q = vec2(length2(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdTorus88( vec3 p, vec2 t )
+float sdTorus88(vec3 p, vec2 t)
 {
 {
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     vec2 q = vec2(length8(p.xz)-t.x,p.y);
     return length8(q)-t.y;
     return length8(q)-t.y;
 }
 }
 
 
-float sdCylinder6( vec3 p, vec2 h )
+float sdCylinder6(vec3 p, vec2 h)
 {
 {
-    return max( length6(p.xz)-h.x, abs(p.y)-h.y );
+    return max(length6(p.xz)-h.x, abs(p.y)-h.y);
 }
 }
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-float opS( float d1, float d2 )
+float opS(float d1, float d2)
 {
 {
     return max(-d2,d1);
     return max(-d2,d1);
 }
 }
 
 
-vec2 opU( vec2 d1, vec2 d2 )
+vec2 opU(vec2 d1, vec2 d2)
 {
 {
     return (d1.x<d2.x) ? d1 : d2;
     return (d1.x<d2.x) ? d1 : d2;
 }
 }
 
 
-vec3 opRep( vec3 p, vec3 c )
+vec3 opRep(vec3 p, vec3 c)
 {
 {
     return mod(p,c)-0.5*c;
     return mod(p,c)-0.5*c;
 }
 }
 
 
-vec3 opTwist( vec3 p )
+vec3 opTwist(vec3 p)
 {
 {
     float  c = cos(10.0*p.y+10.0);
     float  c = cos(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
     float  s = sin(10.0*p.y+10.0);
@@ -214,110 +214,110 @@ vec3 opTwist( vec3 p )
 
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------
 
 
-vec2 map( in vec3 pos )
-{
-    vec2 res = opU( vec2( sdPlane(     pos), 1.0 ),
-                    vec2( sdSphere(    pos-vec3( 0.0,0.25, 0.0), 0.25 ), 46.9 ) );
-    res = opU( res, vec2( sdBox(       pos-vec3( 1.0,0.25, 0.0), vec3(0.25) ), 3.0 ) );
-    res = opU( res, vec2( udRoundBox(  pos-vec3( 1.0,0.25, 1.0), vec3(0.15), 0.1 ), 41.0 ) );
-    res = opU( res, vec2( sdTorus(     pos-vec3( 0.0,0.25, 1.0), vec2(0.20,0.05) ), 25.0 ) );
-    res = opU( res, vec2( sdCapsule(   pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1  ), 31.9 ) );
-    res = opU( res, vec2( sdTriPrism(  pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05) ),43.5 ) );
-    res = opU( res, vec2( sdCylinder(  pos-vec3( 1.0,0.30,-1.0), vec2(0.1,0.2) ), 8.0 ) );
-    res = opU( res, vec2( sdCone(      pos-vec3( 0.0,0.50,-1.0), vec3(0.8,0.6,0.3) ), 55.0 ) );
-    res = opU( res, vec2( sdTorus82(   pos-vec3( 0.0,0.25, 2.0), vec2(0.20,0.05) ),50.0 ) );
-    res = opU( res, vec2( sdTorus88(   pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05) ),43.0 ) );
-    res = opU( res, vec2( sdCylinder6( pos-vec3( 1.0,0.30, 2.0), vec2(0.1,0.2) ), 12.0 ) );
-    res = opU( res, vec2( sdHexPrism(  pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05) ),17.0 ) );
-    res = opU( res, vec2( sdPryamid4(  pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25) ),37.0 ) );
-    res = opU( res, vec2( opS( udRoundBox(  pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
-                               sdSphere(    pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0 ) );
-    res = opU( res, vec2( opS( sdTorus82(  pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
-                               sdCylinder(  opRep( vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0 ) );
-    res = opU( res, vec2( 0.5*sdSphere(    pos-vec3(-2.0,0.25,-1.0), 0.2 ) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0 ) );
-    res = opU( res, vec2( 0.5*sdTorus( opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7 ) );
-    res = opU( res, vec2( sdConeSection( pos-vec3( 0.0,0.35,-2.0), 0.15, 0.2, 0.1 ), 13.67 ) );
-    res = opU( res, vec2( sdEllipsoid( pos-vec3( 1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05) ), 43.17 ) );
+vec2 map(in vec3 pos)
+{
+    vec2 res = opU(vec2(sdPlane(    pos), 1.0),
+                    vec2(sdSphere(   pos-vec3(0.0,0.25, 0.0), 0.25), 46.9));
+    res = opU(res, vec2(sdBox(      pos-vec3(1.0,0.25, 0.0), vec3(0.25)), 3.0));
+    res = opU(res, vec2(udRoundBox( pos-vec3(1.0,0.25, 1.0), vec3(0.15), 0.1), 41.0));
+    res = opU(res, vec2(sdTorus(    pos-vec3(0.0,0.25, 1.0), vec2(0.20,0.05)), 25.0));
+    res = opU(res, vec2(sdCapsule(  pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1 ), 31.9));
+    res = opU(res, vec2(sdTriPrism( pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05)),43.5));
+    res = opU(res, vec2(sdCylinder( pos-vec3(1.0,0.30,-1.0), vec2(0.1,0.2)), 8.0));
+    res = opU(res, vec2(sdCone(     pos-vec3(0.0,0.50,-1.0), vec3(0.8,0.6,0.3)), 55.0));
+    res = opU(res, vec2(sdTorus82(  pos-vec3(0.0,0.25, 2.0), vec2(0.20,0.05)),50.0));
+    res = opU(res, vec2(sdTorus88(  pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05)),43.0));
+    res = opU(res, vec2(sdCylinder6(pos-vec3(1.0,0.30, 2.0), vec2(0.1,0.2)), 12.0));
+    res = opU(res, vec2(sdHexPrism( pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05)),17.0));
+    res = opU(res, vec2(sdPryamid4( pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25)),37.0));
+    res = opU(res, vec2(opS(udRoundBox( pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
+                               sdSphere(   pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0));
+    res = opU(res, vec2(opS(sdTorus82( pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
+                               sdCylinder( opRep(vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0));
+    res = opU(res, vec2(0.5*sdSphere(   pos-vec3(-2.0,0.25,-1.0), 0.2) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0));
+    res = opU(res, vec2(0.5*sdTorus(opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7));
+    res = opU(res, vec2(sdConeSection(pos-vec3(0.0,0.35,-2.0), 0.15, 0.2, 0.1), 13.67));
+    res = opU(res, vec2(sdEllipsoid(pos-vec3(1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05)), 43.17));
 
 
     return res;
     return res;
 }
 }
 
 
-vec2 castRay( in vec3 ro, in vec3 rd )
+vec2 castRay(in vec3 ro, in vec3 rd)
 {
 {
     float tmin = 0.2;
     float tmin = 0.2;
     float tmax = 30.0;
     float tmax = 30.0;
 
 
 #if 1
 #if 1
     // bounding volume
     // bounding volume
-    float tp1 = (0.0-ro.y)/rd.y; if( tp1>0.0 ) tmax = min( tmax, tp1 );
-    float tp2 = (1.6-ro.y)/rd.y; if( tp2>0.0 ) { if( ro.y>1.6 ) tmin = max( tmin, tp2 );
-                                                 else           tmax = min( tmax, tp2 ); }
+    float tp1 = (0.0-ro.y)/rd.y; if (tp1>0.0) tmax = min(tmax, tp1);
+    float tp2 = (1.6-ro.y)/rd.y; if (tp2>0.0) { if (ro.y>1.6) tmin = max(tmin, tp2);
+                                                 else           tmax = min(tmax, tp2); }
 #endif
 #endif
 
 
     float t = tmin;
     float t = tmin;
     float m = -1.0;
     float m = -1.0;
-    for( int i=0; i<64; i++ )
+    for (int i=0; i<64; i++)
     {
     {
         float precis = 0.0005*t;
         float precis = 0.0005*t;
-        vec2 res = map( ro+rd*t );
-        if( res.x<precis || t>tmax ) break;
+        vec2 res = map(ro+rd*t);
+        if (res.x<precis || t>tmax) break;
         t += res.x;
         t += res.x;
         m = res.y;
         m = res.y;
     }
     }
 
 
-    if( t>tmax ) m=-1.0;
-    return vec2( t, m );
+    if (t>tmax) m=-1.0;
+    return vec2(t, m);
 }
 }
 
 
 
 
-float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
 {
 {
     float res = 1.0;
     float res = 1.0;
     float t = mint;
     float t = mint;
-    for( int i=0; i<16; i++ )
+    for (int i=0; i<16; i++)
     {
     {
-        float h = map( ro + rd*t ).x;
-        res = min( res, 8.0*h/t );
-        t += clamp( h, 0.02, 0.10 );
-        if( h<0.001 || t>tmax ) break;
+        float h = map(ro + rd*t).x;
+        res = min(res, 8.0*h/t);
+        t += clamp(h, 0.02, 0.10);
+        if (h<0.001 || t>tmax) break;
     }
     }
-    return clamp( res, 0.0, 1.0 );
+    return clamp(res, 0.0, 1.0);
 }
 }
 
 
-vec3 calcNormal( in vec3 pos )
+vec3 calcNormal(in vec3 pos)
 {
 {
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
     vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
-    return normalize( e.xyy*map( pos + e.xyy ).x +
-                      e.yyx*map( pos + e.yyx ).x +
-                      e.yxy*map( pos + e.yxy ).x +
-                      e.xxx*map( pos + e.xxx ).x );
+    return normalize(e.xyy*map(pos + e.xyy).x +
+                      e.yyx*map(pos + e.yyx).x +
+                      e.yxy*map(pos + e.yxy).x +
+                      e.xxx*map(pos + e.xxx).x);
     /*
     /*
-    vec3 eps = vec3( 0.0005, 0.0, 0.0 );
+    vec3 eps = vec3(0.0005, 0.0, 0.0);
     vec3 nor = vec3(
     vec3 nor = vec3(
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.xyy).x - map(pos-eps.xyy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
         map(pos+eps.yxy).x - map(pos-eps.yxy).x,
-        map(pos+eps.yyx).x - map(pos-eps.yyx).x );
+        map(pos+eps.yyx).x - map(pos-eps.yyx).x);
     return normalize(nor);
     return normalize(nor);
     */
     */
 }
 }
 
 
-float calcAO( in vec3 pos, in vec3 nor )
+float calcAO(in vec3 pos, in vec3 nor)
 {
 {
     float occ = 0.0;
     float occ = 0.0;
     float sca = 1.0;
     float sca = 1.0;
-    for( int i=0; i<5; i++ )
+    for (int i=0; i<5; i++)
     {
     {
         float hr = 0.01 + 0.12*float(i)/4.0;
         float hr = 0.01 + 0.12*float(i)/4.0;
-        vec3 aopos =  nor * hr + pos;
-        float dd = map( aopos ).x;
+        vec3 aopos =  nor*hr + pos;
+        float dd = map(aopos).x;
         occ += -(dd-hr)*sca;
         occ += -(dd-hr)*sca;
         sca *= 0.95;
         sca *= 0.95;
     }
     }
-    return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
+    return clamp(1.0 - 3.0*occ, 0.0, 1.0);
 }
 }
 
 
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
 // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
-float checkersGradBox( in vec2 p )
+float checkersGradBox(in vec2 p)
 {
 {
     // filter kernel
     // filter kernel
     vec2 w = fwidth(p) + 0.001;
     vec2 w = fwidth(p) + 0.001;
@@ -327,43 +327,43 @@ float checkersGradBox( in vec2 p )
     return 0.5 - 0.5*i.x*i.y;
     return 0.5 - 0.5*i.x*i.y;
 }
 }
 
 
-vec3 render( in vec3 ro, in vec3 rd )
+vec3 render(in vec3 ro, in vec3 rd)
 {
 {
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
     vec2 res = castRay(ro,rd);
     vec2 res = castRay(ro,rd);
     float t = res.x;
     float t = res.x;
     float m = res.y;
     float m = res.y;
-    if( m>-0.5 )
+    if (m>-0.5)
     {
     {
         vec3 pos = ro + t*rd;
         vec3 pos = ro + t*rd;
-        vec3 nor = calcNormal( pos );
-        vec3 ref = reflect( rd, nor );
+        vec3 nor = calcNormal(pos);
+        vec3 ref = reflect(rd, nor);
 
 
         // material
         // material
-        col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) );
-        if( m<1.5 )
+        col = 0.45 + 0.35*sin(vec3(0.05,0.08,0.10)*(m-1.0));
+        if (m<1.5)
         {
         {
 
 
-            float f = checkersGradBox( 5.0*pos.xz );
+            float f = checkersGradBox(5.0*pos.xz);
             col = 0.3 + f*vec3(0.1);
             col = 0.3 + f*vec3(0.1);
         }
         }
 
 
         // lighting
         // lighting
-        float occ = calcAO( pos, nor );
-        vec3  lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) );
-        vec3  hal = normalize( lig-rd );
-        float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 );
-        float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
-        float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
-        float dom = smoothstep( -0.1, 0.1, ref.y );
-        float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
-
-        dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
-        dom *= calcSoftshadow( pos, ref, 0.02, 2.5 );
-
-        float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)*
+        float occ = calcAO(pos, nor);
+        vec3  lig = normalize(vec3(cos(-0.4*runTime), sin(0.7*runTime), -0.6));
+        vec3  hal = normalize(lig-rd);
+        float amb = clamp(0.5+0.5*nor.y, 0.0, 1.0);
+        float dif = clamp(dot(nor, lig), 0.0, 1.0);
+        float bac = clamp(dot(nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
+        float dom = smoothstep(-0.1, 0.1, ref.y);
+        float fre = pow(clamp(1.0+dot(nor,rd),0.0,1.0), 2.0);
+
+        dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
+        dom *= calcSoftshadow(pos, ref, 0.02, 2.5);
+
+        float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0)*
                     dif *
                     dif *
-                    (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 ));
+                    (0.04 + 0.96*pow(clamp(1.0+dot(hal,rd),0.0,1.0), 5.0));
 
 
         vec3 lin = vec3(0.0);
         vec3 lin = vec3(0.0);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
         lin += 1.30*dif*vec3(1.00,0.80,0.55);
@@ -374,51 +374,51 @@ vec3 render( in vec3 ro, in vec3 rd )
         col = col*lin;
         col = col*lin;
         col += 10.00*spe*vec3(1.00,0.90,0.70);
         col += 10.00*spe*vec3(1.00,0.90,0.70);
 
 
-        col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) );
+        col = mix(col, vec3(0.8,0.9,1.0), 1.0-exp(-0.0002*t*t*t));
     }
     }
 
 
-    return vec3( clamp(col,0.0,1.0) );
+    return vec3(clamp(col,0.0,1.0));
 }
 }
 
 
-mat3 setCamera( in vec3 ro, in vec3 ta, float cr )
+mat3 setCamera(in vec3 ro, in vec3 ta, float cr)
 {
 {
     vec3 cw = normalize(ta-ro);
     vec3 cw = normalize(ta-ro);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
     vec3 cp = vec3(sin(cr), cos(cr),0.0);
-    vec3 cu = normalize( cross(cw,cp) );
-    vec3 cv = normalize( cross(cu,cw) );
-    return mat3( cu, cv, cw );
+    vec3 cu = normalize(cross(cw,cp));
+    vec3 cv = normalize(cross(cu,cw));
+    return mat3(cu, cv, cw);
 }
 }
 
 
 void main()
 void main()
 {
 {
     vec3 tot = vec3(0.0);
     vec3 tot = vec3(0.0);
 #if AA>1
 #if AA>1
-    for( int m=0; m<AA; m++ )
-    for( int n=0; n<AA; n++ )
+    for (int m=0; m<AA; m++)
+    for (int n=0; n<AA; n++)
     {
     {
         // pixel coordinates
         // pixel coordinates
-        vec2 o = vec2(float(m),float(n)) / float(AA) - 0.5;
+        vec2 o = vec2(float(m),float(n))/float(AA) - 0.5;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
         vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
 #else
 #else
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
         vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
 #endif
 #endif
 
 
         // RAY: Camera is provided from raylib
         // RAY: Camera is provided from raylib
-        //vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) );
+        //vec3 ro = vec3(-0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x));
 
 
         vec3 ro = viewEye;
         vec3 ro = viewEye;
         vec3 ta = viewCenter;
         vec3 ta = viewCenter;
 
 
         // camera-to-world transformation
         // camera-to-world transformation
-        mat3 ca = setCamera( ro, ta, 0.0 );
+        mat3 ca = setCamera(ro, ta, 0.0);
         // ray direction
         // ray direction
-        vec3 rd = ca * normalize( vec3(p.xy,2.0) );
+        vec3 rd = ca*normalize(vec3(p.xy,2.0));
 
 
         // render
         // render
-        vec3 col = render( ro, rd );
+        vec3 col = render(ro, rd);
 
 
         // gamma
         // gamma
-        col = pow( col, vec3(0.4545) );
+        col = pow(col, vec3(0.4545));
 
 
         tot += col;
         tot += col;
 #if AA>1
 #if AA>1
@@ -426,5 +426,5 @@ void main()
     tot /= float(AA*AA);
     tot /= float(AA*AA);
 #endif
 #endif
 
 
-    finalColor = vec4( tot, 1.0 );
+    finalColor = vec4(tot, 1.0);
 }
 }

+ 1 - 1
examples/shaders/resources/shaders/glsl330/scanlines.fs

@@ -39,7 +39,7 @@ void main()
     fragColor = color;
     fragColor = color;
 */
 */
     // Scanlines method 2
     // Scanlines method 2
-    float globalPos = (fragTexCoord.y + offset) * frequency;
+    float globalPos = (fragTexCoord.y + offset)*frequency;
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
     float wavePos = cos((fract(globalPos) - 0.5)*3.14);
 
 
     // Texel color fetching from texture sampler
     // Texel color fetching from texture sampler

+ 4 - 4
examples/shaders/resources/shaders/glsl330/shadowmap.fs

@@ -49,13 +49,13 @@ void main()
     finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
     finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
 
 
     // Shadow calculations
     // Shadow calculations
-    vec4 fragPosLightSpace = lightVP * vec4(fragPosition, 1);
+    vec4 fragPosLightSpace = lightVP*vec4(fragPosition, 1);
     fragPosLightSpace.xyz /= fragPosLightSpace.w; // Perform the perspective division
     fragPosLightSpace.xyz /= fragPosLightSpace.w; // Perform the perspective division
     fragPosLightSpace.xyz = (fragPosLightSpace.xyz + 1.0)/2.0; // Transform from [-1, 1] range to [0, 1] range
     fragPosLightSpace.xyz = (fragPosLightSpace.xyz + 1.0)/2.0; // Transform from [-1, 1] range to [0, 1] range
     vec2 sampleCoords = fragPosLightSpace.xy;
     vec2 sampleCoords = fragPosLightSpace.xy;
     float curDepth = fragPosLightSpace.z;
     float curDepth = fragPosLightSpace.z;
 
 
-    // Slope-scale depth bias: depth biasing reduces "shadow acne" artifacts, where dark stripes appear all over the scene.
+    // Slope-scale depth bias: depth biasing reduces "shadow acne" artifacts, where dark stripes appear all over the scene
     // The solution is adding a small bias to the depth
     // The solution is adding a small bias to the depth
     // In this case, the bias is proportional to the slope of the surface, relative to the light
     // In this case, the bias is proportional to the slope of the surface, relative to the light
     float bias = max(0.0002*(1.0 - dot(normal, l)), 0.00002) + 0.00001;
     float bias = max(0.0002*(1.0 - dot(normal, l)), 0.00002) + 0.00001;
@@ -64,8 +64,8 @@ void main()
 
 
     // PCF (percentage-closer filtering) algorithm:
     // PCF (percentage-closer filtering) algorithm:
     // Instead of testing if just one point is closer to the current point,
     // Instead of testing if just one point is closer to the current point,
-    // we test the surrounding points as well.
-    // This blurs shadow edges, hiding aliasing artifacts.
+    // we test the surrounding points as well
+    // This blurs shadow edges, hiding aliasing artifacts
     vec2 texelSize = vec2(1.0/float(shadowMapResolution));
     vec2 texelSize = vec2(1.0/float(shadowMapResolution));
     for (int x = -1; x <= 1; x++)
     for (int x = -1; x <= 1; x++)
     {
     {

+ 2 - 2
examples/shaders/resources/shaders/glsl330/sobel.fs

@@ -21,10 +21,10 @@ void main()
 
 
     vec4 horizEdge = vec4(0.0);
     vec4 horizEdge = vec4(0.0);
     horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
     horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
-    horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y    ))*2.0;
+    horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y   ))*2.0;
     horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
     horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
     horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
-    horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y    ))*2.0;
+    horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y   ))*2.0;
     horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
     horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
 
 
     vec4 vertEdge = vec4(0.0);
     vec4 vertEdge = vec4(0.0);

+ 1 - 1
examples/shaders/resources/shaders/glsl330/spotlight.fs

@@ -53,7 +53,7 @@ void main()
         else
         else
         {
         {
             if (d < spots[fi].inner) alpha = 0.0;
             if (d < spots[fi].inner) alpha = 0.0;
-            else alpha = (d - spots[fi].inner) / (spots[fi].radius - spots[fi].inner);
+            else alpha = (d - spots[fi].inner)/(spots[fi].radius - spots[fi].inner);
         }
         }
     }
     }
 
 

+ 4 - 4
examples/shaders/resources/shaders/glsl330/vertex_displacement.vs

@@ -24,13 +24,13 @@ out float height;
 void main()
 void main()
 {
 {
     // Calculate animated texture coordinates based on time and vertex position
     // Calculate animated texture coordinates based on time and vertex position
-    vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x * 0.1), cos(time + vertexPosition.z * 0.1)) * 0.3);
+    vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x*0.1), cos(time + vertexPosition.z*0.1))*0.3);
 
 
     // Normalize animated texture coordinates to range [0, 1]
     // Normalize animated texture coordinates to range [0, 1]
-    animatedTexCoord = animatedTexCoord * 0.5 + 0.5;
+    animatedTexCoord = animatedTexCoord*0.5 + 0.5;
 
 
     // Fetch displacement from the perlin noise map
     // Fetch displacement from the perlin noise map
-    float displacement = texture(perlinNoiseMap, animatedTexCoord).r * 7; // Amplified displacement
+    float displacement = texture(perlinNoiseMap, animatedTexCoord).r*7; // Amplified displacement
 
 
     // Displace vertex position
     // Displace vertex position
     vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
     vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
@@ -39,7 +39,7 @@ void main()
     fragPosition = vec3(matModel*vec4(displacedPosition, 1.0));
     fragPosition = vec3(matModel*vec4(displacedPosition, 1.0));
     fragTexCoord = vertexTexCoord;
     fragTexCoord = vertexTexCoord;
     fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
     fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
-    height = displacedPosition.y * 0.2; // send height to fragment shader for coloring
+    height = displacedPosition.y*0.2; // send height to fragment shader for coloring
 
 
     // Calculate final vertex position
     // Calculate final vertex position
     gl_Position = mvp*vec4(displacedPosition , 1.0);
     gl_Position = mvp*vec4(displacedPosition , 1.0);

+ 5 - 5
examples/shaders/resources/shaders/glsl330/wave.fs

@@ -23,15 +23,15 @@ uniform float speedX;
 uniform float speedY;
 uniform float speedY;
 
 
 void main() {
 void main() {
-    float pixelWidth = 1.0 / size.x;
-    float pixelHeight = 1.0 / size.y;
-    float aspect = pixelHeight / pixelWidth;
+    float pixelWidth = 1.0/size.x;
+    float pixelHeight = 1.0/size.y;
+    float aspect = pixelHeight/pixelWidth;
     float boxLeft = 0.0;
     float boxLeft = 0.0;
     float boxTop = 0.0;
     float boxTop = 0.0;
 
 
     vec2 p = fragTexCoord;
     vec2 p = fragTexCoord;
-    p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
-    p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
+    p.x += cos((fragTexCoord.y - boxTop)*freqX/(pixelWidth*750.0) + (seconds*speedX))*ampX*pixelWidth;
+    p.y += sin((fragTexCoord.x - boxLeft)*freqY*aspect/(pixelHeight*750.0) + (seconds*speedY))*ampY*pixelHeight;
 
 
     finalColor = texture(texture0, p)*colDiffuse*fragColor;
     finalColor = texture(texture0, p)*colDiffuse*fragColor;
 }
 }

+ 1 - 1
examples/text/resources/shaders/glsl330/alpha_discard.fs

@@ -15,5 +15,5 @@ void main()
 {
 {
     vec4 texelColor = texture(texture0, fragTexCoord);
     vec4 texelColor = texture(texture0, fragTexCoord);
     if (texelColor.a == 0.0) discard;
     if (texelColor.a == 0.0) discard;
-    finalColor = texelColor * fragColor * colDiffuse;
+    finalColor = texelColor*fragColor*colDiffuse;
 }
 }