Jump to content
  • Advertisement
aomsin2526

Screen space glossy reflections - viewRay calculation

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

If you intended to correct an error in the post then please contact us.

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

03814579fd.png

 

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

Thanks

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!