diff options
| author | raysan5 <[email protected]> | 2021-10-17 21:02:18 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2021-10-17 21:02:18 +0200 |
| commit | 35e67da08e3d214589968c19b4b2fb31d8e566cc (patch) | |
| tree | 5054bcea5f6df754f467590101789b17dd9d9944 /examples/shaders/shaders_hot_reloading.data | |
| parent | b2228039039afc05c41edd12103123f2a36c8080 (diff) | |
| download | raylib.com-35e67da08e3d214589968c19b4b2fb31d8e566cc.tar.gz raylib.com-35e67da08e3d214589968c19b4b2fb31d8e566cc.zip | |
UPDATED: examples to raylib 4.0
Some new examples added
Diffstat (limited to 'examples/shaders/shaders_hot_reloading.data')
| -rw-r--r-- | examples/shaders/shaders_hot_reloading.data | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/shaders/shaders_hot_reloading.data b/examples/shaders/shaders_hot_reloading.data new file mode 100644 index 0000000..eda00ae --- /dev/null +++ b/examples/shaders/shaders_hot_reloading.data @@ -0,0 +1,39 @@ +#version 100 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; // Texture coordinates (sampler2D) +varying vec4 fragColor; // Tint color + +// Uniform inputs +uniform vec2 resolution; // Viewport resolution (in pixels) +uniform vec2 mouse; // Mouse pixel xy coordinates +uniform float time; // Total run time (in secods) + +// Draw circle +vec4 DrawCircle(vec2 fragCoord, vec2 position, float radius, vec3 color) +{ + float d = length(position - fragCoord) - radius; + float t = clamp(d, 0.0, 1.0); + return vec4(color, 1.0 - t); +} + +void main() +{ + vec2 fragCoord = gl_FragCoord.xy; + vec2 position = vec2(mouse.x, resolution.y - mouse.y); + float radius = 40.0; + + // Draw background layer + vec4 colorA = vec4(0.2,0.2,0.8, 1.0); + vec4 colorB = vec4(1.0,0.7,0.2, 1.0); + vec4 layer1 = mix(colorA, colorB, abs(sin(time*0.1))); + + // Draw circle layer + vec3 color = vec3(0.9, 0.16, 0.21); + vec4 layer2 = DrawCircle(fragCoord, position, radius, color); + + // Blend the two layers + gl_FragColor = mix(layer1, layer2, layer2.a); +} |
