mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-07-01 17:43:34 +03:00
Initial commit
This commit is contained in:
12
desktop/graphics/shaders/shader.frag
Normal file
12
desktop/graphics/shaders/shader.frag
Normal file
@ -0,0 +1,12 @@
|
||||
#version 450
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D texSampler;
|
||||
|
||||
layout(location = 0) in vec4 fragColor;
|
||||
layout(location = 2) in vec2 fragTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = fragColor * texture(texSampler, fragTexCoord);
|
||||
}
|
62
desktop/graphics/shaders/shader.vert
Normal file
62
desktop/graphics/shaders/shader.vert
Normal file
@ -0,0 +1,62 @@
|
||||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform Projection {
|
||||
mat4 m;
|
||||
} projection;
|
||||
layout(set = 0, binding = 1) uniform View {
|
||||
mat4 m;
|
||||
} view;
|
||||
|
||||
layout(push_constant) uniform PushContants {
|
||||
layout(offset = 0) mat3x4 model;
|
||||
} push;
|
||||
|
||||
layout(set = 2, binding = 0) uniform Light {
|
||||
vec4 color;
|
||||
vec4 from;
|
||||
float contrast;
|
||||
float softness;
|
||||
} light;
|
||||
|
||||
layout(location = 0) in vec3 inPosition;
|
||||
layout(location = 1) in vec4 inColor;
|
||||
layout(location = 2) in vec3 inNormal;
|
||||
layout(location = 3) in vec2 inTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 2) out vec2 fragTexCoord;
|
||||
|
||||
void main() {
|
||||
mat4 model = mat4(push.model);
|
||||
|
||||
gl_Position = projection.m * view.m * model * vec4(inPosition, 1);
|
||||
|
||||
fragColor.a = inColor.a;
|
||||
|
||||
float exposure = dot(light.from.xyz, (model * vec4(inNormal, 1)).xyz);
|
||||
if (exposure < -light.softness) {
|
||||
fragColor.rgb = inColor.rgb * (
|
||||
(exposure + 1) * ((0.5 - light.contrast) / (1 - light.softness))
|
||||
);
|
||||
} else if (exposure < light.softness) {
|
||||
// FIXME
|
||||
fragColor.rgb =
|
||||
inColor.rgb
|
||||
* (
|
||||
0.5 + exposure * light.contrast / light.softness
|
||||
)
|
||||
* (
|
||||
(+exposure / light.contrast + 1) / 2 * light.color.rgb +
|
||||
(-exposure / light.contrast + 1) / 2 * vec3(1, 1, 1)
|
||||
);
|
||||
} else {
|
||||
fragColor.rgb =
|
||||
inColor.rgb
|
||||
* (
|
||||
0.5 + light.contrast + (exposure - light.softness) * ((0.5 - light.contrast) / (1 - light.softness))
|
||||
)
|
||||
* light.color.rgb;
|
||||
}
|
||||
|
||||
fragTexCoord = inTexCoord;
|
||||
}
|
Reference in New Issue
Block a user