• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

### #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,

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