forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.PS.450core.frag
41 lines (33 loc) · 1.01 KB
/
Example.PS.450core.frag
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
// GLSL Fragment Shader "PS"
// Generated by XShaderCompiler
// 11/10/2019 20:18:28
#version 450 core
layout(location = 0) in vec4 xsv_NORMAL0;
layout(location = 1) in vec2 xsv_TEXCOORD0;
layout(location = 0) out vec4 SV_Target0;
layout(std140, row_major, binding = 3) uniform SceneState
{
mat4 wvpMatrix;
mat4 wMatrix;
vec4 gravity;
uvec2 gridSize;
uvec2 _pad0;
float damping;
float dTime;
float dStiffness;
float _pad1;
vec4 lightVec;
};
layout(binding = 4) uniform texture2D colorMap;
layout(binding = 5) uniform sampler linearSampler;
void main()
{
// Compute lighting
vec3 normal = normalize(xsv_NORMAL0.xyz);
normal *= vec3(mix(1.0, -1.0, float(gl_FrontFacing)));
float NdotL = mix(0.2, 1.0, max(0.0, dot(normal, -lightVec.xyz)));
// Sample color texture
vec4 color = texture(sampler2D(colorMap, linearSampler), xsv_TEXCOORD0);
color.rgb = mix(color.rgb, vec3(xsv_TEXCOORD0, 1.0), vec3(0.5));
SV_Target0 = vec4(color.rgb * NdotL, color.a);
}