Просмотр исходного кода

Reflector: Add support for logarithmic depth buffer. (#21983)

Michael Herzog 4 лет назад
Родитель
Сommit
028fb95b47
2 измененных файлов с 18 добавлено и 0 удалено
  1. 9 0
      examples/js/objects/Reflector.js
  2. 9 0
      examples/jsm/objects/Reflector.js

+ 9 - 0
examples/js/objects/Reflector.js

@@ -158,12 +158,17 @@
 		uniform mat4 textureMatrix;
 		varying vec4 vUv;
 
+		#include <common>
+		#include <logdepthbuf_pars_vertex>
+
 		void main() {
 
 			vUv = textureMatrix * vec4( position, 1.0 );
 
 			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
 
+			#include <logdepthbuf_vertex>
+
 		}`,
 		fragmentShader:
   /* glsl */
@@ -172,6 +177,8 @@
 		uniform sampler2D tDiffuse;
 		varying vec4 vUv;
 
+		#include <logdepthbuf_pars_fragment>
+
 		float blendOverlay( float base, float blend ) {
 
 			return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
@@ -186,6 +193,8 @@
 
 		void main() {
 
+			#include <logdepthbuf_fragment>
+
 			vec4 base = texture2DProj( tDiffuse, vUv );
 			gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
 

+ 9 - 0
examples/jsm/objects/Reflector.js

@@ -221,12 +221,17 @@ Reflector.ReflectorShader = {
 		uniform mat4 textureMatrix;
 		varying vec4 vUv;
 
+		#include <common>
+		#include <logdepthbuf_pars_vertex>
+
 		void main() {
 
 			vUv = textureMatrix * vec4( position, 1.0 );
 
 			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
 
+			#include <logdepthbuf_vertex>
+
 		}`,
 
 	fragmentShader: /* glsl */`
@@ -234,6 +239,8 @@ Reflector.ReflectorShader = {
 		uniform sampler2D tDiffuse;
 		varying vec4 vUv;
 
+		#include <logdepthbuf_pars_fragment>
+
 		float blendOverlay( float base, float blend ) {
 
 			return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
@@ -248,6 +255,8 @@ Reflector.ReflectorShader = {
 
 		void main() {
 
+			#include <logdepthbuf_fragment>
+
 			vec4 base = texture2DProj( tDiffuse, vUv );
 			gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );