فهرست منبع

Moved to range fog

David Catuhe 8 سال پیش
والد
کامیت
e1a73794cf

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/babylon.core.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3012 - 3012
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/babylon.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2 - 2
dist/preview release/babylon.max.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -12,6 +12,7 @@
  - Multi-platform Compressed Textures for Desktops & Mobile Devices with fall back.  Batch (dos) scripts to convert entire directories of .jpg's & .png's ([jcpalmer](https://github.com/Palmer-JC))
 
 ### Updates
+- Engine now uses range based fog ([deltakosh](https://github.com/deltakosh))
 - `VertexBuffer.updatable` is now serialized ([deltakosh](https://github.com/deltakosh))
 - Added intersectsMeshes to Ray ([abow](https://github.com/abow))
 - New RayHelper class for easily viewing and attaching a ray to a mesh.  [Demo](http://www.babylonjs-playground.com/#ZHDBJ#34) - ([abow](https://github.com/abow))

+ 5 - 4
src/Shaders/ShadersInclude/fogFragmentDeclaration.fx

@@ -8,7 +8,7 @@
 
 uniform vec4 vFogInfos;
 uniform vec3 vFogColor;
-varying float fFogDistance;
+varying vec3 vFogDistance;
 
 float CalcFogFactor()
 {
@@ -16,18 +16,19 @@ float CalcFogFactor()
 	float fogStart = vFogInfos.y;
 	float fogEnd = vFogInfos.z;
 	float fogDensity = vFogInfos.w;
+	float fogDistance = length(vFogDistance);
 
 	if (FOGMODE_LINEAR == vFogInfos.x)
 	{
-		fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
+		fogCoeff = (fogEnd - fogDistance) / (fogEnd - fogStart);
 	}
 	else if (FOGMODE_EXP == vFogInfos.x)
 	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
+		fogCoeff = 1.0 / pow(E, fogDistance * fogDensity);
 	}
 	else if (FOGMODE_EXP2 == vFogInfos.x)
 	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
+		fogCoeff = 1.0 / pow(E, fogDistance * fogDistance * fogDensity * fogDensity);
 	}
 
 	return clamp(fogCoeff, 0.0, 1.0);

+ 1 - 1
src/Shaders/ShadersInclude/fogVertex.fx

@@ -1,3 +1,3 @@
 #ifdef FOG
-fFogDistance = abs((view * worldPos).z);
+vFogDistance = (view * worldPos).xyz;
 #endif

+ 1 - 1
src/Shaders/ShadersInclude/fogVertexDeclaration.fx

@@ -1,3 +1,3 @@
 #ifdef FOG
-	varying float fFogDistance;
+	varying vec3 vFogDistance;
 #endif

+ 1 - 1
src/Shaders/sprites.vertex.fx

@@ -46,6 +46,6 @@ void main(void) {
 
 	// Fog
 #ifdef FOG
-	fFogDistance = abs(viewPos.z);
+	vFogDistance = viewPos;
 #endif
 }