浏览代码

pointSize include

David Catuhe 9 年之前
父节点
当前提交
5a41f0eca9

文件差异内容过多而无法显示
+ 8 - 8
dist/preview release/babylon.core.js


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


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


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/babylon.noworker.js


+ 1 - 4
materialsLibrary/dist/babylon.normalMaterial.js

@@ -243,10 +243,7 @@ var BABYLON;
                     this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
                 }
                 // Clip plane
-                if (scene.clipPlane) {
-                    var clipPlane = scene.clipPlane;
-                    this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
-                }
+                BABYLON.MaterialHelper.BindClipPlane(this._effect, scene);
                 // Point size
                 if (this.pointsCloud) {
                     this._effect.setFloat("pointSize", this.pointSize);

文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.normalMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.pbrMaterial.js


文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.pbrMaterial.min.js


+ 1 - 4
materialsLibrary/dist/babylon.simpleMaterial.js

@@ -244,10 +244,7 @@ var BABYLON;
                     this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
                 }
                 // Clip plane
-                if (scene.clipPlane) {
-                    var clipPlane = scene.clipPlane;
-                    this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
-                }
+                BABYLON.MaterialHelper.BindClipPlane(this._effect, scene);
                 // Point size
                 if (this.pointsCloud) {
                     this._effect.setFloat("pointSize", this.pointSize);

文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.simpleMaterial.min.js


+ 2 - 68
materialsLibrary/materials/pbr/pbr.fragment.fx

@@ -367,13 +367,7 @@ uniform sampler2D reflectivitySampler;
 #endif
 
 // Fresnel
-#ifdef FRESNEL
-float computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)
-{
-    float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);
-    return clamp(fresnelTerm, 0., 1.);
-}
-#endif
+#include<fresnelFunction>
 
 #ifdef OPACITYFRESNEL
 uniform vec4 opacityParts;
@@ -423,67 +417,7 @@ varying vec3 vPositionUVW;
     #endif
 #endif
 
-vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
-{
-#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
-    vec3 direction = normalize(vDirectionW);
-
-    float t = clamp(direction.y * -0.5 + 0.5, 0., 1.0);
-    float s = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;
-
-    return vec3(s, t, 0);
-#endif
-
-#ifdef REFLECTIONMAP_EQUIRECTANGULAR
-
-	vec3 cameraToVertex = normalize(worldPos.xyz - vEyePosition);
-	vec3 r = reflect(cameraToVertex, worldNormal);
-	float t = clamp(r.y * -0.5 + 0.5, 0., 1.0);
-	float s = atan(r.z, r.x) * RECIPROCAL_PI2 + 0.5;
-
-	return vec3(s, t, 0);
-#endif
-
-#ifdef REFLECTIONMAP_SPHERICAL
-    vec3 viewDir = normalize(vec3(view * worldPos));
-    vec3 viewNormal = normalize(vec3(view * vec4(worldNormal, 0.0)));
-
-    vec3 r = reflect(viewDir, viewNormal);
-    r.z = r.z - 1.0;
-
-    float m = 2.0 * length(r);
-
-    return vec3(r.x / m + 0.5, 1.0 - r.y / m - 0.5, 0);
-#endif
-
-#ifdef REFLECTIONMAP_PLANAR
-    vec3 viewDir = worldPos.xyz - vEyePosition;
-    vec3 coords = normalize(reflect(viewDir, worldNormal));
-
-    return vec3(reflectionMatrix * vec4(coords, 1));
-#endif
-
-#ifdef REFLECTIONMAP_CUBIC
-    vec3 viewDir = worldPos.xyz - vEyePosition;
-    vec3 coords = reflect(viewDir, worldNormal);
-#ifdef INVERTCUBICMAP
-    coords.y = 1.0 - coords.y;
-#endif
-    return vec3(reflectionMatrix * vec4(coords, 0));
-#endif
-
-#ifdef REFLECTIONMAP_PROJECTION
-    return vec3(reflectionMatrix * (view * worldPos));
-#endif
-
-#ifdef REFLECTIONMAP_SKYBOX
-    return vPositionUVW;
-#endif
-
-#ifdef REFLECTIONMAP_EXPLICIT
-    return vec3(0, 0, 0);
-#endif
-}
+#include<reflectionFunction>
 
 #endif
 

