mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
[examples] Added shaders_color_correction (#5307)
* [examples] Added `shaders_color_correction` * Add _CRT_SECURE_NO_WARNINGS to VS Project * Added to makefiles
This commit is contained in:
@ -10,4 +10,7 @@
|
||||
| space.png | ❔ | ❔ | - |
|
||||
| texel_checker.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [UV Checker Map Maker](http://uvchecker.byvalle.com/) |
|
||||
| cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||
| spark_flame.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [EffectTextureMaker](https://mebiusbox.github.io/contents/EffectTextureMaker/) |
|
||||
| spark_flame.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [EffectTextureMaker](https://mebiusbox.github.io/contents/EffectTextureMaker/) |
|
||||
| parrots.png | [Kodak set](http://r0k.us/graphics/kodak/) | ❔ | Original name: `kodim23.png` |
|
||||
| cat.png | ❔ | ❔ | - |
|
||||
| mandrill.png | ❔ | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Mandrill (a.k.a. Baboon) |
|
||||
BIN
examples/shaders/resources/cat.png
Normal file
BIN
examples/shaders/resources/cat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 379 KiB |
BIN
examples/shaders/resources/mandrill.png
Normal file
BIN
examples/shaders/resources/mandrill.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 193 KiB |
BIN
examples/shaders/resources/parrots.png
Normal file
BIN
examples/shaders/resources/parrots.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 KiB |
@ -0,0 +1,34 @@
|
||||
#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 colDiffuse;
|
||||
|
||||
uniform float contrast;
|
||||
uniform float saturation;
|
||||
uniform float brightness;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Get texel color
|
||||
vec4 texel = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// Apply contrast
|
||||
texel.rgb = (texel.rgb - 0.5)*(contrast/100.0 + 1.0) + 0.5;
|
||||
|
||||
// Apply brightness
|
||||
texel.rgb = texel.rgb + brightness/100.0;
|
||||
|
||||
// Apply saturation
|
||||
float intensity = dot(texel.rgb, vec3(0.299, 0.587, 0.114));
|
||||
texel.rgb = (texel.rgb - intensity)*saturation/100.0 + texel.rgb;
|
||||
|
||||
// Output resulting color
|
||||
gl_FragColor = texel;
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float contrast;
|
||||
uniform float saturation;
|
||||
uniform float brightness;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture2D(texture0, fragTexCoord); // Get texel color
|
||||
|
||||
// Apply contrast
|
||||
texel.rgb = (texel.rgb - 0.5)*(contrast/100.0 + 1.0) + 0.5;
|
||||
|
||||
// Apply brightness
|
||||
texel.rgb = texel.rgb + brightness/100.0;
|
||||
|
||||
// Apply saturation
|
||||
float intensity = dot(texel.rgb, vec3(0.299, 0.587, 0.114));
|
||||
texel.rgb = (texel.rgb - intensity)*saturation/100.0 + texel.rgb;
|
||||
|
||||
// Output resulting color
|
||||
gl_FragColor = texel;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float contrast;
|
||||
uniform float saturation;
|
||||
uniform float brightness;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture(texture0, fragTexCoord); // Get texel color
|
||||
|
||||
// Apply contrast
|
||||
texel.rgb = (texel.rgb - 0.5f)*(contrast/100.0f + 1.0f) + 0.5f;
|
||||
|
||||
// Apply brightness
|
||||
texel.rgb = texel.rgb + brightness/100.0f;
|
||||
|
||||
// Apply saturation
|
||||
float intensity = dot(texel.rgb, vec3(0.299f, 0.587f, 0.114f));
|
||||
texel.rgb = (texel.rgb - intensity)*saturation/100.0f + texel.rgb;
|
||||
|
||||
// Output resulting color
|
||||
finalColor = texel;
|
||||
}
|
||||
Reference in New Issue
Block a user