Sign in to follow this  

scaling a texture in HLSL about arbitrary center

Recommended Posts

Im trying to scale a texture around an arbitrary center point in a shader...

 

to try to be more clear, if you want to scale around a center point of a texture normally you can  do something like this:

 

float2 scaleCenter = float2(0.5f, 0.5f);

centercoord = (In.tex.xy - scaleCenter.xy) * scale + scaleCenter.xy;

 

however, I want to do this with a longer texture that's scaled already like this : tex.x/=8.0f... tex.x+=x/8.0f (where x is 0 to 8 .... the particular block I want to show)  ...this is so I can pack a bunch of textures into one.

 

ok, but I still want to then scale the result about its own center point...

 

I hope this makes sense...

 

I tried something like this: 

float2 scaleCenter = float2(0.5f, 0.5f)/float2(8.0f,1);

scaleCenter.x+=i/8.0f; 

 

but not working right...can someone help?

 

 

 

 

 

 

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