文件差异内容过多而无法显示
+ 2 - 2
materialsLibrary/test/refs/babylon.max.js


+ 7 - 0
src/Shaders/ShadersInclude/fresnelFunction.fx

@@ -0,0 +1,7 @@
+#ifdef FRESNEL
+	float computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)
+	{
+		float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);
+		return clamp(fresnelTerm, 0., 1.);
+	}
+#endif

+ 3 - 0
src/Shaders/ShadersInclude/pointCloudVertex.fx

@@ -0,0 +1,3 @@
+#ifdef POINTSIZE
+	gl_PointSize = pointSize;
+#endif

+ 3 - 0
src/Shaders/ShadersInclude/pointCloudVertexDeclaration.fx

@@ -0,0 +1,3 @@
+#ifdef POINTSIZE
+	uniform float pointSize;
+#endif

+ 61 - 0
src/Shaders/ShadersInclude/reflectionFunction.fx

@@ -0,0 +1,61 @@
+vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
+{
+#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
+	vec3 direction = normalize(vDirectionW);
+
+	float t = clamp(direction.y * -0.5 + 0.5, 0., 1.0);
+	float s = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;
+
+	return vec3(s, t, 0);
+#endif
+
+#ifdef REFLECTIONMAP_EQUIRECTANGULAR
+
+	vec3 cameraToVertex = normalize(worldPos.xyz - vEyePosition);
+	vec3 r = reflect(cameraToVertex, worldNormal);
+	float t = clamp(r.y * -0.5 + 0.5, 0., 1.0);
+	float s = atan(r.z, r.x) * RECIPROCAL_PI2 + 0.5;
+
+	return vec3(s, t, 0);
+#endif
+
+#ifdef REFLECTIONMAP_SPHERICAL
+	vec3 viewDir = normalize(vec3(view * worldPos));
+	vec3 viewNormal = normalize(vec3(view * vec4(worldNormal, 0.0)));
+
+	vec3 r = reflect(viewDir, viewNormal);
+	r.z = r.z - 1.0;
+
+	float m = 2.0 * length(r);
+
+	return vec3(r.x / m + 0.5, 1.0 - r.y / m - 0.5, 0);
+#endif
+
+#ifdef REFLECTIONMAP_PLANAR
+	vec3 viewDir = worldPos.xyz - vEyePosition;
+	vec3 coords = normalize(reflect(viewDir, worldNormal));
+
+	return vec3(reflectionMatrix * vec4(coords, 1));
+#endif
+
+#ifdef REFLECTIONMAP_CUBIC
+	vec3 viewDir = worldPos.xyz - vEyePosition;
+	vec3 coords = reflect(viewDir, worldNormal);
+#ifdef INVERTCUBICMAP
+	coords.y = 1.0 - coords.y;
+#endif
+	return vec3(reflectionMatrix * vec4(coords, 0));
+#endif
+
+#ifdef REFLECTIONMAP_PROJECTION
+	return vec3(reflectionMatrix * (view * worldPos));
+#endif
+
+#ifdef REFLECTIONMAP_SKYBOX
+	return vPositionUVW;
+#endif
+
+#ifdef REFLECTIONMAP_EXPLICIT
+	return vec3(0, 0, 0);
+#endif
+}

+ 2 - 68
src/Shaders/default.fragment.fx

@@ -97,13 +97,7 @@ uniform sampler2D specularSampler;
 #endif
 
 // Fresnel
