Skip to content

Commit

Permalink
Update shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Oct 15, 2024
1 parent 8a1cb15 commit 0b1c848
Show file tree
Hide file tree
Showing 22 changed files with 321 additions and 547 deletions.
12 changes: 6 additions & 6 deletions armorpaint/shaders/dilate_map.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ in vec2 tex;
out float dummy;

void main() {
#if defined(HLSL) || defined(METAL) || defined(SPIRV)
vec2 tex_coord = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);
#else
#ifdef GLSL
vec2 tex_coord = tex * 2.0 - 1.0;
#endif
#else
vec2 tex_coord = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);
#endif
gl_Position = vec4(tex_coord, 0.0, 1.0);
#ifdef HLSL
#ifdef HLSL
float keep = pos.x + nor.x;
#endif
#endif
}
18 changes: 11 additions & 7 deletions base/shaders/cursor.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ uniform sampler2D gbufferD;
uniform sampler2D texa;
#endif

#ifdef HLSL
in vec4 pos;
in vec2 nor;
#endif
in vec2 tex;
out vec2 tex_coord;

vec3 get_pos(vec2 uv) {
#ifdef HLSL
#ifdef HLSL
float keep = textureLod(texa, vec2(0.0, 0.0), 0.0).r; // direct3d12 unit align
float keep2 = pos.x + nor.x;
#endif
#if defined(HLSL) || defined(METAL) || defined(SPIRV)
float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
#else
#endif

#ifdef GLSL
float depth = textureLod(gbufferD, uv, 0.0).r;
#endif
#else
float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
#endif

vec4 wpos = vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
wpos = mul(wpos, invVP);
return wpos.xyz / wpos.w;
Expand All @@ -38,7 +42,7 @@ vec3 get_normal(vec3 p0, vec2 uv) {
return normalize(cross(p2 - p0, p1 - p0));
}

void create_basis(vec3 normal, out vec3 tangent, out vec3 binormal) {
void create_basis(vec3 normal, OUT(vec3, tangent), OUT(vec3, binormal)) {
tangent = normalize(camera_right - normal * dot(camera_right, normal));
binormal = cross(tangent, normal);
}
Expand Down
6 changes: 4 additions & 2 deletions base/shaders/pass.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
tex_coord = pos.xy * madd + madd;
#if defined(HLSL) || defined(METAL) || defined(SPIRV)

#ifdef GLSL
#else
tex_coord.y = 1.0 - tex_coord.y;
#endif
#endif

gl_Position = vec4(pos.xy, 0.0, 1.0);
}
6 changes: 4 additions & 2 deletions base/shaders/pass_viewray.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
tex_coord = pos.xy * madd + madd;
#if defined(HLSL) || defined(METAL) || defined(SPIRV)

#ifdef GLSL
#else
tex_coord.y = 1.0 - tex_coord.y;
#endif
#endif

gl_Position = vec4(pos.xy, 0.0, 1.0);

Expand Down
6 changes: 4 additions & 2 deletions base/shaders/pass_viewray2.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
tex_coord = pos.xy * madd + madd;
#if defined(HLSL) || defined(METAL) || defined(SPIRV)

#ifdef GLSL
#else
tex_coord.y = 1.0 - tex_coord.y;
#endif
#endif

gl_Position = vec4(pos.xy, 0.0, 1.0);

Expand Down
Loading

0 comments on commit 0b1c848

Please sign in to comment.