Metal fixes

This commit is contained in:
Lubos Lenco 2020-05-04 00:19:11 +02:00
parent baac97fb17
commit 61ff96786f
3 changed files with 9 additions and 3 deletions

View File

@ -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;

View File

@ -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

View File

@ -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) + """);