Amerio.Stephane Posted April 27, 2025 Posted April 27, 2025 Hello, I'm trying to rotate a texture in a material graph, and the rotation appears to also scale down the texture: The mesh is a simple quad with UV from 0,0, to 1,1 As a sample test, here is the graph used: Am I doing something wrong? Is it the expected behavior for this node? If yes, then how should I compensate the scaling? Suggestions: add support for a pivot different from (0.5, 0.5) Suggestions: if the scaling is expected, add support for a compensation in the node as a static switch Thanks!
silent Posted April 28, 2025 Posted April 28, 2025 Hi Stephane, The Rotate UV node was automatically ported into the graph from the general shader codebase. It works as intended for brushes by rotating the UV coordinates and fitting them into the rectangle, which is why you're observing scale changes. To avoid this scaling behavior, you can create your own rotation method. Simply create a custom Function node and use the following code: float2 rotateUV(float2 uv, float angle, float2 pivot) { float s = 0.0f; float c = 0.0f; sincos(angle * DEG2RAD, s, c); uv -= pivot; float2 ret; ret.x = c * uv.x + s * uv.y; ret.y = c * uv.y - s * uv.x; // uncomment for fitting in square // ret *= max(abs(c + s), abs(c - s)); return ret + pivot; } Just in case, full matgraph file for that: rotate_uv.mgraph We plan to add proper Rotate UV methods in future updates (2.21+). Thanks! 2 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Amerio.Stephane Posted April 28, 2025 Author Posted April 28, 2025 It works! Thanks a lot! Bonus question: If I want to use the function multiple times in the same graph, I guess I have to put it inside a subgraph and use the subgraph instead, or is there a better way?
silent Posted April 28, 2025 Posted April 28, 2025 Quote Bonus question: If I want to use the function multiple times in the same graph, I guess I have to put it inside a subgraph and use the subgraph instead, or is there a better way? Yes, that's the right approach for using it across multiple graphs. Just don’t forget to replace it with the proper native version once it’s officially released :) 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts