Sfoglia il codice sorgente

Examples: Improve AO shaders. (#27320)

* GTAOPass: Use higher default depth precision.

* GTAOShader: Try highp sampler2D.

* Examples: Define high sampler precision for AO shaders.

* Examples: Restrict highp samplers to depth only.
Michael Herzog 1 anno fa
parent
commit
0e7ab9f1df

+ 4 - 0
examples/jsm/postprocessing/GTAOPass.js

@@ -4,6 +4,7 @@ import {
 	CustomBlending,
 	DataTexture,
 	DepthTexture,
+	DepthStencilFormat,
 	DstAlphaFactor,
 	DstColorFactor,
 	HalfFloatType,
@@ -15,6 +16,7 @@ import {
 	ShaderMaterial,
 	UniformsUtils,
 	UnsignedByteType,
+	UnsignedInt248Type,
 	WebGLRenderTarget,
 	ZeroFactor
 } from 'three';
@@ -171,6 +173,8 @@ class GTAOPass extends Pass {
 		} else {
 
 			this.depthTexture = new DepthTexture();
+			this.depthTexture.format = DepthStencilFormat;
+			this.depthTexture.type = UnsignedInt248Type;
 			this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
 				minFilter: NearestFilter,
 				magFilter: NearestFilter,

+ 1 - 2
examples/jsm/shaders/GTAOShader.js

@@ -79,10 +79,9 @@ const GTAOShader = {
 		}`,
 
 	fragmentShader: /* glsl */`
-
 		varying vec2 vUv;
 		uniform sampler2D tNormal;
-		uniform sampler2D tDepth;
+		uniform highp sampler2D tDepth;
 		uniform sampler2D tNoise;
 		uniform vec2 resolution;
 		uniform float cameraNear;

+ 1 - 2
examples/jsm/shaders/SAOShader.js

@@ -49,7 +49,6 @@ const SAOShader = {
 		}`,
 
 	fragmentShader: /* glsl */`
-
 		#include <common>
 
 		varying vec2 vUv;
@@ -58,7 +57,7 @@ const SAOShader = {
 		uniform sampler2D tDiffuse;
 		#endif
 
-		uniform sampler2D tDepth;
+		uniform highp sampler2D tDepth;
 		uniform sampler2D tNormal;
 
 		uniform float cameraNear;

+ 1 - 2
examples/jsm/shaders/SSAOShader.js

@@ -49,9 +49,8 @@ const SSAOShader = {
 		}`,
 
 	fragmentShader: /* glsl */`
-
 		uniform sampler2D tNormal;
-		uniform sampler2D tDepth;
+		uniform highp sampler2D tDepth;
 		uniform sampler2D tNoise;
 
 		uniform vec3 kernel[ KERNEL_SIZE ];