Commits

davep committed 9312199

SH-1912 Add environment map back into shiny when lighting and shadows enabled.

Comments (0)

Files changed (5)

indra/llrender/llrender.cpp

 	return mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]];
 }
 
+const glh::matrix4f& LLRender::getProjectionMatrix()
+{
+	return mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]];
+}
+
 void LLRender::translateUI(F32 x, F32 y, F32 z)
 {
 	if (mUIOffset.empty())

indra/llrender/llrender.h

 	void matrixMode(U32 mode);	
 
 	const glh::matrix4f& getModelviewMatrix();
+	const glh::matrix4f& getProjectionMatrix();
 
 	void syncMatrices();
 	void syncLightState();

indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl

 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
 uniform sampler2DRect depthMap;
-uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
 
 uniform vec4 max_y;
 uniform vec4 glow;
 uniform float scene_light_strength;
-uniform vec3 env_mat[3];
-//uniform mat4 shadow_matrix[3];
-//uniform vec4 shadow_clip;
+uniform mat3 env_mat;
 uniform mat3 ssao_effect_mat;
 
 uniform vec3 sun_dir;
 	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
-	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
-	
+		
 	float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
 	
 	vec4 diffuse = texture2DRect(diffuseRect, tc);
 			vec3 spec_contrib = dumbshiny * spec.rgb;
 			bloom = dot(spec_contrib, spec_contrib);
 			col += spec_contrib;
+
+			//add environmentmap
+			vec3 env_vec = env_mat * refnormpersp;
+			col += textureCube(environmentMap, env_vec).rgb * max(spec.a-diffuse.a-0.2, 0.0); 
 		}
 	
 		col = atmosLighting(col);

indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl

 uniform sampler2DRect normalMap;
 uniform sampler2DRect lightMap;
 uniform sampler2DRect depthMap;
-uniform sampler2D	  noiseMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
 uniform vec3 gi_quad;
 uniform vec4 max_y;
 uniform vec4 glow;
 uniform float scene_light_strength;
-uniform vec3 env_mat[3];
+uniform mat3 env_mat;
 uniform vec4 shadow_clip;
 uniform mat3 ssao_effect_mat;
 
 	vec3 pos = getPosition_d(tc, depth).xyz;
 	vec3 norm = texture2DRect(normalMap, tc).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
-	//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
-	
+		
 	float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
 	
 	vec4 diffuse = texture2DRect(diffuseRect, tc);
 			vec3 spec_contrib = dumbshiny * spec.rgb;
 			bloom = dot(spec_contrib, spec_contrib);
 			col += spec_contrib;
+
+			//add environmentmap
+			vec3 env_vec = env_mat * refnormpersp;
+			col += textureCube(environmentMap, env_vec).rgb * max(spec.a-diffuse.a-0.2, 0.0); 
 		}
 			
 		col = atmosLighting(col);

indra/newview/pipeline.cpp

 			cube_map->enable(channel);
 			cube_map->bind();
 			F32* m = gGLModelView;
-
-			
+						
 			F32 mat[] = { m[0], m[1], m[2],
 						  m[4], m[5], m[6],
 						  m[8], m[9], m[10] };
 		
-			shader.uniform3fv(LLShaderMgr::DEFERRED_ENV_MAT, 3, mat);
+			shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, TRUE, mat);
 		}
 	}