[example] Writing into the depth buffer (#2836)

* Add a depth buffer example.

* Fixed a typo
This commit is contained in:
BugraAlptekinSari 2023-01-01 20:17:28 +03:00 committed by GitHub
parent 30b75702df
commit 3cfb9a6e83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 179 additions and 1 deletions

View 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;
}

View 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;
}