Sign in to follow this  

Creating texture of monitor size with card supporting Non Power 2 Conditional

This topic is 2653 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 am trying to create a texture of size (1280x1024) and (1920x1080) in my directX application (Managed C#).But my garphics card dosen't allow NPOT but it supports POT Conditional.
I came across few posts where they mentioned about following few conditions,

1. Texture address mode to clamp
2. Wrapn to 0
3. No mipmaps
etc.

Since i am new to direct X and its is a must for me to create non power 2 textures.Kindly help me to create such textures by providing some code to achieve these conditions or is there any other method to create NPOT Textures.

Regards
Rajacc

Share this post


Link to post
Share on other sites
1. Set the texture address mode for the sampler that the texture is in to Clamp (The stage is probably 0 unless you're doing multi texturing)
2. Unless you change the wrap mode, it already defaults to 0, so you don't need to do anything here
3. When you create the texture, specify 1 for the number of mip maps
4. You also cannot use compressed texture formats when you create the texture

I can give you the code in C++ if it's any use, but I don't know C#.



EDIT: Corrected: Need to specify 1, not 0 for number of mip maps.

[Edited by - Evil Steve on September 2, 2010 5:39:38 AM]

Share this post


Link to post
Share on other sites
Make the texture a power of 2 and use a subset of the pixels. For example, make a 2048*2048 texture and only consider pixels X=0-1680 and Y=0-1050. Then, if you need to write to disk you can crop it to a user specified resolution.

Share this post


Link to post
Share on other sites
Hi Steve,
Thanks for replying.I am working on 3D generation by matrix interlacing of multiple views and hence arrangement of pixels should be highly accurate.

I am using the texture created as a look up table where the interlaced texture coordinates will be stored which in turn will be passed to a shader for final processing.

The following is the code i am using for creating the texture (which works fine in my previous system where NPOT is allowed),

MyTexture = new Texture(device,1280,1024,0, Usage.None, Format.G32R32F, Pool.Managed);

Here the error occurs ( since the NPOT is not allowed in my present hardware)

In case if i changed the code as

MyTexture = new Texture(device, 1280, 1024,1, Usage.None, Format.G32R32F, Pool.Managed);

By changing the number of levels in texture to 1 , it is creating the texture but my output is not clear with pixels spreading and causes ghosting.

Could you tell whats happening here and yes if you give me C++ code to achieve the NPOT Conditional requirements, it will be of great help to me.
Thanks in advance and thanks to everyone who helped.

Share this post


Link to post
Share on other sites
Quote:
Original post by rajacc
In case if i changed the code as

MyTexture = new Texture(device, 1280, 1024,1, Usage.None, Format.G32R32F, Pool.Managed);

By changing the number of levels in texture to 1 , it is creating the texture but my output is not clear with pixels spreading and causes ghosting.
Ah sorry - I meant pass 1 for the number of mip-maps (0 means "Generate a full mimap chain"). So what you have above is correct.

Can you show us a screenshot of what you mean by ghosting and pixels spreading?

As for C++ code:

// 1.
pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

// 2.
pDevice->SetRenderState(D3DRS_WRAP0, 0);

// 3. and 4. As you have above looks correct

Share this post


Link to post
Share on other sites
Hi Steve,
Thanks for your reply.

I did as you have explained and still the output is not as expected. So i have changed the code (in the previous machine where NPOT is supported) as 1 for the number of mip-maps and still it produced good result. Hence the problem may not be in texture creation.

Then i used a image with a single red color pixel at (0,0) coordinate as input and executed in both the machines.

The output of the machine where NPOT is supported(having ATI Radeon HD 3200 Graphics) , gives the same red pixel at (0,0).

Whereas the output from the system where i am having problem (having Intel(R) G41 Express Chipset )spreads the pixel color.(i.e) the red pixel has been spread over {(0,0,(1,0),(0,1),(1,1)}.

But the applications running in both the systems are same, with the same shader code to arrange the pixels.The following is the parameters added for texture in shader file.

Texture Texture1;
sampler samp1 = sampler_state {
texture = <Texture1>;
MinFilter = Point;
MagFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
};

Could you explain what could be the problem and how to fix this ?

Thanks in advance

Regards
Rajacc.



Share this post


Link to post
Share on other sites

This topic is 2653 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.

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