Jump to content



Eric bruneton Atmospheric scattering rotation bug

  • You cannot reply to this topic
2 replies to this topic

#1 Sneezy   Members   -  Reputation: 106

Like
0Likes
Like

Posted 23 February 2012 - 12:39 PM

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.



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

Ad:

#2 Sneezy   Members   -  Reputation: 106

Like
0Likes
Like

Posted 25 February 2012 - 04:17 AM

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 :(.

#3 Sneezy   Members   -  Reputation: 106

Like
0Likes
Like

Posted 27 February 2012 - 04:21 AM

nvm,

Fixed it :-)






We are working on generating results for this topic
PARTNERS