[example] Writing into the depth buffer (#2836)
* Add a depth buffer example. * Fixed a typo
This commit is contained in:
parent
30b75702df
commit
3cfb9a6e83
4 changed files with 179 additions and 1 deletions
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue