Advertisement

Screen space glossy reflections - viewRay calculation

Started by August 31, 2017 12:14 PM
1 comment, last by aomsin2526 7 years, 5 months ago

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);

03814579fd.png

 

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

Thanks

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

This topic is closed to new replies.

Advertisement