diff --git a/examples/shaders/resources/shaders/glsl100/color_mix.fs b/examples/shaders/resources/shaders/glsl100/color_mix.fs index 0074e6af1..c5c0cb70c 100644 --- a/examples/shaders/resources/shaders/glsl100/color_mix.fs +++ b/examples/shaders/resources/shaders/glsl100/color_mix.fs @@ -11,6 +11,8 @@ uniform sampler2D texture0; uniform sampler2D texture1; uniform vec4 colDiffuse; +uniform float divider; + void main() { // Texel color fetching from texture sampler @@ -18,7 +20,7 @@ void main() vec4 texelColor1 = texture2D(texture1, fragTexCoord); float x = fract(fragTexCoord.s); - float out = smoothstep(0.4, 0.6, x); + float final = smoothstep(divider - 0.1, divider + 0.1, x); - gl_FragColor = mix(texelColor0, texelColor1, out); -} \ No newline at end of file + gl_FragColor = mix(texelColor0, texelColor1, final); +} diff --git a/examples/shaders/resources/shaders/glsl330/color_mix.fs b/examples/shaders/resources/shaders/glsl330/color_mix.fs index 1ac7520a9..761b3464a 100644 --- a/examples/shaders/resources/shaders/glsl330/color_mix.fs +++ b/examples/shaders/resources/shaders/glsl330/color_mix.fs @@ -10,6 +10,8 @@ uniform sampler2D texture0; uniform sampler2D texture1; uniform vec4 colDiffuse; +uniform float divider = 0.5; + out vec4 finalColor; void main() @@ -19,7 +21,7 @@ void main() vec4 texelColor1 = texture(texture1, fragTexCoord); float x = fract(fragTexCoord.s); - float outVal = smoothstep(0.4, 0.6, x); + float final = smoothstep(divider - 0.1, divider + 0.1, x); - finalColor = mix(texelColor0, texelColor1, outVal); + finalColor = mix(texelColor0, texelColor1, final); } \ No newline at end of file diff --git a/examples/shaders/shaders_multi_sample2d.c b/examples/shaders/shaders_multi_sample2d.c index 2e545981c..2ff6f2001 100644 --- a/examples/shaders/shaders_multi_sample2d.c +++ b/examples/shaders/shaders_multi_sample2d.c @@ -45,6 +45,10 @@ int main(void) // Get an additional sampler2D location to be enabled on drawing int texBlueLoc = GetShaderLocation(shader, "texture1"); + + // Get shader uniform for divider + int dividerLoc = GetShaderLocation(shader, "divider"); + float dividerValue = 0.5f; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -54,7 +58,13 @@ int main(void) { // Update //---------------------------------------------------------------------------------- - // ... + if (IsKeyDown(KEY_RIGHT)) dividerValue += 0.01f; + else if (IsKeyDown(KEY_LEFT)) dividerValue -= 0.01f; + + if (dividerValue < 0.0f) dividerValue = 0.0f; + else if (dividerValue > 1.0f) dividerValue = 1.0f; + + SetShaderValue(shader, dividerLoc, ÷rValue, SHADER_UNIFORM_FLOAT); //---------------------------------------------------------------------------------- // Draw @@ -75,6 +85,8 @@ int main(void) DrawTexture(texRed, 0, 0, WHITE); EndShaderMode(); + + DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, GetScreenHeight() - 40, 20, RAYWHITE); EndDrawing(); //----------------------------------------------------------------------------------