vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
fragment_point_light.frag
Go to the documentation of this file.
1#version 450
2
3layout(location = 0) in vec2 fragOffset;
4layout(location = 0) out vec4 outColor;
5
6struct PointLight {
7 vec4 position; // ignore w
8 vec4 color; // w is intensity
9 float shininess;
10};
11
12layout(set = 0, binding = 0) uniform GlobalUbo {
13 mat4 projection;
14 mat4 view;
15 mat4 invView;
16 vec4 ambientLightColor; // w is intensity
17 PointLight pointLights[10];
18 int numLights;
19} ubo;
20
21layout(push_constant) uniform Push {
22 vec4 position;
23 vec4 color;
24 float radius;
25} push;
26
27const float M_PI = 3.1415926538;
28
29void main() {
30 float dis = length(fragOffset);
31 if (dis >= 1.0) {
32 discard;
33 }
34
35 float cosDis = 0.5 * (cos(dis * M_PI) + 1.0);
36 outColor = vec4(push.color.rgb + 0.5 * cosDis, cosDis);
37}