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

Screen Space Vector in world Space (Solved)

$
0
0
So I've been trying to implement Eric Bruneton's Atmospheric Scattering implementation, and I seem to be having an issue with the generation of the world space direction vector for the application phase. In his implementation he uses the inverse view projection matrix to project the view vector in the vertex shader to world space. This is the debug view of my engine. Everything that is green is below the x-z plane, i,e the horizon , and everything about that line is red. As you can tell , the line is slanted. I wanted to know if anyone could give me any idea of what I'm doing wrong. I've tried upwards of four different implementations of screen to world space direction projection, but this is my current code. I've also tried projecting to a frustum corner. void DrawRectangle(in uint VertexID, out float4 OutPosition, out float2 OutUV) { OutUV = float2((VertexID << 1) & 2, VertexID & 2); OutPosition = float4(OutUV * float2(2.0, -2.0) + float2(-1.0f, 1.0f), 0, 1); } void MainVertexShader(in uint VertexID : SV_VertexID, out float2 OutTexcoord : TEXCOORD0, out float4 OutScreenVector : TEXCOORD1, out float4 OutPosition : SV_POSITION) { float4 OutSVPosition; // get the parameters DrawRectangle(VertexID,OutSVPosition,OutTexcoord); // set the out position OutPosition = float4(OutSVPosition.xy,1.0f,1.0f); // construct the screen vector OutScreenVector = normalize(mul(View.InvViewProjection,float4(OutSVPosition.xy,1.0f,0.0f))); }

Viewing all articles
Browse latest Browse all 17825

Trending Articles



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