Screen space glossy reflections - viewRay calculation

This topic is 388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, i'm currently implementing http://roar11.com/2015/07/screen-space-glossy-reflections/.

But i don't know how to calc viewRay.

here is my solution much different from example, it works but look bad at edge of screen.

	float3 viewRay = normalize(VSPositionFromDepth(input.tex.xy, depth, sslr_invProjMatrix));
float3 rayOriginVS = viewRay * LinearDepth(depth);

/*
* Since position is reconstructed in view space, just normalize it to get the
* vector from the eye to the position and then reflect that around the normal to
* get the ray direction to trace.
*/

float3 toPositionVS = normalize(worldPosition.xyz - camPosition.xyz);
float3 rayDirectionVS = normalize(reflect(toPositionVS, normalVS));
rayDirectionVS = mul(float4(rayDirectionVS, 0), sslr_viewMatrix);

// output rDotV to the alpha channel for use in determining how much to fade the ray
float rDotV = dot(rayDirectionVS, rayOriginVS);

is there a better way to do this? I'm googling for few days but can't find any working solution.

Thanks

Share on other sites

Update: Fixed, this because i use world space normal instead of view space. now i'm able to follow example code.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• Forum Statistics

• Total Topics
632631
• Total Posts
3007532
• Who's Online (See full list)

There are no registered users currently online

×