I'm currently attempting to copy a small texture onto a larger texture, but I want to have control over how large and at what UV position the smaller texture is copied over.
I've made some progress on this and can scale and offset the texture, but the issue is that the scaling is not from the center of the offset.
Does anyone have any ideas on how to do this?
As you can see above, the capsule is at the center of the outlined box. When I scale the coordinates, you can see the red splotches representing where I'm standing scale towards the center/capsule. Now, to do this, the offset is set to (0.5, 0.5).
If I move the outlined box to the upper left corner, the offset no longer scales from the circle. It scales from the upper left corner with an offset of (0, 0). To get it to scale from the center, I need an offset of (0.125, 0.125) which is counter intuitive. I'm handling the offset and scaling manually, but I'd ideally like to automate the process and calculate it all based on position.
Here's the code I'm working with:
float2 newUV = i.uv - float2(_XMod, _YMod); newUV = newUV.xy * float2(_ScaleX, _ScaleY) + float2(0.5f, 0.5f);