Przeglądaj źródła

Merge pull request #801 from julien-moreau/master

Added wind influence on waves for water material
David Catuhe 9 lat temu
rodzic
commit
2509950937

Plik diff jest za duży
+ 1 - 1
materialsLibrary/dist/babylon.waterMaterial.js


+ 2 - 1
materialsLibrary/materials/water/water.vertex.fx

@@ -184,7 +184,8 @@ void main(void) {
 #endif
 
 	vec3 p = position;
-	float newY = (sin(((p.x / 0.05) + time * 100.0)) * waveHeight * 5.0) + (cos(((p.z / 0.05) + time * 100.0)) * waveHeight * 5.0);
+	float newY = (sin(((p.x / 0.05) + time * windForce) * windDirection.x) * waveHeight * 5.0)
+			   + (cos(((p.z / 0.05) + time * windForce) * windDirection.y) * waveHeight * 5.0);
 	p.y += abs(newY);
 	
 	gl_Position = viewProjection * finalWorld * vec4(p, 1.0);

+ 1 - 0
materialsLibrary/test/index.html

@@ -161,6 +161,7 @@
 				water.bumpTexture = new BABYLON.Texture("textures/waterbump.png", scene);
 				water.windForce = -45;
 				water.waveHeight = 1.3;
+				water.windDirection = new BABYLON.Vector2(1, 1);
 				water.addToRenderList(skybox);
 				water.addToRenderList(shadowCaster);
 				water.addToRenderList(shadowCaster2);