-#ifdef FRESNEL
-float computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)
-{
-	float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);
-	return clamp(fresnelTerm, 0., 1.);
-}
-#endif
+#include<fresnelFunction>
 
 #ifdef DIFFUSEFRESNEL
 uniform vec4 diffuseLeftColor;
@@ -141,67 +135,7 @@ uniform mat4 reflectionMatrix;
 #endif
 #endif
 
-vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
-{
-#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
-	vec3 direction = normalize(vDirectionW);
-
-	float t = clamp(direction.y * -0.5 + 0.5, 0., 1.0);
-	float s = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;
-
-	return vec3(s, t, 0);
-#endif
-
-#ifdef REFLECTIONMAP_EQUIRECTANGULAR
-
-	vec3 cameraToVertex = normalize(worldPos.xyz - vEyePosition);
-	vec3 r = reflect(cameraToVertex, worldNormal);
-	float t = clamp(r.y * -0.5 + 0.5, 0., 1.0);
-	float s = atan(r.z, r.x) * RECIPROCAL_PI2 + 0.5;
-
-	return vec3(s, t, 0);
-#endif
-
-#ifdef REFLECTIONMAP_SPHERICAL
-	vec3 viewDir = normalize(vec3(view * worldPos));
-	vec3 viewNormal = normalize(vec3(view * vec4(worldNormal, 0.0)));
-
-	vec3 r = reflect(viewDir, viewNormal);
-	r.z = r.z - 1.0;
-
-	float m = 2.0 * length(r);
-
-	return vec3(r.x / m + 0.5, 1.0 - r.y / m - 0.5, 0);
-#endif
-
-#ifdef REFLECTIONMAP_PLANAR
-	vec3 viewDir = worldPos.xyz - vEyePosition;
-	vec3 coords = normalize(reflect(viewDir, worldNormal));
-
-	return vec3(reflectionMatrix * vec4(coords, 1));
-#endif
-
-#ifdef REFLECTIONMAP_CUBIC
-	vec3 viewDir = worldPos.xyz - vEyePosition;
-	vec3 coords = reflect(viewDir, worldNormal);
-#ifdef INVERTCUBICMAP
-	coords.y = 1.0 - coords.y;
-#endif
-	return vec3(reflectionMatrix * vec4(coords, 0));
-#endif
-
-#ifdef REFLECTIONMAP_PROJECTION
-	return vec3(reflectionMatrix * (view * worldPos));
-#endif
-
-#ifdef REFLECTIONMAP_SKYBOX
-	return vPositionUVW;
-#endif
-
-#ifdef REFLECTIONMAP_EXPLICIT
-	return vec3(0, 0, 0);
-#endif
-}
+#include<reflectionFunction>
 
 #ifdef REFLECTIONFRESNEL
 uniform vec4 reflectionLeftColor;

+ 2 - 8
src/Shaders/default.vertex.fx

@@ -65,9 +65,7 @@ uniform vec2 vBumpInfos;
 uniform mat4 bumpMatrix;
 #endif
 
-#ifdef POINTSIZE
-uniform float pointSize;
-#endif
+#include<pointCloudVertexDeclaration>
 
 // Output
 varying vec3 vPositionW;
@@ -209,11 +207,7 @@ void main(void) {
 	vColor = color;
 #endif
 
-	// Point size
-#ifdef POINTSIZE
-	gl_PointSize = pointSize;
-#endif
-
+#include<pointCloudVertex>
 #include<logDepthVertex>
 
 }

+ 1 - 7
src/Shaders/legacydefault.fragment.fx

@@ -70,13 +70,7 @@ uniform sampler2D specularSampler;
 #endif
 
 // Fresnel
-#ifdef FRESNEL
-float computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)
-{
-	float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);
-	return clamp(fresnelTerm, 0., 1.);
-}
-#endif
+#include<fresnelFunction>
 
 #ifdef DIFFUSEFRESNEL
 uniform vec4 diffuseLeftColor;