Sign in to follow this  
MaartenDeNef

Eric bruneton Atmospheric scattering rotation bug

Recommended Posts

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]http://www.youtube.com/watch?v=0_YIx4oU6LE[/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.

[CODE]
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);
[/CODE]

Then in my vertex shader i'm doing
[CODE]
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;
}
[/CODE]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this