reepblue Posted July 22, 2015 Share Posted July 22, 2015 Tonight I've been looking for a way to rotate a texture 360 degrees from the center so I can use it on a model sheet. I've only found ex_texcoords0 which pans the texture on the face, but I can't seem to find any values or clues on how I would rotate the texture on the face. Any pointers in the right direction would be appreciated. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
shadmar Posted July 22, 2015 Share Posted July 22, 2015 You can apply a 2x2 rotation matrix to the texcoords, something like this would rotate the texture : float sinx = sin ( 0.0001 * currenttime ); float cosx = cos ( 0.0001 * currenttime ); float siny = sin ( 0.0001 * currenttime ); mat2 rotmatrix = mat2( cosx, -sinx, siny, cosx); vec2 rotuv = rotmatrix*ex_texcoords0; Then use rotuv instead of ex_texcoords0 when you lookup the texture. 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted July 22, 2015 Share Posted July 22, 2015 if you just need a fast 90 degree or 180 rotation, you can switch ex_texoords0.xy with yx and -xy -yx etc.. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
reepblue Posted July 23, 2015 Author Share Posted July 23, 2015 Thanks, now I just need to figure out how to make it spin from the center for the plane/texture than the front corner. I kind of want to do a spinning animation on my cubes in Vectronic. Edit: No luck so far, I just keep getting effects that reminds me of the Giygas boss battle from EarthBound. I guess I still need help. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
shadmar Posted July 23, 2015 Share Posted July 23, 2015 Ah center rotation, just subtract 0.5 from coordinates, rotate and add 0.5. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted July 23, 2015 Share Posted July 23, 2015 Like this : //find center vec2 uv = (ex_texcoords0-0.5); //rotate float sinx = sin ( 0.001 * currenttime ); float cosx = cos ( 0.001 * currenttime ); float siny = sin ( 0.001 * currenttime ); mat2 rotmatrix = mat2( cosx, -sinx, siny, cosx); //apply matrix and restore uv (0.5) vec2 rotuv = rotmatrix*uv+0.5; //fetch texture using new uv coordinates outcolor *= texture(texture0,rotuv); 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Roland Posted July 23, 2015 Share Posted July 23, 2015 How cool. This will suit my 'Click-To-Go' marker perfectly. Was just wondering how to solve that and here is a solution like sent from heaven. 1 Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
reepblue Posted July 24, 2015 Author Share Posted July 24, 2015 Shadmar, you're a hero. Just a tip, make sure that the texture file is Clamped to X and Y to remove the duplicate textures you see in the corners while it's rotating. Now to test my idea with this. Thanks again. 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.