diff options
| author | BugraAlptekinSari <[email protected]> | 2023-01-01 20:17:28 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-01 18:17:28 +0100 |
| commit | 3cfb9a6e83af9a94a2d1d57dd6bbfba738c09b2a (patch) | |
| tree | 1f787d5563e2d2e9e2d2a93b41cdd4a9175a4d62 /examples/shaders/resources | |
| parent | 30b75702df9d5d8f1ce2b9c7911b05e992b777f5 (diff) | |
| download | raylib-3cfb9a6e83af9a94a2d1d57dd6bbfba738c09b2a.tar.gz raylib-3cfb9a6e83af9a94a2d1d57dd6bbfba738c09b2a.zip | |
[example] Writing into the depth buffer (#2836)
* Add a depth buffer example.
* Fixed a typo
Diffstat (limited to 'examples/shaders/resources')
| -rw-r--r-- | examples/shaders/resources/shaders/glsl100/write_depth.fs | 15 | ||||
| -rw-r--r-- | examples/shaders/resources/shaders/glsl330/write_depth.fs | 13 |
2 files changed, 28 insertions, 0 deletions
diff --git a/examples/shaders/resources/shaders/glsl100/write_depth.fs b/examples/shaders/resources/shaders/glsl100/write_depth.fs new file mode 100644 index 00000000..5167efb8 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/write_depth.fs @@ -0,0 +1,15 @@ +#version 100 +#extension GL_EXT_frag_depth : enable +precision mediump float; // Precision required for OpenGL ES2 (WebGL) + +varying vec2 fragTexCoord; +varying vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; +void main() +{ + vec4 texelColor = texture2D(texture0, fragTexCoord); + gl_FragColor = texelColor*colDiffuse*fragColor; + gl_FragDepthEXT = 1.0 - gl_FragCoord.z; +}
\ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/write_depth.fs b/examples/shaders/resources/shaders/glsl330/write_depth.fs new file mode 100644 index 00000000..36c70fe4 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/write_depth.fs @@ -0,0 +1,13 @@ +#version 330 + +in vec2 fragTexCoord; +in vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; +void main() +{ + vec4 texelColor = texture2D(texture0, fragTexCoord); + gl_FragColor = texelColor*colDiffuse*fragColor; + gl_FragDepth = 1.0 - gl_FragCoord.z; +}
\ No newline at end of file |
