mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
[example] Writing into the depth buffer (#2836)
* Add a depth buffer example. * Fixed a typo
This commit is contained in:
committed by
GitHub
parent
30b75702df
commit
3cfb9a6e83
15
examples/shaders/resources/shaders/glsl100/write_depth.fs
Normal file
15
examples/shaders/resources/shaders/glsl100/write_depth.fs
Normal file
@ -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;
|
||||
}
|
||||
13
examples/shaders/resources/shaders/glsl330/write_depth.fs
Normal file
13
examples/shaders/resources/shaders/glsl330/write_depth.fs
Normal file
@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user