Sfoglia il codice sorgente

Merge branch 'dev' into bumpmap

alteredq 13 anni fa
parent
commit
9391780293
3 ha cambiato i file con 16 aggiunte e 5 eliminazioni
  1. 0 2
      build/Three.js
  2. 0 2
      build/custom/ThreeExtras.js
  3. 16 1
      src/extras/ShaderUtils.js

File diff suppressed because it is too large
+ 0 - 2
build/Three.js


File diff suppressed because it is too large
+ 0 - 2
build/custom/ThreeExtras.js


+ 16 - 1
src/extras/ShaderUtils.js

@@ -132,6 +132,8 @@ THREE.ShaderUtils = {
 				"uShininess": { type: "f", value: 30 },
 				"uOpacity": { type: "f", value: 1 },
 
+				"useRefract": { type: "i", value: 0 },
+				"uRefractionRatio": { type: "f", value: 0.98 },
 				"uReflectivity": { type: "f", value: 0.5 },
 
 				"uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) },
@@ -164,6 +166,9 @@ THREE.ShaderUtils = {
 				"uniform samplerCube tCube;",
 
 				"uniform float uNormalScale;",
+
+				"uniform bool useRefract;",
+				"uniform float uRefractionRatio;",
 				"uniform float uReflectivity;",
 
 				"varying vec3 vTangent;",
@@ -485,7 +490,17 @@ THREE.ShaderUtils = {
 
 					"if ( enableReflection ) {",
 
-						"vec3 vReflect = reflect( normalize( vWorldPosition ), normal );",
+						"vec3 vReflect;",
+
+						"if ( useRefract ) {",
+
+							"vReflect = refract( normalize( vWorldPosition - cameraPosition ), normal, uRefractionRatio );",
+
+						"} else {",
+
+							"vReflect = reflect( normalize( vWorldPosition - cameraPosition ), normal );",
+
+						"}",
 
 						"vec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
 

Some files were not shown because too many files changed in this diff