Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depth texture example: changed to white-nearest #13487

Merged
merged 1 commit into from
Mar 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/webgl_depth_texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@
uniform float cameraFar;


float readDepth (sampler2D depthSampler, vec2 coord) {
float fragCoordZ = texture2D(depthSampler, coord).x;
float readDepth( sampler2D depthSampler, vec2 coord ) {
float fragCoordZ = texture2D( depthSampler, coord ).x;
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
}

void main() {
vec3 diffuse = texture2D(tDiffuse, vUv).rgb;
float depth = readDepth(tDepth, vUv);
//vec3 diffuse = texture2D( tDiffuse, vUv ).rgb;
float depth = readDepth( tDepth, vUv );

gl_FragColor.rgb = vec3(depth);
gl_FragColor.rgb = 1.0 - vec3( depth );
gl_FragColor.a = 1.0;
}
</script>
Expand Down Expand Up @@ -128,7 +128,7 @@
document.body.appendChild( stats.dom );

camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 50 );
camera.position.z = -4;
camera.position.z = 4;

var controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.enableDamping = true;
Expand Down Expand Up @@ -161,7 +161,7 @@
function setupPost () {

// Setup post processing stage
postCamera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
postCamera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
var postMaterial = new THREE.ShaderMaterial( {
vertexShader: document.querySelector( '#post-vert' ).textContent.trim(),
fragmentShader: document.querySelector( '#post-frag' ).textContent.trim(),
Expand All @@ -181,8 +181,8 @@

function setupScene () {

var diffuse = new THREE.TextureLoader().load( 'textures/brick_diffuse.jpg' );
diffuse.wrapS = diffuse.wrapT = THREE.RepeatWrapping;
//var diffuse = new THREE.TextureLoader().load( 'textures/brick_diffuse.jpg' );
//diffuse.wrapS = diffuse.wrapT = THREE.RepeatWrapping;

// Setup some geometries
var geometry = new THREE.TorusKnotBufferGeometry( 1, 0.3, 128, 64 );
Expand Down