SHARE
TWEET
Untitled
a guest
Oct 2nd, 2015
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- // Depth shader
- #VS
- void main() {
- vec4 pos = u_projViewTrans * (u_worldTrans * a_position);
- v_depth = pos.z;
- gl_Position = pos;
- }
- #FS
- void main() {
- float linearDepth = v_depth * (1.0 / (nearfar.y - nearfar.x));
- gl_FragColor = vec4(linearDepth, 0, 0, 0);
- }
- // Shader.java
- setUniformMatrix("u_invProjView", cam.combined.cpy().inv());
- // Shader.frag
- ### Reconstruction from depth
- vec3 getPosition(in vec2 uv) {
- depthv = texture2D(texture0, uv).x;
- //float depth = (2.0 * nearfar.x) / (nearfar.y + nearfar.x - depthv* (nearfar.y - u_frustumNearFar.x));
- // #### IS this right? ####
- vec4 pos = vec4(uv, depthv, 1.0)*2.0-1.0;
- pos = u_invProjView * pos;
- pos = pos/pos.w;
- return pos.xyz;
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

