diff --git a/Shaders/compositor_pass/compositor_pass.vert.glsl b/Shaders/compositor_pass/compositor_pass.vert.glsl index 8e3089f8..4e0a095d 100644 --- a/Shaders/compositor_pass/compositor_pass.vert.glsl +++ b/Shaders/compositor_pass/compositor_pass.vert.glsl @@ -18,7 +18,7 @@ void main() { // Scale vertex attribute to [0-1] range const vec2 madd = vec2(0.5, 0.5); texCoord = pos.xy * madd + madd; - #ifdef HLSL + #ifdef _InvY texCoord.y = 1.0 - texCoord.y; #endif @@ -26,7 +26,7 @@ void main() { // #ifdef _CPos // NDC (at the back of cube) - // vec4 v = vec4(pos.xy, 1.0, 1.0); + // vec4 v = vec4(pos.xy, 1.0, 1.0); // v = vec4(invVP * v); // v.xyz /= v.w; // viewRay = v.xyz - eye; diff --git a/Shaders/include/pass.vert.glsl b/Shaders/include/pass.vert.glsl index eececc04..1d924d72 100755 --- a/Shaders/include/pass.vert.glsl +++ b/Shaders/include/pass.vert.glsl @@ -10,7 +10,7 @@ void main() { // Scale vertex attribute to 0-1 range const vec2 madd = vec2(0.5, 0.5); texCoord = pos.xy * madd + madd; - #ifdef HLSL + #ifdef _InvY texCoord.y = 1.0 - texCoord.y; #endif diff --git a/blender/arm/write_data.py b/blender/arm/write_data.py index c3b5446b..bbdfb28c 100755 --- a/blender/arm/write_data.py +++ b/blender/arm/write_data.py @@ -452,6 +452,12 @@ def write_compiledglsl(defs, make_variants): if make_variants and d.endswith('var'): continue # Write a shader variant instead f.write("#define " + d + "\n") + + f.write("""#if defined(HLSL) || defined(METAL) +#define _InvY +#endif +""") + f.write("""const float PI = 3.1415926535; const float PI2 = PI * 2.0; const vec2 shadowmapSize = vec2(""" + str(shadowmap_size) + """, """ + str(shadowmap_size) + """);