0
\$\begingroup\$

I ask for help - I need to rotate the UV scan inside the quad by a certain angle (set by a parameter) so that the result is embedded in the original UV, and the missing areas are repeat edge pixels. Example in the picture. Unity. How to do it? I can only simply rotate the scan, but not reduce it.

Required rotation type

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Maybe someone will need it?

o.spriteCoord.xy = v.texcoord.xy;
o.spriteCoord.zw = float2(1, 1);
                    
o.spriteCoord.x = (o.spriteCoord.x - 0.5) * _BoundsX + 0.5;
o.spriteCoord.y = (o.spriteCoord.y - 0.5) * _BoundsY + 0.5;
                    
o.spriteCoord.xy = rotateUV(o.spriteCoord.xy, _Rotation);
                    
o.spriteCoord.x = (o.spriteCoord.x - 0.5) / _ScaleX + 0.5;
o.spriteCoord.y = (o.spriteCoord.y - 0.5) / _ScaleY + 0.5;

Where bounds is the size in unit of the global width and height, and scale is the desired image scale

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .