Texture Wrapping points

Started by
4 comments, last by Angi_g 14 years ago
Hey guys I have seen in a few games lately (eg. devil may cry 4) that the texture library's are mainly consisting of texture sheets for level geometry. one of the fascinating things I found though was that the texture sheets (textures with around 5 or so elements that could be used in thousands of ways) had their texture elements in a tiled texture without new polygon creation eg: there is an area of the texture sheet that uses some roof tiles, they can crop the rest of the image then wrap the roof tiles like a single image, kind of like a independent texture I know you can change the dimensions of the texture in the sampler, but I was wondering if there is a type of crop function in the sampler (using VS/PS version 3) Thanks heaps! Angus
Advertisement
not sure about a crop function, but you can read the bytes from part of a texture and create a new texture from them
There's nothing you could do with sampler states or anything like that...you could do it manually in the shader I suppose using some fmods.

I would imagine that the DMC4 guys just explicitly wrap the UV's in the level geometry.
thanks for the quick responses

MJP: whats a shader Fmod, whenever I hear Fmod I think of the sound engine, Google thinks that too. I am cool with manually hard-coding Coords and stuff as it will only be used in once special instance

majek: I have no idea how you would do that. to me tex2D goes something like this

texture
sampler
tex2d
????
profit!
fmod
Thanks heaps MJP! fmod does the trick
there was a few troubles implementing it, like the edges of the texture had horrible artifacts, but its easily resolvable by turning off mip lvls
I make all object's in max, but it has that LAME z-up system, which makes UV invert the Y coord sometimes (Wierd Eh) I fixed it by inverting the fmod

Also, for the UV coordinates I did something like this

//X-YMul & X-YAdd are globals
float XCrop = -fmod(IN.UV.x,FcropX); //fmod is inverted due to 3ds max z-up sys
float YCrop = -fmod(IN.UV.y,FcropY);
float2 Tex = float2(XCrop,YCrop);
Tex *= float2(XMul,YMul); //Scale
Tex += float2(XAdd,YAdd); //Offset

so I have found its best to set your crop weights first, then set the UV scale and offset later

This topic is closed to new replies.

Advertisement