Jump to content

[SOLVED] Abitrary image rotation for textures.


photo

Recommended Posts

Would this be possible... One of our artists is asking for it as it would make the effect he is trying to achieve much easier

 

can you specify more precisely which effect he is trying to achieve ?

Link to comment

Would this be possible... One of our artists is asking for it as it would make the effect he is trying to achieve much easier

 

Thinking about it you could extend UNIGINE material mesh_base in core\materials\unigine_meshes.mat with an optional parameter base_rotation analogous to base_transform used for texture scaling and offsetting

 

<material name="mesh_base" editable="0">
....
   <!-- states -->
....
   <state name="rotation" type="toggle">0</state>
....
   <!-- ... shaders -->
   <shader pass="..." object="mesh"
....
rotation_defines=",ROTATION"
vertex="core/shaders/meshes/vertex_base.shader"
fragment="core/shaders/meshes/fragment_base_.....shader"/>
....
   <!-- parameters -->
   <parameter name="base_transform" type="expression" shared="1">vec4(1.0f,0.0f,0.0f,1.0f)</parameter>
   <parameter name="base_rotation" rotation="1" type="expression" shared="1">vec4(1.0f,0.0f,0.0f,1.0f)</parameter>
....
</material>

 

where base_rotation vec4 elements define 2x2 rotation matrix elements for additional UV texture coordinate rotation (and also shear). UV texcoord rotation can than be added in core\shaders\meshes\vertex_base.shader

 

....
   // texture scale and offset
   texcoord.xy = texcoord.xy * base_transform.xy + base_transform.zw;

   #ifdef ROTATION

   // texture rotation
   texcoord.xy = texcoord.xy * base_rotation.xy + texcoord.yx * base_rotation.zw;

   #endif
....

 

Maybe UNIGINE is willing to include this in default materials/shaders for even greater out-of-the-box texture animation flexibility

Link to comment

Maybe UNIGINE is willing to include this in default materials/shaders for even greater out-of-the-box texture animation flexibility

 

You have to do it on your own, reason see here. Another maybe helpful general example for custom material shader override here

Link to comment
×
×
  • Create New...