From 1d545449bb19148b45d2d92f213e1001a8eb527c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 7 Apr 2016 12:32:32 +0200 Subject: Reviewed shaders and added comments --- examples/resources/shaders/base.vs | 21 ------- examples/resources/shaders/bloom.fs | 43 -------------- examples/resources/shaders/glsl100/base.vs | 26 +++++++++ examples/resources/shaders/glsl100/bloom.fs | 37 ++++++++++++ examples/resources/shaders/glsl100/grayscale.fs | 25 ++++++++ examples/resources/shaders/glsl100/swirl.fs | 45 +++++++++++++++ examples/resources/shaders/glsl330/base.vs | 26 +++++++++ examples/resources/shaders/glsl330/bloom.fs | 38 +++++++++++++ examples/resources/shaders/glsl330/grayscale.fs | 26 +++++++++ examples/resources/shaders/glsl330/phong.fs | 76 +++++++++++++++++++++++++ examples/resources/shaders/glsl330/phong.vs | 29 ++++++++++ examples/resources/shaders/glsl330/swirl.fs | 46 +++++++++++++++ examples/resources/shaders/grayscale.fs | 20 ------- examples/resources/shaders/phong.fs | 76 ------------------------- examples/resources/shaders/phong.vs | 29 ---------- examples/resources/shaders/shapes_base.vs | 18 ------ examples/resources/shaders/shapes_grayscale.fs | 15 ----- examples/resources/shaders/swirl.fs | 41 ------------- examples/shaders_custom_uniform.c | 6 +- examples/shaders_model_shader.c | 4 +- examples/shaders_postprocessing.c | 6 +- examples/shaders_shapes_textures.c | 7 +-- 22 files changed, 385 insertions(+), 275 deletions(-) delete mode 100644 examples/resources/shaders/base.vs delete mode 100644 examples/resources/shaders/bloom.fs create mode 100644 examples/resources/shaders/glsl100/base.vs create mode 100644 examples/resources/shaders/glsl100/bloom.fs create mode 100644 examples/resources/shaders/glsl100/grayscale.fs create mode 100644 examples/resources/shaders/glsl100/swirl.fs create mode 100644 examples/resources/shaders/glsl330/base.vs create mode 100644 examples/resources/shaders/glsl330/bloom.fs create mode 100644 examples/resources/shaders/glsl330/grayscale.fs create mode 100644 examples/resources/shaders/glsl330/phong.fs create mode 100644 examples/resources/shaders/glsl330/phong.vs create mode 100644 examples/resources/shaders/glsl330/swirl.fs delete mode 100644 examples/resources/shaders/grayscale.fs delete mode 100644 examples/resources/shaders/phong.fs delete mode 100644 examples/resources/shaders/phong.vs delete mode 100644 examples/resources/shaders/shapes_base.vs delete mode 100644 examples/resources/shaders/shapes_grayscale.fs delete mode 100644 examples/resources/shaders/swirl.fs (limited to 'examples') diff --git a/examples/resources/shaders/base.vs b/examples/resources/shaders/base.vs deleted file mode 100644 index 9b8cca69..00000000 --- a/examples/resources/shaders/base.vs +++ /dev/null @@ -1,21 +0,0 @@ -#version 330 - -in vec3 vertexPosition; -in vec2 vertexTexCoord; -in vec3 vertexNormal; -in vec4 vertexColor; - -out vec2 fragTexCoord; -out vec4 fragTintColor; - -uniform mat4 mvpMatrix; - -// NOTE: Add here your custom variables - -void main() -{ - fragTexCoord = vertexTexCoord; - fragTintColor = vertexColor; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/resources/shaders/bloom.fs b/examples/resources/shaders/bloom.fs deleted file mode 100644 index 0a73161a..00000000 --- a/examples/resources/shaders/bloom.fs +++ /dev/null @@ -1,43 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; -in vec4 fragTintColor; - -out vec4 fragColor; - -uniform sampler2D texture0; -//uniform vec4 fragTintColor; - -// NOTE: Add here your custom variables - -void main() -{ - vec4 sum = vec4(0); - vec4 tc = vec4(0); - - for (int i = -4; i < 4; i++) - { - for (int j = -3; j < 3; j++) - { - sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25; - } - } - - if (texture2D(texture0, fragTexCoord).r < 0.3) - { - tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord); - } - else - { - if (texture2D(texture0, fragTexCoord).r < 0.5) - { - tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord); - } - else - { - tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord); - } - } - - fragColor = tc; -} \ No newline at end of file diff --git a/examples/resources/shaders/glsl100/base.vs b/examples/resources/shaders/glsl100/base.vs new file mode 100644 index 00000000..e9386939 --- /dev/null +++ b/examples/resources/shaders/glsl100/base.vs @@ -0,0 +1,26 @@ +#version 100 + +// Input vertex attributes +attribute vec3 vertexPosition; +attribute vec2 vertexTexCoord; +attribute vec3 vertexNormal; +attribute vec4 vertexColor; + +// Input uniform values +uniform mat4 mvpMatrix; + +// Output vertex attributes (to fragment shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Send vertex attributes to fragment shader + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + // Calculate final vertex position + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl100/bloom.fs b/examples/resources/shaders/glsl100/bloom.fs new file mode 100644 index 00000000..5a08843d --- /dev/null +++ b/examples/resources/shaders/glsl100/bloom.fs @@ -0,0 +1,37 @@ +#version 100 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// NOTE: Add here your custom variables + +void main() +{ + vec4 sum = vec4(0); + vec4 tc = vec4(0); + + for (int i = -4; i < 4; i++) + { + for (int j = -3; j < 3; j++) + { + sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25; + } + } + + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord); + + // Calculate final fragment color + if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor; + else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor; + else tc = sum*sum*0.0075 + texelColor; + + finalColor = tc; +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl100/grayscale.fs b/examples/resources/shaders/glsl100/grayscale.fs new file mode 100644 index 00000000..f92ec335 --- /dev/null +++ b/examples/resources/shaders/glsl100/grayscale.fs @@ -0,0 +1,25 @@ +#version 100 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor; + + // Convert texel color to grayscale using NTSC conversion weights + float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); + + // Calculate final fragment color + gl_FragColor = vec4(gray, gray, gray, texelColor.a); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl100/swirl.fs b/examples/resources/shaders/glsl100/swirl.fs new file mode 100644 index 00000000..e77d4f87 --- /dev/null +++ b/examples/resources/shaders/glsl100/swirl.fs @@ -0,0 +1,45 @@ +#version 100 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// NOTE: Add here your custom variables + +const float renderWidth = 800.0; // HARDCODED for example! +const float renderHeight = 480.0; // Use uniforms instead... + +float radius = 250.0; +float angle = 0.8; + +uniform vec2 center = vec2(200.0, 200.0); + +void main (void) +{ + vec2 texSize = vec2(renderWidth, renderHeight); + vec2 tc = fragTexCoord*texSize; + tc -= center; + + float dist = length(tc); + + if (dist < radius) + { + float percent = (radius - dist)/radius; + float theta = percent*percent*angle*8.0; + float s = sin(theta); + float c = cos(theta); + + tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); + } + + tc += center; + vec3 color = texture2D(texture0, tc/texSize).rgb; + + gl_FragColor = vec4(color, 1.0);; +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/base.vs b/examples/resources/shaders/glsl330/base.vs new file mode 100644 index 00000000..638cb8ae --- /dev/null +++ b/examples/resources/shaders/glsl330/base.vs @@ -0,0 +1,26 @@ +#version 330 + +// Input vertex attributes +in vec3 vertexPosition; +in vec2 vertexTexCoord; +in vec3 vertexNormal; +in vec4 vertexColor; + +// Input uniform values +uniform mat4 mvpMatrix; + +// Output vertex attributes (to fragment shader) +out vec2 fragTexCoord; +out vec4 fragColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Send vertex attributes to fragment shader + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + // Calculate final vertex position + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/bloom.fs b/examples/resources/shaders/glsl330/bloom.fs new file mode 100644 index 00000000..c8cb0d32 --- /dev/null +++ b/examples/resources/shaders/glsl330/bloom.fs @@ -0,0 +1,38 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables + +void main() +{ + vec4 sum = vec4(0); + vec4 tc = vec4(0); + + for (int i = -4; i < 4; i++) + { + for (int j = -3; j < 3; j++) + { + sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25; + } + } + + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord); + + // Calculate final fragment color + if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor; + else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor; + else tc = sum*sum*0.0075 + texelColor; + + finalColor = tc; +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/grayscale.fs b/examples/resources/shaders/glsl330/grayscale.fs new file mode 100644 index 00000000..d4a8824f --- /dev/null +++ b/examples/resources/shaders/glsl330/grayscale.fs @@ -0,0 +1,26 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor; + + // Convert texel color to grayscale using NTSC conversion weights + float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); + + // Calculate final fragment color + finalColor = vec4(gray, gray, gray, texelColor.a); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/phong.fs b/examples/resources/shaders/glsl330/phong.fs new file mode 100644 index 00000000..2e7a95f6 --- /dev/null +++ b/examples/resources/shaders/glsl330/phong.fs @@ -0,0 +1,76 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec3 fragNormal; + +// Diffuse data +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// Light attributes +uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0.0); +uniform vec3 light_diffuseColor = vec3(1.0, 0.5, 0.0); +uniform vec3 light_specularColor = vec3(0.0, 1.0, 0.0); +uniform float light_intensity = 1.0; +uniform float light_specIntensity = 1.0; + +// Material attributes +uniform vec3 mat_ambientColor = vec3(1.0, 1.0, 1.0); +uniform vec3 mat_specularColor = vec3(1.0, 1.0, 1.0); +uniform float mat_glossiness = 50.0; + +// World attributes +uniform vec3 lightPos; +uniform vec3 cameraPos; + +// Fragment shader output data +out vec4 fragColor; + +vec3 AmbientLighting() +{ + return (mat_ambientColor*light_ambientColor); +} + +vec3 DiffuseLighting(in vec3 N, in vec3 L) +{ + // Lambertian reflection calculation + float diffuse = clamp(dot(N, L), 0, 1); + + return (fragTintColor.xyz*light_diffuseColor*light_intensity*diffuse); +} + +vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V) +{ + float specular = 0.0; + + // Calculate specular reflection only if the surface is oriented to the light source + if (dot(N, L) > 0) + { + // Calculate half vector + vec3 H = normalize(L + V); + + // Calculate specular intensity + specular = pow(dot(N, H), 3 + mat_glossiness); + } + + return (mat_specularColor*light_specularColor*light_specIntensity*specular); +} + +void main() +{ + // Normalize input vectors + vec3 L = normalize(lightPos); + vec3 V = normalize(cameraPos); + vec3 N = normalize(fragNormal); + + vec3 ambient = AmbientLighting(); + vec3 diffuse = DiffuseLighting(N, L); + vec3 specular = SpecularLighting(N, L, V); + + // Get base color from texture + vec4 textureColor = texture(texture0, fragTexCoord); + vec3 finalColor = textureColor.rgb; + + fragColor = vec4(finalColor * (ambient + diffuse + specular), textureColor.a); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/phong.vs b/examples/resources/shaders/glsl330/phong.vs new file mode 100644 index 00000000..d68d9b3f --- /dev/null +++ b/examples/resources/shaders/glsl330/phong.vs @@ -0,0 +1,29 @@ +#version 330 + +// Input vertex attributes +in vec3 vertexPosition; +in vec2 vertexTexCoord; +in vec3 vertexNormal; + +// Input uniform values +uniform mat4 mvpMatrix; + +// Output vertex attributes (to fragment shader) +out vec2 fragTexCoord; +out vec3 fragNormal; + +// NOTE: Add here your custom variables +uniform mat4 modelMatrix; + +void main() +{ + // Send vertex attributes to fragment shader + fragTexCoord = vertexTexCoord; + + // Calculate view vector normal from model + mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); + fragNormal = normalize(normalMatrix*vertexNormal); + + // Calculate final vertex position + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/swirl.fs b/examples/resources/shaders/glsl330/swirl.fs new file mode 100644 index 00000000..b1dc82f0 --- /dev/null +++ b/examples/resources/shaders/glsl330/swirl.fs @@ -0,0 +1,46 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables + +const float renderWidth = 800.0; // HARDCODED for example! +const float renderHeight = 480.0; // Use uniforms instead... + +float radius = 250.0; +float angle = 0.8; + +uniform vec2 center = vec2(200.0, 200.0); + +void main (void) +{ + vec2 texSize = vec2(renderWidth, renderHeight); + vec2 tc = fragTexCoord*texSize; + tc -= center; + + float dist = length(tc); + + if (dist < radius) + { + float percent = (radius - dist)/radius; + float theta = percent*percent*angle*8.0; + float s = sin(theta); + float c = cos(theta); + + tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); + } + + tc += center; + vec3 color = texture2D(texture0, tc/texSize).rgb; + + finalColor = vec4(color, 1.0);; +} \ No newline at end of file diff --git a/examples/resources/shaders/grayscale.fs b/examples/resources/shaders/grayscale.fs deleted file mode 100644 index af50b8c1..00000000 --- a/examples/resources/shaders/grayscale.fs +++ /dev/null @@ -1,20 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; - -out vec4 fragColor; - -uniform sampler2D texture0; -uniform vec4 fragTintColor; - -// NOTE: Add here your custom variables - -void main() -{ - vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor; - - // Convert to grayscale using NTSC conversion weights - float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); - - fragColor = vec4(gray, gray, gray, fragTintColor.a); -} \ No newline at end of file diff --git a/examples/resources/shaders/phong.fs b/examples/resources/shaders/phong.fs deleted file mode 100644 index f79413d9..00000000 --- a/examples/resources/shaders/phong.fs +++ /dev/null @@ -1,76 +0,0 @@ -#version 330 - -// Vertex shader input data -in vec2 fragTexCoord; -in vec3 fragNormal; - -// Diffuse data -uniform sampler2D texture0; -uniform vec4 fragTintColor; - -// Light attributes -uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0.0); -uniform vec3 light_diffuseColor = vec3(1.0, 0.5, 0.0); -uniform vec3 light_specularColor = vec3(0.0, 1.0, 0.0); -uniform float light_intensity = 1.0; -uniform float light_specIntensity = 1.0; - -// Material attributes -uniform vec3 mat_ambientColor = vec3(1.0, 1.0, 1.0); -uniform vec3 mat_specularColor = vec3(1.0, 1.0, 1.0); -uniform float mat_glossiness = 50.0; - -// World attributes -uniform vec3 lightPos; -uniform vec3 cameraPos; - -// Fragment shader output data -out vec4 fragColor; - -vec3 AmbientLighting() -{ - return (mat_ambientColor*light_ambientColor); -} - -vec3 DiffuseLighting(in vec3 N, in vec3 L) -{ - // Lambertian reflection calculation - float diffuse = clamp(dot(N, L), 0, 1); - - return (fragTintColor.xyz*light_diffuseColor*light_intensity*diffuse); -} - -vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V) -{ - float specular = 0.0; - - // Calculate specular reflection only if the surface is oriented to the light source - if (dot(N, L) > 0) - { - // Calculate half vector - vec3 H = normalize(L + V); - - // Calculate specular intensity - specular = pow(dot(N, H), 3 + mat_glossiness); - } - - return (mat_specularColor*light_specularColor*light_specIntensity*specular); -} - -void main() -{ - // Normalize input vectors - vec3 L = normalize(lightPos); - vec3 V = normalize(cameraPos); - vec3 N = normalize(fragNormal); - - vec3 ambient = AmbientLighting(); - vec3 diffuse = DiffuseLighting(N, L); - vec3 specular = SpecularLighting(N, L, V); - - // Get base color from texture - vec4 textureColor = texture(texture0, fragTexCoord); - vec3 finalColor = textureColor.rgb; - - fragColor = vec4(finalColor * (ambient + diffuse + specular), textureColor.a); -} \ No newline at end of file diff --git a/examples/resources/shaders/phong.vs b/examples/resources/shaders/phong.vs deleted file mode 100644 index 52cc2227..00000000 --- a/examples/resources/shaders/phong.vs +++ /dev/null @@ -1,29 +0,0 @@ -#version 330 - -// Vertex input data -in vec3 vertexPosition; -in vec2 vertexTexCoord; -in vec3 vertexNormal; - -// Projection and model data -uniform mat4 mvpMatrix; - -uniform mat4 modelMatrix; -//uniform mat4 viewMatrix; // Not used - -// Attributes to fragment shader -out vec2 fragTexCoord; -out vec3 fragNormal; - -void main() -{ - // Send texture coord to fragment shader - fragTexCoord = vertexTexCoord; - - // Calculate view vector normal from model - mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); - fragNormal = normalize(normalMatrix*vertexNormal); - - // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/resources/shaders/shapes_base.vs b/examples/resources/shaders/shapes_base.vs deleted file mode 100644 index ad272dc1..00000000 --- a/examples/resources/shaders/shapes_base.vs +++ /dev/null @@ -1,18 +0,0 @@ -#version 330 - -attribute vec3 vertexPosition; -attribute vec2 vertexTexCoord; -attribute vec4 vertexColor; - -uniform mat4 mvpMatrix; - -varying vec2 fragTexCoord; -varying vec4 fragTintColor; - -void main() -{ - fragTexCoord = vertexTexCoord; - fragTintColor = vertexColor; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/resources/shaders/shapes_grayscale.fs b/examples/resources/shaders/shapes_grayscale.fs deleted file mode 100644 index 0698e1bf..00000000 --- a/examples/resources/shaders/shapes_grayscale.fs +++ /dev/null @@ -1,15 +0,0 @@ -#version 330 - -uniform sampler2D texture0; -varying vec2 fragTexCoord; -varying vec4 fragTintColor; - -void main() -{ - vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor; - - // Convert to grayscale using NTSC conversion weights - float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); - - gl_FragColor = vec4(gray, gray, gray, base.a); -} \ No newline at end of file diff --git a/examples/resources/shaders/swirl.fs b/examples/resources/shaders/swirl.fs deleted file mode 100644 index f89ef406..00000000 --- a/examples/resources/shaders/swirl.fs +++ /dev/null @@ -1,41 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; - -out vec4 fragColor; - -uniform sampler2D texture0; -uniform vec4 fragTintColor; - -// NOTE: Add here your custom variables - -const float renderWidth = 800.0; // HARDCODED for example! -const float renderHeight = 480.0; // Use uniforms instead... - -float radius = 250.0; -float angle = 0.8; - -uniform vec2 center = vec2(200.0, 200.0); - -void main (void) -{ - vec2 texSize = vec2(renderWidth, renderHeight); - vec2 tc = fragTexCoord*texSize; - tc -= center; - float dist = length(tc); - - if (dist < radius) - { - float percent = (radius - dist)/radius; - float theta = percent*percent*angle*8.0; - float s = sin(theta); - float c = cos(theta); - - tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); - } - - tc += center; - vec3 color = texture2D(texture0, tc/texSize).rgb; - - fragColor = vec4(color, 1.0);; -} \ No newline at end of file diff --git a/examples/shaders_custom_uniform.c b/examples/shaders_custom_uniform.c index af59dc3c..ceaa86df 100644 --- a/examples/shaders_custom_uniform.c +++ b/examples/shaders_custom_uniform.c @@ -36,10 +36,10 @@ int main() Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture SetModelTexture(&dwarf, texture); // Bind texture to model - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - Shader shader = LoadShader("resources/shaders/base.vs", - "resources/shaders/swirl.fs"); // Load postpro shader + Shader shader = LoadShader("resources/shaders/glsl330/base.vs", + "resources/shaders/glsl330/swirl.fs"); // Load postpro shader // Get variable (uniform) location on the shader to connect with the program // NOTE: If uniform variable could not be found in the shader, function returns -1 diff --git a/examples/shaders_model_shader.c b/examples/shaders_model_shader.c index a10ec235..b302f631 100644 --- a/examples/shaders_model_shader.c +++ b/examples/shaders_model_shader.c @@ -34,8 +34,8 @@ int main() Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture - Shader shader = LoadShader("resources/shaders/base.vs", - "resources/shaders/grayscale.fs"); // Load model shader + Shader shader = LoadShader("resources/shaders/glsl330/base.vs", + "resources/shaders/glsl330/grayscale.fs"); // Load model shader SetModelShader(&dwarf, shader); // Set shader effect to 3d model SetModelTexture(&dwarf, texture); // Bind texture to model diff --git a/examples/shaders_postprocessing.c b/examples/shaders_postprocessing.c index 0bcd5156..632a6371 100644 --- a/examples/shaders_postprocessing.c +++ b/examples/shaders_postprocessing.c @@ -38,8 +38,8 @@ int main() Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - Shader shader = LoadShader("resources/shaders/base.vs", - "resources/shaders/bloom.fs"); // Load postpro shader + Shader shader = LoadShader("resources/shaders/glsl330/base.vs", + "resources/shaders/glsl330/bloom.fs"); // Load postpro shader // Create a RenderTexture2D to be used for render to texture RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); @@ -76,7 +76,7 @@ int main() End3dMode(); - DrawText("HELLO TEXTURE!!!", 120, 200, 60, RED); + DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED); EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) diff --git a/examples/shaders_shapes_textures.c b/examples/shaders_shapes_textures.c index 37180cec..1b1142fa 100644 --- a/examples/shaders_shapes_textures.c +++ b/examples/shaders_shapes_textures.c @@ -32,10 +32,9 @@ int main() Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png"); - // NOTE: This shader is a bit different than model/postprocessing shaders, - // it requires the color data for every vertice to use it in every shape or texture independently - Shader shader = LoadShader("resources/shaders/shapes_base.vs", - "resources/shaders/shapes_grayscale.fs"); + // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version + Shader shader = LoadShader("resources/shaders/glsl330/base.vs", + "resources/shaders/glsl330/grayscale.fs"); // Shader usage is also different than models/postprocessing, shader is just activated when required -- cgit v1.2.3