Jump to content

Using gl_FragDepth in WebGL

TheAnonymousPoster

I am writing a 3D application in webgl, and need to provide my own depth data that is contained within a texture, my current code does this:

VS:

varying vec2 vUv;

void main() {
vUv = uv;
}

FS:

uniform sampler2D depthTex;

varying vec2 vUv;

void main() {
gl_FragDepth = texture2D(depthTex, vUv).r;
}

however gl_FragDepth is disabled in opengl-es (and therefor webgl) is there anyway to somehow enable it, or any way to provide my own depth data that doesnt involve heavy manipulation of render targets?

Asrock X79 Extreme4-M || Intel i7-3930K @ 4.5GHz  || EVGA GTX 780Ti SC || 32Gb Kington hyperX|| Modded Corsair 350D || Intel 530 SSD 512Gb || 2x WD Caviar Black 2TB || Corsair H100I || NZXT HUE || Custom Sleeved BeQuiet P9 600 Watt 


HTC ONE || Asus Zenbook UX302LG

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×