forked from julianxhokaxhiu/FFNx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFFNx.vert
72 lines (60 loc) · 2.61 KB
/
FFNx.vert
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/****************************************************************************/
// Copyright (C) 2009 Aali132 //
// Copyright (C) 2018 quantumpencil //
// Copyright (C) 2018 Maxime Bacoux //
// Copyright (C) 2020 myst6re //
// Copyright (C) 2020 Chris Rizzitello //
// Copyright (C) 2020 John Pritchard //
// Copyright (C) 2023 Julian Xhokaxhiu //
// //
// This file is part of FFNx //
// //
// FFNx is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License //
// //
// FFNx is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
/****************************************************************************/
$input a_position, a_color0, a_texcoord0
$output v_color0, v_texcoord0
#include <bgfx/bgfx_shader.sh>
uniform mat4 d3dViewport;
uniform mat4 d3dProjection;
uniform mat4 worldView;
uniform vec4 VSFlags;
#define isTLVertex VSFlags.x > 0.0
#define blendMode VSFlags.y
#define isFBTexture VSFlags.z > 0.0
void main()
{
vec4 pos = a_position;
vec4 color = a_color0;
vec2 coords = a_texcoord0;
color.rgba = color.bgra;
if (isTLVertex)
{
pos.w = 1.0 / pos.w;
pos.xyz *= pos.w;
pos = mul(u_proj, pos);
}
else
{
pos = mul(mul(d3dViewport,mul(d3dProjection,worldView)), vec4(pos.xyz, 1.0));
if (color.a > 0.5) color.a = 0.5;
}
if (blendMode == 4.0) color.a = 1.0;
else if (blendMode == 3.0) color.a = 0.25;
#if BGFX_SHADER_LANGUAGE_HLSL
#else
#if BGFX_SHADER_LANGUAGE_SPIRV
#else
if (isFBTexture) coords.y = 1.0 - coords.y;
#endif
#endif
gl_Position = pos;
v_color0 = color;
v_texcoord0 = coords;
}