浏览代码

fixed bump fragment

Benjamin Guignabert 8 年之前
父节点
当前提交
eac276a6e6

文件差异内容过多而无法显示
+ 5995 - 5995
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 5995 - 5995
dist/preview release/babylon.module.d.ts


+ 12 - 7
index.html

@@ -65,13 +65,18 @@
 								sphere.position.z = - squareSize / 4 + j / 2;
 								sphere.position.x = - squareSize / 4 + i / 2;
 								sphere.position.y = - squareSize / 4 + k / 2;
-								sphere.material = new BABYLON.StandardMaterial("test");
-								sphere.material.diffuseTexture = new BABYLON.Texture("test.jpeg", scene);
-								sphere.material.bumpTexture = new BABYLON.Texture("test.jpeg", scene);
-								sphere.material.diffuseColor = new BABYLON.Color3(Math.random(), Math.random(), Math.random());
-								sphere.material.specularColor = new BABYLON.Color3(Math.random() < 0.8 ? 0 : 1, Math.random() < 0.8 ? 0 : 1, Math.random() < 0.8 ? 0 : 1);
-								sphere.material.emissiveColor = new BABYLON.Color3(0, 0, 0);
-								sphere.material.freeze();
+								if (j === 0) {
+									sphere.material = new BABYLON.StandardMaterial("test");
+									sphere.material.diffuseTexture = new BABYLON.Texture("test.jpeg", scene);
+									sphere.material.bumpTexture = new BABYLON.Texture("test.jpeg", scene);
+									sphere.material.diffuseColor = new BABYLON.Color3(Math.random(), Math.random(), Math.random());
+									sphere.material.specularColor = new BABYLON.Color3(Math.random() < 0.8 ? 0 : 1, Math.random() < 0.8 ? 0 : 1, Math.random() < 0.8 ? 0 : 1);
+									sphere.material.emissiveColor = new BABYLON.Color3(0, 0, 0);
+									sphere.material.freeze();
+								}
+								else {
+									sphere.material = spheres[0].material;
+								}
 								sphere.freezeWorldMatrix();
 								spheres.push(sphere);
 							}

+ 3 - 3
src/Shaders/ShadersInclude/bumpFragment.fx

@@ -4,7 +4,7 @@
 	#if defined(TANGENT) && defined(NORMAL)
 		mat3 TBN = vTBN;
 	#else
-		mat3 TBN = cotangent_frame(normalW * vBumpInfos.y, vPositionW, vBumpUV);
+		mat3 TBN = cotangent_frame(normalW * uMaterial.vBumpInfos.y, vPositionW, vBumpUV);
 	#endif
 #endif
 
@@ -12,9 +12,9 @@
 	mat3 invTBN = transposeMat3(TBN);
 
 	#ifdef PARALLAXOCCLUSION
-		uvOffset = parallaxOcclusion(invTBN * -viewDirectionW, invTBN * normalW, vBumpUV, vBumpInfos.z);
+		uvOffset = parallaxOcclusion(invTBN * -viewDirectionW, invTBN * normalW, vBumpUV, uMaterial.vBumpInfos.z);
 	#else
-		uvOffset = parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z);
+		uvOffset = parallaxOffset(invTBN * viewDirectionW, uMaterial.vBumpInfos.z);
 	#endif
 #endif
 

+ 0 - 1
src/Shaders/ShadersInclude/bumpFragmentFunctions.fx

@@ -1,6 +1,5 @@
 #ifdef BUMP
 	varying vec2 vBumpUV;
-	vec3 vBumpInfos = uMaterial.vBumpInfos;
 	uniform sampler2D bumpSampler;
 #if defined(TANGENT) && defined(NORMAL) 
 	varying mat3 vTBN;