Skip to main content
gamedev.net
🔒 Locked

Eric bruneton Atmospheric scattering rotation bug

Started by Sneezy Feb 23, 2012 at 6:39 PM 1 replies 2.5k views
Original Post
Sneezy
Sneezy
Hi,

I'm trying to implement Precomputed atmospheric scattering thanks to the paper of Eric Bruneton.
I've converted some of the shaders needed to compute the single scattering. (Transmittance, Irradiance1, InScatter1, InScatterCopy) to HLSL.

All the precomputed textures work like they suppose to. But when I try to bring them together strange things happen.
I made a short video to show you the problem.

[media]
[/media]

As you can see my horizon is turned on it's side and when i start to move it turns around.
1 other problem is I can't see my outer space view of the earth.

I think my problems with the turning lays with in my Camera view direction vector.
I just followed the files givin by bruneton on his site to calculate it.


D3DXMATRIX matView = pRenderContext->GetCamera()->GetView();
D3DXMATRIX matProj = pRenderContext->GetCamera()->GetProj();
D3DXMATRIX iproj;
D3DXMATRIX iview;
D3DXMatrixInverse(&iproj, NULL, &matProj);
D3DXMatrixInverse(&iview, NULL, &matView);
D3DXVECTOR4 cl;
D3DXVec3Transform(&cl, &D3DXVECTOR3(0.0, 0.0, 0.0), &iview);
D3DXVECTOR4 sun = D3DXVECTOR4(sin(sunTheta) * cos(sunPhi), sin(sunTheta) * sin(sunPhi), cos(sunTheta), 0.0);
D3DXVECTOR3 campos = D3DXVECTOR3(pRenderContext->GetCamera()->GetPos());
m_pCShaderVar->SetFloatVector(campos);
m_pSShaderVar->SetFloatVector(sun);
m_pProjInverseShaderVar->SetMatrix(iproj);
m_pViewInverseShaderVar->SetMatrix(iview);


Then in my vertex shader i'm doing

PS_INPUT_STRUCT_FINAL VSPLANET( VS_INPUT_STRUCT input )
{
PS_INPUT_STRUCT_FINAL output = (PS_INPUT_STRUCT_FINAL)0;
output.Pos = float4(input.Pos,1);
output.Tex = input.Tex;
float4 invpos = mul(float4(input.Pos.xyz,1), projInverse);
output.ray = mul(float4(invpos.xyz, 0), viewInverse).xyz;
return output;
}


So I hope someone has had the same problem or knows what I did wrong.
If you need more code just ask :-)

Ty in advance
Sneezy
Sneezy
Ok,

I fixed the problem with the outer space view. It was an error in my render to 3D texture.
Just that anoying rotation needs to be fixed .
Sneezy
Sneezy
nvm,

Fixed it :-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.