瀏覽代碼

Updated shaders for EnvColor.

Mark Sibly 8 年之前
父節點
當前提交
403595d0c4

+ 4 - 1
modules/mojo3d/graphics/shaders/material-pbr-deferred.glsl

@@ -25,6 +25,7 @@ uniform mat3 i_ModelViewNormalMatrix;
 
 uniform vec4 r_AmbientDiffuse;
 uniform samplerCube r_EnvTexture;
+uniform vec4 r_EnvColor;
 uniform mat3 r_EnvMatrix;
 
 //pbr varyings...
@@ -195,7 +196,7 @@ void pbrWriteFragData( vec3 color,vec3 emissive,float metalness,float roughness,
 	
 	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
 	
-	vec3 env=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) );
+	vec3 env=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
 
 	vec3 vvec=normalize( -v_Position );
 	
@@ -245,6 +246,8 @@ void main(){
 	float roughness=texture2D( m_RoughnessTexture,v_TexCoord0 ).g * m_RoughnessFactor;
 	float occlusion=texture2D( m_OcclusionTexture,v_TexCoord0 ).r;
 	
+//	emissive=vec3( 1.0,1.0,0.0 );
+	
 #ifdef MX2_BUMPMAPPED
 	vec3 normal=texture2D( m_NormalTexture,v_TexCoord0 ).xyz * 2.0 - 1.0;
 	normal=normalize( v_TanMatrix * normal );

+ 3 - 1
modules/mojo3d/graphics/shaders/material-pbr-forward.glsl

@@ -38,8 +38,10 @@ uniform mat3 m_TextureMatrix;
 //
 uniform vec4 r_AmbientDiffuse;
 uniform samplerCube r_EnvTexture;
+uniform vec4 r_EnvColor;
 uniform mat3 r_EnvMatrix;
 
+
 #endif
 
 #if MX2_LIGHTINGPASS
@@ -281,7 +283,7 @@ vec3 fragColor( vec3 color,vec3 emissive,float metalness,float roughness,float o
 	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
 	float lod=textureCube( r_EnvTexture,rvec,10.0 ).a * 255.0 - 10.0;
 	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-	vec3 ambenv=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) );
+	vec3 ambenv=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
 	
 	float ndotv=max( dot( normal,vvec ),0.0 );