• Advertisement
Sign in to follow this  

9000 x 1500 Skybox Texture - XNA

This topic is 1797 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 all,

 

I'm working on a 3D space shooter with XNA 4.0 and have downloaded a temporary skybox(actually a sphere) with texture which I would like to replace with another scene.

 

So I finished creating the cube map with the photoshop CS3 Nvidia dds plugin and exported as a cubemap (other settings default) and, while I can import the texture and it displays well, no seams etc, I was forced to scale down to a size below 4096 for use with XNA.

 

However this results in the skybox feeling very "close" to the scene due to the smaller texture size compared to the original.

 

After checking the dimensions of the original texture in photoshop (even though it only displays a black background?) it seems to be a 9000 x 1500 texture size and the file size is just over 100 Mb!

 

My own texture is a paltry 3072 x 512 with a file size of about 1 Mb by comparison.

 

So my question is are there some export settings I am ignoring? Or, why exactly does XNA turn it's nose up at my own texture when it is over 4096 and not another?

 

I have checked the content importer and processor settings for each texture and they appear the same so is there something I'm missing?

 

If anyone can shed some light I would be much obliged.

 

Thanks.

 

 

Share this post


Link to post
Share on other sites
Advertisement
Because graphics cards have limited memory and are only able to address so much. When a texture is loaded for use, it goes into a special area where it can be sampled from very quickly. The size of that memory is the maximum size of the texture you can load. Some cards had 256, then 1024, 2048, and then 4096, and beyond.

4096 is the largest size Xbox360 can use. It may be the largest size that XNA GS supports for PC as well. Then your own GPU will have it's own limit, which may be less or more.

There is no way in hell you need a texture any larger than that. Most textures at 4096x4096 are being used for atlasing, and not for a single texture, and there aren't even that many pixels visible on screen. Edited by Daaark

Share this post


Link to post
Share on other sites

Yeah that was my understanding as well of the way video memory was handled on the GPU, but there is still the fact that the texture being referenced is of that size and those dimensions in the content folder.. So the only thing I can think of is that its being either scaled down or sampled in some way along the content pipeline that I am unaware of, or perhaps that there is some sort of compression technique that was applied to the original texture during its creation that enables the image data to be referenced at runtime... Im just fishing here because, as you say, it doesn't conform to my understanding of the the addresing limitations of the environment..

 

Cheers though I appreciate the response!

Share this post


Link to post
Share on other sites
A lot of people don't realize how the content folder in XNA works.

The content folder in your project is treated like a source code folder, and then the it all gets compiled into new formats. Your models get converted to a format that maps with the MODEL datatype. Textures will be turned to DDS, and any necessary conversions size and bit depth conversions will be done.

A 3072x512 texture * 32 bits is not 1 mb. 512x512 is just under 1mb.

Share this post


Link to post
Share on other sites

Yeah I suppose I could have a better grasp though I am aware of the
byte code compilation process during the build process.. The thing is,
that is exactly why I don't understand the differences between the on
screen results I am achieving. I mean, if the content pipeline is
supposed to pretty much automatically apply scale, sampling and other
pertinent texture info at compile time and imbedded in the model, all of which is sent to the GPU to be rendered, then what is causing the scaling issues I am having? If you know what  mean.

 

I
dont mean to sound like an idiot either, but I am not really a guy who
has often tried to stitch his own textures together in photoshop. My
reference to the file sizes are simply what I see on the screen and in
the properties of the files, I was just including them in case it had
context for the problem. I not really an artist. I dont really know how to measure what size an image is except by what I see on the screen. When I create a new photoshop document I set  it to 6144 x 1024 pixels at 300 pixels per inch in 32 bit RGB mode. Then exported it to .dds with default options bar changing it from 2D texture to cubemap. The resulting mipmapped file appears to be 1Mb in the file explorer then.

Share this post


Link to post
Share on other sites

Also the shader operating on the texture is as follows skybox.fx

 

uniform extern float4x4 ViewMatrix;
uniform extern float4x4 ProjectionMatrix;

void SkyboxVertexShader( float3 pos : POSITION0,
                         out float4 SkyPos : POSITION0,
                         out float3 SkyCoord : TEXCOORD0 )
{
    // Calculate rotation. Using a float3 result, so translation is ignored
    float3 rotatedPosition = mul(pos, ViewMatrix);           
    // Calculate projection, moving all vertices to the far clip plane 
    // (w and z both 1.0)
    SkyPos = mul(float4(rotatedPosition, 1), ProjectionMatrix).xyww;    

    SkyCoord = pos;
};
uniform extern texture SkyboxTexture;
sampler SkyboxS = sampler_state
{
    Texture = <SkyboxTexture>;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU = CLAMP;
    AddressV = CLAMP;
};
float4 SkyboxPixelShader( float3 SkyCoord : TEXCOORD0 ) : COLOR
{
    // grab the pixel color value from the skybox cube map
    return texCUBE(SkyboxS, SkyCoord);
};
technique SkyboxTechnique
{
    pass P0
    {
        vertexShader = compile vs_2_0 SkyboxVertexShader();
        pixelShader = compile ps_2_0 SkyboxPixelShader();

        // We're drawing the inside of a model
        CullMode = None;  
        // We don't want it to obscure objects with a Z < 1
        ZWriteEnable = false; 
    }
}

Share this post


Link to post
Share on other sites

And the draw and update methods in my skysphere.cs file.

 

 public override void LoadContent()
        {

            SkySphereModel = XNAGame.Instance().Content.Load<Model>("SkySphere/SphereHighPoly");
            TextureCube SkySphereTexture = XNAGame.Instance().Content.Load<TextureCube>("SkySphere/SkySphereTexture");
            SkySphereEffect = XNAGame.Instance().Content.Load<Effect>("SkySphere");
            SkySphereEffect.Parameters["ViewMatrix"].SetValue(XNAGame.Instance().Camera.view);
            SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(XNAGame.Instance().Camera.projection);
            SkySphereEffect.Parameters["SkyboxTexture"].SetValue(SkySphereTexture);

            SkySphereEffect = XNAGame.Instance().Content.Load<Effect>("SkySphere");

            foreach (ModelMesh mesh in SkySphereModel.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = SkySphereEffect;
                }
            }
        }

        public override void Draw(GameTime gameTime)
        {
            SkySphereEffect.Parameters["ViewMatrix"].SetValue(XNAGame.Instance().Camera.view);
            SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(XNAGame.Instance().Camera.projection);

            DepthStencilState dss = new DepthStencilState();
            dss.DepthBufferEnable = false;
            XNAGame.Instance().GraphicsDevice.DepthStencilState = dss;
            foreach (ModelMesh mesh in SkySphereModel.Meshes)
            {

                mesh.Draw();
            }

            dss = new DepthStencilState();
            dss.DepthBufferEnable = true;
            XNAGame.Instance().GraphicsDevice.DepthStencilState = dss;
        }
    }

Share this post


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

  • Advertisement