rj-action-library/Runtime/Shading/Library/Transform.gdshaderinc

26 lines
496 B
Plaintext

vec3 localToWorld( vec3 _VERTEX, mat4 _MODEL_MATRIX )
{
return ( _MODEL_MATRIX * vec4( _VERTEX, 1.0 ) ).xyz;
}
vec3 worldToLocal( vec3 _VERTEX, mat4 _MODEL_MATRIX )
{
return ( inverse( _MODEL_MATRIX ) * vec4( _VERTEX, 1.0 ) ).xyz;
}
vec2 tilingOffset( vec2 uv, vec4 tilingOffset )
{
uv *= tilingOffset.xy;
uv += tilingOffset.zw;
return uv;
}
vec2 tilingOffsetRepeat( vec2 uv, vec4 tilingOffset )
{
uv *= tilingOffset.xy;
uv += tilingOffset.zw;
return mod( uv, vec2(1,1) );
}