// #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Normals.gdshaderinc" vec3 scaleNormalMap( vec3 normal, float scale ) { normal -= vec3( 0.5 ); normal *= scale; normal += vec3( 0.5 ); return normal; } vec3 addNormalMaps( vec3 a, vec3 b ) { a -= vec3( 0.5 ); b -= vec3( 0.5 ); vec3 result = a + b; return result + 0.5; } vec3 getNormal( sampler2D _normalTexture, vec2 screenUV ) { return textureLod( _normalTexture, screenUV, 0.0 ).rgb * 2.0 - vec3( 1.0 ); } vec3 getNormalAtViewPosition( sampler2D _normalTexture, vec3 viewPosition, mat4 _PROJECTION_MATRIX ) { vec2 screenPosition = viewToScreen( viewPosition, _PROJECTION_MATRIX ); return getNormal( _normalTexture, screenPosition ); } vec4 getNormalRoughness( sampler2D _normalTexture, vec2 screenUV ) { vec4 sample = textureLod( _normalTexture, screenUV, 0.0 ); return vec4( sample.rgb * 2.0 - vec3( 1.0 ), sample.a ); } vec4 getNormalRoughnessAtViewPosition( sampler2D _normalTexture, vec3 viewPosition, mat4 _PROJECTION_MATRIX ) { vec2 screenPosition = viewToScreen( viewPosition, _PROJECTION_MATRIX ); return getNormalRoughness( _normalTexture, screenPosition ); }