Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Screen space glossy reflections - viewRay calculation

$
0
0
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

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>