Sign in to follow this  
RPTD

can you mix different sized textures?

Recommended Posts

is it possible to do for example a texture of let's say 512x512 (color texture) and then for doing high-res stuff some 1024x1024 normal map or other fancy manipulation maps in one render pass? i ask this especially as i did not find out so far if this 'mixing' of different texture sizes is working flawlessly and if you can assume the consumer hardware does accept this too. are there cards that do not allow mixing textures with different sizes like that?

Share this post


Link to post
Share on other sites
Yes it is possible but, it's slower.
Because when you use the same texcoord for these texture.
The coord is between <0,1>x<0,1>, so they have to be calculated(calculating is done when you call tex2D(cg) or texture2D(glsl)...)twice, once for 512x512, and then for 1024x1024.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cifko
it's slower.

Not really. I use this all the time but I never noticed even a small performance drop compatred to same-sized textures. I don't think GPU reuses coordinates.

Share this post


Link to post
Share on other sites
Quote:
Original post by _DarkWIng_
I don't think GPU reuses coordinates.


Agreed. With this in mind, I can't see how it can be slower. I also haven't noticed any speed deficit with using different sized textures.

Share this post


Link to post
Share on other sites
ok... then this should work.

still standing around the question if this is compatible across different cards or if i need if-path to deal with it beeing not possible.

(currently my engine doesn't allow diff sized textures but i though it might be helpfull perhaps)

Share this post


Link to post
Share on other sites
yes, its possible across different cards, you can use any size texture which is valid up to 2048*2048 on pretty much all cards and 4096*4069 on Nvidia hardware.

As for slowness, the only time I could see it slowing down would be if you were causing texture cache thrashing, and even then you'd have to be doing something pretty crazy to cause it to be bad enuff to have a noticeable effect on your app

Share this post


Link to post
Share on other sites
Quote:
Original post by Cifko
Quote:
Original post by _DarkWIng_
I don't think GPU reuses coordinates.

Gpu don't but you can in shader :-)

I'm sorry but I really don't get your point.

Share this post


Link to post
Share on other sites
CG:
VP:

struct IN
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};

struct OUT
{
float4 HPosition : POSITION;
float3 TexCoord : TEXCOORD0;
};

OUT main(IN Input,
uniform float4x4 ProjectionAndModelview)
{
OUT Output;
Output.TexCoord = Input.TexCoord;
Output.HPosition = mul(ProjectionAndModelview, Input.Position);
return Output;
}

FP:

void main(in float2 TexCoord : TEXCOORD0, uniform sampler2D Tex1, uniform sampler2D Tex2, out float4 color0 : COLOR0)
{
color0 = tex2D(Tex1, TexCoord)+tex2D(Tex2, TexCoord);
}


This is what I mean. This use the same TexCoord for 2 different textures.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cifko: In a vertex and fragment shader, all texture coords are always assumed to be in the 0..1 range, however the texture resolution. The 0..1 range is remapped to the actual texture resolution by the tex2D command, by using a hardwired circuitry. There is absolutely no speed difference accessing texture of different resolution in a single pass, because this remapping is "for free", is always performed, and cannot be bypassed.

The only exception are rectangle textures, where the addressing is in the 0..max_res(x,y) range. Accessing multiple texture by a single texcoord can help a little in this case, it basically saves you a MUL or MAD in the vertex shader. Whether this is worth the artificially introduced limitations and the potentially larger texture cache hits (from blowing up one texture to fit the resolution of the other one) is open to debate. I personally don't think so. Unless your rectangle texture resolution happen to be exactly the same anyway, just throw in an additional texcoord.

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