Jump to content
  • Advertisement
Sign in to follow this  
Steve5050

Sky Box Distortion Third Persom Camera

This topic is 3731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Using vb.net 2003 with dx 9.0c I actually have a space ship with a camera behind and up as a third person camera. The problem is when I pitch the camera up and down the I can see that the bottom and sides of the box go convex and concave,I can see it do that to the mountains and the bottom grassland textures the I am using. I'm doing something wrong with the view matrix. Here is my third person camera in my FrameMove()
 Dim SkyBoxLocation As New Vector3(0, 0, 0)
        Select Case CameraViewMode
            Case CameraMode.ThirdPersonMode
                Dim ThirdPersonMatrix As Matrix = Matrix.Translation(0, 6, -30)
                ThirdPersonMatrix = Matrix.Multiply(ThirdPersonMatrix, SpaceShip.Position.WorldMatrix)
                ViewMatrix = Matrix.Invert(ThirdPersonMatrix)
                SkyBoxLocation = SpaceShip.Position.Location
End Select

Device.Transform.View = ViewMatrix
SkyBox.Position.Location = SkyBoxLocation

Now Rendering:
Protected Overrides Sub Render()
               Device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Blue, 1.0F, 0)

         Device.Transform.View = ViewMatrix

         Device.BeginScene()
             
         SkyBoxSphere.Render()
       
         Device.Transform.World = SpaceShip.Position.WorldMatrix

        PlayerShip.Render()

        Device.EndScene()
End Sub

Transforming my skybox world in it's render sub didn't change anything. I'll leave it at that for now, maybe someone can pick up on what I'm doing wrong. Thanks Steve

Share this post


Link to post
Share on other sites
Advertisement
You don't want your skybox centered around the spaceship, you want it centered around your camera.

Usually what I do is I don't bother moving my skybox at all, I just leave it at <0,0,0> and then only apply the rotation portion of the view matrix. Shader code looks like this:


void SkyboxVS( in float3 in_vPositionOS : POSITION,
in float3 in_vTexCoord : TEXCOORD0,
out float4 out_vPositionCS : POSITION,
out float3 out_vTexCoord : TEXCOORD0 )
{
float4 vPositionVS = float4(mul(in_vPositionOS, (float3x3)g_matView), 1.0f);
out_vPositionCS = mul(vPositionVS, g_matProj);
out_vTexCoord = in_vTexCoord;
}

Share this post


Link to post
Share on other sites
Thanks MJP

I went with:

Dim SkyBoxLocation As New Vector3(0, 0, 0)
Select Case CameraViewMode
Case CameraMode.ThirdPersonMode
Dim ThirdPersonMatrix As Matrix = Matrix.Translation(0, 6, -30)
ThirdPersonMatrix = Matrix.Multiply(ThirdPersonMatrix, SpaceShip.Position.WorldMatrix)
ViewMatrix = Matrix.Invert(ThirdPersonMatrix)
SkyBoxLocation.X = ThirdPersonMatrix.41
SkyBoxLocation.Y = ThirdPersonMatrix.42
SkyBoxLocation.Z = ThirdPersonMatrix.43
End Select

Device.Transform.View = ViewMatrix
SkyBox.Position.Location = SkyBoxLocation




Thanks
Steve

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!