Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actuallipsryme

Posted 22 January 2013 - 06:21 PM

Yeah sorry, I switched the N and V before for testing when calculating the reflection vector.
Still the ground looks like this (it's just this small part in the middle that doesn't get the reflection):
http://d.pr/i/QXfU

 

Here are the parts that are important for the env reflection:

 

	// Calculate Position from linear view space depth
	float3 ViewRay = input.ViewRay.xyz;
	float depth = DepthTarget.Sample(PointSampler, UV).r;
	float linearDepth = ProjectionB / (depth - ProjectionA);
	float3 ViewDir = ViewRay * linearDepth; // View space position
	float3 V = normalize(ViewDir) * -1.0f;
	float3 V_WS = mul(V, (float3x3)InverseView);
	V_WS = normalize(V_WS);

// Retrieve Specular Power [2-2048]
	float SpecPow = exp2(10.0f * AlbedoTarget.SampleLevel(PointSampler, UV, 0).a + 1.0f);

	// Sample reflection from environment probe
	float3 R = reflect(N_WS, V_WS);

	// Pick MipLevel depending on glossiness
	float mipLevel = -1.66096404744368 * log(SpecPow) + 5.5; // log(SpecPow / 2048.0f) / log(0.25f);
	float3 reflectionColor = ToLinear(EnvironmentProbe.SampleLevel(LinearSampler, R, mipLevel).rgb).rgb;


	// Compute Fresnel Term (F) using Schlick's approximation
	float NdotV = dot(N_WS, V_WS);
	float3 FresnelReflectance = ToLinear(float3(0.3f, 0.3f, 0.3f));
	float3 F_schlick = FresnelReflectance + ((1.0f - FresnelReflectance) * pow(1.0f - NdotV, 5.0f));
	reflectionColor *= F_schlick;

		// Accumulate results of BRDF and Ambient lighting for regular objects
		lighting.rgb = MicrofacetBRDF(N, LightDir, V, DiffuseAlbedo, SpecPow,
								      ambientOcclusion, Attenuation, shadowFactor).rgb;

		lighting.rgb += reflectionColor;

 

 


#1lipsryme

Posted 22 January 2013 - 06:14 PM

Yeah sorry, I switched the N and V before for testing when calculating the reflection vector.

Still the ground looks like this (it's just this small part in the middle that doesn't get the reflection):

http://d.pr/i/QXfU


PARTNERS