From c1e3641baeb2c31c183f34e8913b058cc6a94c98 Mon Sep 17 00:00:00 2001 From: Anstro Pleuton Date: Tue, 21 Jan 2025 23:09:51 -0800 Subject: [PATCH] Add shaders_rounded_rectangle example --- examples/Makefile | 3 +- examples/Makefile.Web | 3 +- examples/README.md | 27 +- .../shaders/glsl100/rounded_rectangle.fs | 90 ++++ .../glsl100/rounded_rectangle_border.fs | 91 ++++ .../glsl100/rounded_rectangle_shadow.fs | 98 +++++ .../shaders/glsl120/rounded_rectangle.fs | 87 ++++ .../glsl120/rounded_rectangle_border.fs | 89 ++++ .../glsl120/rounded_rectangle_shadow.fs | 96 +++++ .../shaders/glsl330/rounded_rectangle.fs | 90 ++++ .../glsl330/rounded_rectangle_border.fs | 92 +++++ .../glsl330/rounded_rectangle_shadow.fs | 99 +++++ examples/shaders/shaders_rounded_rectangle.c | 208 ++++++++++ .../shaders/shaders_rounded_rectangle.png | Bin 0 -> 13936 bytes .../shaders_rounded_rectangle.vcxproj | 387 ++++++++++++++++++ projects/VS2022/raylib.sln | 19 + 16 files changed, 1464 insertions(+), 15 deletions(-) create mode 100644 examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs create mode 100644 examples/shaders/resources/shaders/glsl100/rounded_rectangle_border.fs create mode 100644 examples/shaders/resources/shaders/glsl100/rounded_rectangle_shadow.fs create mode 100644 examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs create mode 100644 examples/shaders/resources/shaders/glsl120/rounded_rectangle_border.fs create mode 100644 examples/shaders/resources/shaders/glsl120/rounded_rectangle_shadow.fs create mode 100644 examples/shaders/resources/shaders/glsl330/rounded_rectangle.fs create mode 100644 examples/shaders/resources/shaders/glsl330/rounded_rectangle_border.fs create mode 100644 examples/shaders/resources/shaders/glsl330/rounded_rectangle_shadow.fs create mode 100644 examples/shaders/shaders_rounded_rectangle.c create mode 100644 examples/shaders/shaders_rounded_rectangle.png create mode 100644 projects/VS2022/examples/shaders_rounded_rectangle.vcxproj diff --git a/examples/Makefile b/examples/Makefile index 834007c26..736da215a 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -646,7 +646,8 @@ SHADERS = \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ shaders/shaders_write_depth \ - shaders/shaders_vertex_displacement + shaders/shaders_vertex_displacement \ + shaders/shaders_rounded_rectangle.c AUDIO = \ audio/audio_mixed_processor \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index c9becc29b..d22751293 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -526,7 +526,8 @@ SHADERS = \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ shaders/shaders_vertex_displacement \ - shaders/shaders_write_depth + shaders/shaders_write_depth \ + shaders/shaders_rounded_rectangle AUDIO = \ audio/audio_mixed_processor \ diff --git a/examples/README.md b/examples/README.md index ba14d82dd..9906e5b55 100644 --- a/examples/README.md +++ b/examples/README.md @@ -199,6 +199,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete | 138 | [shaders_write_depth](shaders/shaders_write_depth.c) | shaders_write_depth | ⭐️⭐️☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | | 139 | [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | shaders_basic_pbr | ⭐️⭐️⭐️⭐️ | 5.0 | 5.1-dev | [Afan OLOVCIC](https://github.com/_DevDad) | | 140 | [shaders_lightmap](shaders/shaders_lightmap.c) | shaders_lightmap | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) | +| 141 | [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | shaders_rounded_rectangle | ⭐️⭐️☆☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) | ### category: audio @@ -206,13 +207,13 @@ Examples using raylib audio functionality, including sound/music loading and pla | ## | example | image | difficulty
level | version
created | last version
updated | original
developer | |----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| -| 141 | [audio_module_playing](audio/audio_module_playing.c) | audio_module_playing | ⭐️☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) | -| 142 | [audio_music_stream](audio/audio_music_stream.c) | audio_music_stream | ⭐️☆☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) | -| 143 | [audio_raw_stream](audio/audio_raw_stream.c) | audio_raw_stream | ⭐️⭐️⭐️☆ | 1.6 | 4.2 | [Ray](https://github.com/raysan5) | -| 144 | [audio_sound_loading](audio/audio_sound_loading.c) | audio_sound_loading | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) | -| 145 | [audio_mixed_processor](audio/audio_mixed_processor.c) | audio_mixed_processor | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) | -| 146 | [audio_stream_effects](audio/audio_stream_effects.c) | audio_stream_effects | ⭐️⭐️⭐️⭐️ | 4.2 | 5.0 | [Ray](https://github.com/raysan5) | -| 147 | [audio_sound_multi](audio/audio_sound_multi.c) | audio_sound_multi | ⭐️⭐️☆☆ | 4.6 | 4.6 | [Jeffery Myers](https://github.com/JeffM2501) | +| 142 | [audio_module_playing](audio/audio_module_playing.c) | audio_module_playing | ⭐️☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) | +| 143 | [audio_music_stream](audio/audio_music_stream.c) | audio_music_stream | ⭐️☆☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) | +| 144 | [audio_raw_stream](audio/audio_raw_stream.c) | audio_raw_stream | ⭐️⭐️⭐️☆ | 1.6 | 4.2 | [Ray](https://github.com/raysan5) | +| 145 | [audio_sound_loading](audio/audio_sound_loading.c) | audio_sound_loading | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) | +| 146 | [audio_mixed_processor](audio/audio_mixed_processor.c) | audio_mixed_processor | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) | +| 147 | [audio_stream_effects](audio/audio_stream_effects.c) | audio_stream_effects | ⭐️⭐️⭐️⭐️ | 4.2 | 5.0 | [Ray](https://github.com/raysan5) | +| 148 | [audio_sound_multi](audio/audio_sound_multi.c) | audio_sound_multi | ⭐️⭐️☆☆ | 4.6 | 4.6 | [Jeffery Myers](https://github.com/JeffM2501) | ### category: others @@ -220,12 +221,12 @@ Examples showing raylib misc functionality that does not fit in other categories | ## | example | image | difficulty
level | version
created | last version
updated | original
developer | |----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| -| 148 | [rlgl_standalone](others/rlgl_standalone.c) | rlgl_standalone | ⭐️⭐️⭐️⭐️ | 1.6 | 4.0 | [Ray](https://github.com/raysan5) | -| 149 | [rlgl_compute_shader](others/rlgl_compute_shader.c) | rlgl_compute_shader | ⭐️⭐️⭐️⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) | -| 150 | [easings_testbed](others/easings_testbed.c) | easings_testbed | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) | -| 151 | [raylib_opengl_interop](others/raylib_opengl_interop.c) | raylib_opengl_interop | ⭐️⭐️⭐️⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) | -| 152 | [embedded_files_loading](others/embedded_files_loading.c) | embedded_files_loading | ⭐️⭐️☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) | -| 153 | [raymath_vector_angle](others/raymath_vector_angle.c) | raymath_vector_angle | ⭐️⭐️☆☆ | 1.0 | 4.6 | [Ray](https://github.com/raysan5) | +| 149 | [rlgl_standalone](others/rlgl_standalone.c) | rlgl_standalone | ⭐️⭐️⭐️⭐️ | 1.6 | 4.0 | [Ray](https://github.com/raysan5) | +| 150 | [rlgl_compute_shader](others/rlgl_compute_shader.c) | rlgl_compute_shader | ⭐️⭐️⭐️⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) | +| 151 | [easings_testbed](others/easings_testbed.c) | easings_testbed | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) | +| 152 | [raylib_opengl_interop](others/raylib_opengl_interop.c) | raylib_opengl_interop | ⭐️⭐️⭐️⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) | +| 153 | [embedded_files_loading](others/embedded_files_loading.c) | embedded_files_loading | ⭐️⭐️☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) | +| 154 | [raymath_vector_angle](others/raymath_vector_angle.c) | raymath_vector_angle | ⭐️⭐️☆☆ | 1.0 | 4.6 | [Ray](https://github.com/raysan5) | As always contributions are welcome, feel free to send new examples! Here is an [examples template](examples_template.c) to start with! diff --git a/examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs b/examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs new file mode 100644 index 000000000..c28124d02 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/rounded_rectangle.fs @@ -0,0 +1,90 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#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 vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + float sdf = roundedRectangleSDF(fragCoord, center, halfSize, radius); + + // Calculate anti-aliased factor + float aa = 1.0 - antiAlias(0.0, -sdf); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/rounded_rectangle_border.fs b/examples/shaders/resources/shaders/glsl100/rounded_rectangle_border.fs new file mode 100644 index 000000000..d19876455 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/rounded_rectangle_border.fs @@ -0,0 +1,91 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#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 vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) +uniform float borderThickness; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's border + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + float sdf = roundedRectangleSDF(fragCoord, center, halfSize, radius); + + // Calculate anti-aliased factor + float aa = antiAlias(borderThickness, -sdf) * (1.0 - antiAlias(0.0, -sdf)); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/rounded_rectangle_shadow.fs b/examples/shaders/resources/shaders/glsl100/rounded_rectangle_shadow.fs new file mode 100644 index 000000000..90a1e5e66 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/rounded_rectangle_shadow.fs @@ -0,0 +1,98 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#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 vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// Shadow parameters +uniform float shadowRadius; +uniform float shadowPower; +uniform vec2 shadowOffset; +uniform float shadowScale; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's shadow + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + + vec2 shadowHalfSize = halfSize*shadowScale; + vec2 shadowCenter = center + shadowOffset; + float sdf = roundedRectangleSDF(fragCoord, shadowCenter, shadowHalfSize, radius); + + float aa = easestep(shadowRadius, 0.0, sdf, shadowPower); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs b/examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs new file mode 100644 index 000000000..70ed29cbd --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/rounded_rectangle.fs @@ -0,0 +1,87 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 120 + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec4 rectangle, + vec4 radius +) +{ + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle + float sdf = roundedRectangleSDF(fragCoord, rectangle, radius); + + // Calculate anti-aliased factor + float aa = 1.0 - antiAlias(0.0, -sdf); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/rounded_rectangle_border.fs b/examples/shaders/resources/shaders/glsl120/rounded_rectangle_border.fs new file mode 100644 index 000000000..66d453d2f --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/rounded_rectangle_border.fs @@ -0,0 +1,89 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 120 + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) +uniform float borderThickness; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's border + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + float sdf = roundedRectangleSDF(fragCoord, center, halfSize, radius); + + // Calculate anti-aliased factor + float aa = antiAlias(borderThickness, -sdf) * (1.0 - antiAlias(0.0, -sdf)); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/rounded_rectangle_shadow.fs b/examples/shaders/resources/shaders/glsl120/rounded_rectangle_shadow.fs new file mode 100644 index 000000000..e06e3fff3 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/rounded_rectangle_shadow.fs @@ -0,0 +1,96 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 120 + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// Shadow parameters +uniform float shadowRadius; +uniform float shadowPower; +uniform vec2 shadowOffset; +uniform float shadowScale; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's shadow + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + + vec2 shadowHalfSize = halfSize*shadowScale; + vec2 shadowCenter = center + shadowOffset; + float sdf = roundedRectangleSDF(fragCoord, shadowCenter, shadowHalfSize, radius); + + float aa = easestep(shadowRadius, 0.0, sdf, shadowPower); + + gl_FragColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/rounded_rectangle.fs b/examples/shaders/resources/shaders/glsl330/rounded_rectangle.fs new file mode 100644 index 000000000..e707aa8c3 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/rounded_rectangle.fs @@ -0,0 +1,90 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// Output fragment color +out vec4 finalColor; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec4 rectangle, + vec4 radius +) +{ + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle + float sdf = roundedRectangleSDF(fragCoord, rectangle, radius); + + // Calculate anti-aliased factor + float aa = 1.0 - antiAlias(0.0, -sdf); + + finalColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/rounded_rectangle_border.fs b/examples/shaders/resources/shaders/glsl330/rounded_rectangle_border.fs new file mode 100644 index 000000000..0e27bee4f --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/rounded_rectangle_border.fs @@ -0,0 +1,92 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// Output fragment color +out vec4 finalColor; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) +uniform float borderThickness; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's border + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + float sdf = roundedRectangleSDF(fragCoord, center, halfSize, radius); + + // Calculate anti-aliased factor + float aa = antiAlias(borderThickness, -sdf) * (1.0 - antiAlias(0.0, -sdf)); + + finalColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/rounded_rectangle_shadow.fs b/examples/shaders/resources/shaders/glsl330/rounded_rectangle_shadow.fs new file mode 100644 index 000000000..d02091292 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/rounded_rectangle_shadow.fs @@ -0,0 +1,99 @@ +// Note: SDF by Iñigo Quilez is licensed under MIT License + +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// Output fragment color +out vec4 finalColor; + +uniform vec4 rectangle; // Rectangle dimensions (x, y, width, height) +uniform vec4 radius; // Corner radius (top-left, top-right, bottom-left, bottom-right) + +// Shadow parameters +uniform float shadowRadius; +uniform float shadowPower; +uniform vec2 shadowOffset; +uniform float shadowScale; + +// TODO: Remove anti-aliasing? + +// Anti-alias using easing function for smmoth edges +uniform float aaPower; +uniform float aaDistance; + +// Ease in-out +float ease(float x, float p) +{ + if (x < 0.5) + { + return 1.0/pow(0.5, p - 1.0)*pow(x, p); + } + else + { + return 1.0 - 1.0/pow(0.5, p - 1.0)*pow(1.0 - x, p); + } +} + +// Smoothstep with easing +float easestep(float edge0, float edge1, float x, float p) +{ + float t = clamp( (x - edge0)/(edge1 - edge0), 0.0, 1.0 ); + return ease(t, p); +} + +// Anti-alias on edge for x +float antiAlias(float edge, float x) +{ + return easestep(edge + aaDistance*0.5, edge - aaDistance*0.5, x, aaPower); +} + +// Create a rounded rectangle using signed distance field +// Thanks to Iñigo Quilez (https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm) +// And thanks to inobelar (https://www.shadertoy.com/view/fsdyzB) for shader +// MIT License +float roundedRectangleSDF( + vec2 fragCoord, + vec2 center, + vec2 halfSize, + vec4 radius +) +{ + vec2 fragFromCenter = fragCoord - center; + + // Determine which corner radius to use + radius.xy = (fragFromCenter.y > 0.0) ? radius.xy : radius.zw; + radius.x = (fragFromCenter.x < 0.0) ? radius.x : radius.y; + + // Calculate signed distance field + vec2 dist = abs(fragFromCenter) - halfSize + radius.x; + return min(max(dist.x, dist.y), 0.0) + length(max(dist, 0.0)) - radius.x; +} + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord); + + // Get fragment coordinate in pixels + vec2 fragCoord = gl_FragCoord.xy; + + // Calculate signed distance field for rounded rectangle's shadow + vec2 halfSize = rectangle.zw*0.5; + vec2 center = rectangle.xy + halfSize; + + vec2 shadowHalfSize = halfSize*shadowScale; + vec2 shadowCenter = center + shadowOffset; + float sdf = roundedRectangleSDF(fragCoord, shadowCenter, shadowHalfSize, radius); + + float aa = easestep(shadowRadius, 0.0, sdf, shadowPower); + + finalColor = texelColor*colDiffuse*fragColor + *vec4(1.0, 1.0, 1.0, aa); +} \ No newline at end of file diff --git a/examples/shaders/shaders_rounded_rectangle.c b/examples/shaders/shaders_rounded_rectangle.c new file mode 100644 index 000000000..9e861c0b2 --- /dev/null +++ b/examples/shaders/shaders_rounded_rectangle.c @@ -0,0 +1,208 @@ +/******************************************************************************************* +* +* raylib [shaders] example - Rounded Rectangle +* +* Example complexity rating: [★★☆☆] 2/4 +* +* Example originally created with raylib 5.5, last time updated with raylib 5.5 +* +* Example contributed by Anstro Pleuton (@anstropleuton) and reviewed by Ramon Santamaria (@raysan5) +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2025-2025 Anstro Pleuton (@anstropleuton) +* +********************************************************************************************/ + +#include "raylib.h" + +#if defined(PLATFORM_DESKTOP) + #define GLSL_VERSION 330 +#else // PLATFORM_ANDROID, PLATFORM_WEB + #define GLSL_VERSION 100 +#endif + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Rounded Rectangle"); + + // Shader loading + //-------------------------------------------------------------------------------------- + // Load the rectangle shader which will draw the rectangle with rounded corners + Shader rectangleShader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION), + TextFormat("resources/shaders/glsl%i/rounded_rectangle.fs", GLSL_VERSION)); + + // Organized into an array for easy access + int rectangleShaderLocs[4] = { + GetShaderLocation(rectangleShader, "rectangle"), // vec4, rectangle bounds (x, y, width, height, NOTE: Y axis is flipped) + GetShaderLocation(rectangleShader, "radius"), // vec4, radius corners (top-left, top-right, bottom-left, bottom-right) + GetShaderLocation(rectangleShader, "aaPower"), // float, anti-aliasing power + GetShaderLocation(rectangleShader, "aaDistance") // float, anti-aliasing distance + }; + + // Load the rectangle shadow shader which will draw the rectangle's shadow + Shader rectangleShadowShader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION), + TextFormat("resources/shaders/glsl%i/rounded_rectangle_shadow.fs", GLSL_VERSION)); + + int rectangleShadowShaderLocs[8] = { + GetShaderLocation(rectangleShadowShader, "rectangle"), // vec4, rectangle bounds (x, y, width, height) + GetShaderLocation(rectangleShadowShader, "radius"), // vec4, radius corners (top-left, top-right, bottom-left, bottom-right) + GetShaderLocation(rectangleShadowShader, "shadowRadius"), // float, shadow radius + GetShaderLocation(rectangleShadowShader, "shadowPower"), // float, shadow power + GetShaderLocation(rectangleShadowShader, "shadowOffset"), // vec2, shadow offset (NOTE: Y axis is flipped) + GetShaderLocation(rectangleShadowShader, "shadowScale"), // float, shadow scale + GetShaderLocation(rectangleShadowShader, "aaPower"), // float, anti-aliasing power + GetShaderLocation(rectangleShadowShader, "aaDistance") // float, anti-aliasing distance + }; + + // Load the rectangle border shader which will draw the rectangle's border + Shader rectangleBorderShader = LoadShader(TextFormat("resources/shaders/glsl%i/base.vs", GLSL_VERSION), + TextFormat("resources/shaders/glsl%i/rounded_rectangle_border.fs", GLSL_VERSION)); + + int rectangleBorderShaderLocs[5] = { + GetShaderLocation(rectangleBorderShader, "rectangle"), // vec4, rectangle bounds (x, y, width, height) + GetShaderLocation(rectangleBorderShader, "radius"), // vec4, radius corners (top-left, top-right, bottom-left, bottom-right) + GetShaderLocation(rectangleBorderShader, "borderThickness"), // float, border thickness + GetShaderLocation(rectangleBorderShader, "aaPower"), // float, anti-aliasing power + GetShaderLocation(rectangleBorderShader, "aaDistance") // float, anti-aliasing distance + }; + //-------------------------------------------------------------------------------------- + + // Set parameters + //-------------------------------------------------------------------------------------- + // Set 4 radius values for the rounded corners in pixels (top-left, top-right, bottom-left, bottom-right) + SetShaderValue(rectangleShader, rectangleShaderLocs[1], (float[]){ 5.0f, 10.0f, 15.0f, 20.0f }, SHADER_UNIFORM_VEC4); + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[1], (float[]){ 5.0f, 10.0f, 15.0f, 20.0f }, SHADER_UNIFORM_VEC4); + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[1], (float[]){ 5.0f, 10.0f, 15.0f, 20.0f }, SHADER_UNIFORM_VEC4); + + // Set shadow parameters (in pixels) + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[2], (float[]){ 20.0f }, SHADER_UNIFORM_FLOAT); // Shadow radius + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[3], (float[]){ 1.5f }, SHADER_UNIFORM_FLOAT); // Shadow power + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[4], (float[]){ 0.0f, -5.0f }, SHADER_UNIFORM_VEC2); // Shadow offset + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[5], (float[]){ 0.95f }, SHADER_UNIFORM_FLOAT); // Shadow scale + + // Set border parameters (in pixels) + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[2], (float[]){ 5.0f }, SHADER_UNIFORM_FLOAT); // Border thickness + + // Set anti-aliasing (power and distance) parameters for all shaders + SetShaderValue(rectangleShader, rectangleShaderLocs[2], (float[]){ 1.5f }, SHADER_UNIFORM_FLOAT); + SetShaderValue(rectangleShader, rectangleShaderLocs[3], (float[]){ 1.0f }, SHADER_UNIFORM_FLOAT); + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[6], (float[]){ 1.5f }, SHADER_UNIFORM_FLOAT); + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[7], (float[]){ 1.0f }, SHADER_UNIFORM_FLOAT); + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[3], (float[]){ 1.5f }, SHADER_UNIFORM_FLOAT); + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[4], (float[]){ 1.0f }, SHADER_UNIFORM_FLOAT); + + //-------------------------------------------------------------------------------------- + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // NOTE: Draw rectangle's shadow first using shader + DrawRectangleLines(30, 50, 150, 100, DARKGRAY); + DrawText("Rectangle shadow shader", 30, 35, 10, DARKGRAY); + + Rectangle rec = { 50, 70, 110, 60 }; + + // Flip Y axis to match shader coordinate system + rec.y = GetScreenHeight() - rec.y - rec.height; + + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleShadowShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKBLUE); + EndShaderMode(); + + // Draw rectangle box with rounded corners using shader + DrawRectangleLines(30, 180, 150, 100, DARKGRAY); + DrawText("Rounded rectangle shader", 30, 165, 10, DARKGRAY); + + rec = (Rectangle){ 50, 200, 110, 60 }; + rec.y = GetScreenHeight() - rec.y - rec.height; + + SetShaderValue(rectangleShader, rectangleShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + EndShaderMode(); + + // Draw rectangle's border using shader + DrawRectangleLines(30, 310, 150, 100, DARKGRAY); + DrawText("Rectangle border shader", 30, 295, 10, DARKGRAY); + + rec = (Rectangle){ 50, 330, 110, 60 }; + rec.y = GetScreenHeight() - rec.y - rec.height; + + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleBorderShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), SKYBLUE); + EndShaderMode(); + + // Draw one more rectangle with all three combined + //-------------------------------------------------------------------------------------------------- + DrawRectangleLines(210, 50, 560, 360, DARKGRAY); + DrawText("Rectangle all three combined", 210, 35, 10, DARKGRAY); + + rec = (Rectangle){ 240, 80, 500, 300 }; + rec.y = GetScreenHeight() - rec.y - rec.height; + + // Draw shadow + SetShaderValue(rectangleShadowShader, rectangleShadowShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleShadowShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKBLUE); + EndShaderMode(); + + // Draw rectangle + SetShaderValue(rectangleShader, rectangleShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + EndShaderMode(); + + // Draw border + SetShaderValue(rectangleBorderShader, rectangleBorderShaderLocs[0], (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4); + + BeginShaderMode(rectangleBorderShader); + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), SKYBLUE); + EndShaderMode(); + //-------------------------------------------------------------------------------------------------- + + DrawText("(c) Rounded rectangle SDF by Iñigo Quilez. MIT License.", GetScreenWidth() - 300, GetScreenHeight() - 20, 10, BLACK); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // Unload shader + UnloadShader(rectangleShader); + UnloadShader(rectangleShadowShader); + UnloadShader(rectangleBorderShader); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/shaders/shaders_rounded_rectangle.png b/examples/shaders/shaders_rounded_rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..0d8c2b5f41e887c4558c2c8c594912ca797e2036 GIT binary patch literal 13936 zcmd6Oc{rPEzwV2+s$GhSAU8Y(4KLQPSEm_j3nDRN%l{?5L>eO>2|bM`*_T*rl6@;=Y=K6&2Xbl>;Si{H&n zcu$-=0RRB+EmI>a0N|1W0FIBxkAd$9yI1spFGrr-yk&D7{E9g45fA;p%HC3tG z_YqQRSJbXcUD421y{3IdUFvr;so$+_;%Bv{06+@3Wpu+PSB8mUM4zFzh))xi}pG+ab%9|hOc1I1kPtGw~ zk|Fq2IF(^O;T+A{Jn6p{O~B` zpBrI7^P=>r;!Ig06;jZF+DDjAu^YPhfM!Gm$1FBFLPgv1{lX{e1}!Vk*J{ z`F=^0s3YH;RO5VBSN(oO^Lfpn&CLk0j66m@6}5l2a!=PkY=ZH$lOeGNIgmYa8rW(# zzT2+778`24Cr}Aqs(jhDpz1&9g!Y%TC<5oU$m0pktN13LaW!+G$wy4}=yJ>AZ;b(O z_mwM^oZ*fdT07_06&Cm@<8!yW87pJUJCzc9xXOE%$87#NL%>kFKflf?@XrH*gGxx95H5ZISHtl z{>2Po4rg{L-DrQBeO2q$ScUjdF`;kMDfMl|;J)H&Ua<3P-XoSB-LuLWE#5Sa*!zAnf-&Rg(l9h& z&;1Nr&;3bg>+AY{hOF7b|I$&u^k4sb1ZgCW9NJue5|;(mGO+*eCmqzzOYT7T~5EP5I) zkP3&18REXCLh^GAU&aamF|G9(97R0m1>n%`7T>4cEe~&+!boOUN{^%dC98)YP4mZyM-QjfKskyk$G;97Lu1R_Y}F-+1o-jNF(%T;CgZqTUDS3@ z*p0#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x64 + + + Release.DLL + Win32 + + + Release.DLL + x64 + + + Release + Win32 + + + Release + x64 + + + + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4} + Win32Proj + shaders_rounded_rectangle + 10.0 + shaders_rounded_rectangle + + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index f4f0600e1..8f3323bc8 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -307,6 +307,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_bone_socket", "examp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_vertex_displacement", "examples\shaders_vertex_displacement.vcxproj", "{CCA63A76-D9FC-4130-9F67-4D97F9770D53}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_rounded_rectangle", "examples\shaders_rounded_rectangle.vcxproj", "{D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug.DLL|x64 = Debug.DLL|x64 @@ -2615,6 +2617,22 @@ Global {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x64.Build.0 = Release|x64 {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x86.ActiveCfg = Release|Win32 {CCA63A76-D9FC-4130-9F67-4D97F9770D53}.Release|x86.Build.0 = Release|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug|x64.ActiveCfg = Debug|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug|x64.Build.0 = Debug|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug|x86.ActiveCfg = Debug|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Debug|x86.Build.0 = Debug|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release.DLL|x64.Build.0 = Release.DLL|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release|x64.ActiveCfg = Release|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release|x64.Build.0 = Release|x64 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release|x86.ActiveCfg = Release|Win32 + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2771,6 +2789,7 @@ Global {0981CA28-E4A5-4DF1-987F-A41D09131EFC} = {6C82BAAE-BDDF-457D-8FA8-7E2490B07035} {3A7FE53D-35F7-49DC-9C9A-A5204A53523F} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C} {CCA63A76-D9FC-4130-9F67-4D97F9770D53} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} + {D3493FFE-8873-4C53-8F6C-74DEF78EA3C4} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}