Use HLSL define

This commit is contained in:
luboslenco 2018-11-27 21:44:56 +01:00
parent cd0447e4ba
commit 7075374c8f
19 changed files with 22 additions and 25 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 _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -8,14 +8,14 @@ in vec3 col;
uniform mat4 VP;
out vec3 color;
// #ifdef _InvY
// #ifdef HLSL
out vec4 wvpposition;
// #endif
void main() {
color = col;
gl_Position = VP * vec4(pos, 1.0);
// #ifdef _InvY
// #ifdef HLSL
wvpposition = gl_Position;
// #endif
}

View file

@ -3,13 +3,13 @@
#include "compiled.inc"
in vec3 color;
// #ifdef _InvY
// #ifdef HLSL
vec4 wvpposition;
// #endif
out vec4[2] fragColor;
void main() {
// #ifdef _InvY // D3D
// #ifdef HLSL // D3D
fragColor[0] = vec4(1.0, 1.0, 0.0, 1.0 - ((wvpposition.z / wvpposition.w) * 0.5 + 0.5));
// #else
// fragColor[0] = vec4(1.0, 1.0, 0.0, 1.0 - gl_FragCoord.z);

View file

@ -14,7 +14,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

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 _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -14,7 +14,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -13,7 +13,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -17,7 +17,7 @@ out vec4 fragColor;
void main() {
vec2 texCoord = wvpposition.xy / wvpposition.w;
texCoord = texCoord * 0.5 + 0.5;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -17,7 +17,7 @@ out vec4 fragColor;
void main() {
vec2 texCoord = wvpposition.xy / wvpposition.w;
texCoord = texCoord * 0.5 + 0.5;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -19,7 +19,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -15,7 +15,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -13,7 +13,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -42,7 +42,7 @@ vec2 getProjectedCoord(vec3 hitCoord) {
vec4 projectedCoord = P * vec4(hitCoord, 1.0);
projectedCoord.xy /= projectedCoord.w;
projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
#ifdef _InvY
#ifdef HLSL
projectedCoord.y = 1.0 - projectedCoord.y;
#endif
return projectedCoord.xy;

View file

@ -26,7 +26,7 @@ vec2 getProjectedCoord(vec3 hitCoord) {
vec4 projectedCoord = P * vec4(hitCoord, 1.0);
projectedCoord.xy /= projectedCoord.w;
projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
#ifdef _InvY
#ifdef HLSL
projectedCoord.y = 1.0 - projectedCoord.y;
#endif
return projectedCoord.xy;

View file

@ -34,7 +34,7 @@ vec3 getPosNoEye(const vec3 eyeLook, const vec3 viewRay, const float depth, cons
return wposition;
}
#ifdef _InvY
#ifdef HLSL
vec3 getPos2(const mat4 invVP, const float depth, vec2 coord) {
coord.y = 1.0 - coord.y;
#else
@ -46,7 +46,7 @@ vec3 getPos2(const mat4 invVP, const float depth, const vec2 coord) {
return pos.xyz;
}
#ifdef _InvY
#ifdef HLSL
vec3 getPosView2(const mat4 invP, const float depth, vec2 coord) {
coord.y = 1.0 - coord.y;
#else
@ -58,7 +58,7 @@ vec3 getPosView2(const mat4 invP, const float depth, const vec2 coord) {
return pos.xyz;
}
#ifdef _InvY
#ifdef HLSL
vec3 getPos2NoEye(const vec3 eye, const mat4 invVP, const float depth, vec2 coord) {
coord.y = 1.0 - coord.y;
#else

View file

@ -6,7 +6,7 @@ vec2 getProjectedCoord(vec3 hitCoord) {
vec4 projectedCoord = VP * vec4(hitCoord, 1.0);
projectedCoord.xy /= projectedCoord.w;
projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
#ifdef _InvY
#ifdef HLSL
projectedCoord.y = 1.0 - projectedCoord.y;
#endif
return projectedCoord.xy;

View file

@ -14,7 +14,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -17,7 +17,7 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef _InvY
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif

View file

@ -87,9 +87,6 @@ def add_world_defs():
elif voxelao:
wrd.world_defs += '_VoxelAOvar' # Write a shader variant
if arm.utils.get_gapi().startswith('direct3d'): # Flip Y axis in drawQuad command
wrd.world_defs += '_InvY'
if arm.utils.get_legacy_shaders() and not state.is_viewport:
wrd.world_defs += '_Legacy'