mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Vulcan Nightmare
Experimentally bringing up vulcan support
This commit is contained in:
parent
863a786c48
commit
83b576e8d9
189 changed files with 12147 additions and 7820 deletions
79
assets/shaders/wmo.frag.glsl
Normal file
79
assets/shaders/wmo.frag.glsl
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 1) uniform WMOMaterial {
|
||||
int hasTexture;
|
||||
int alphaTest;
|
||||
int unlit;
|
||||
int isInterior;
|
||||
float specularIntensity;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2DShadow uShadowMap;
|
||||
|
||||
layout(location = 0) in vec3 FragPos;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TexCoord;
|
||||
layout(location = 3) in vec4 VertColor;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = hasTexture != 0 ? texture(uTexture, TexCoord) : vec4(1.0);
|
||||
if (alphaTest != 0 && texColor.a < 0.5) discard;
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
if (!gl_FrontFacing) norm = -norm;
|
||||
|
||||
vec3 result;
|
||||
|
||||
if (unlit != 0) {
|
||||
result = texColor.rgb;
|
||||
} else if (isInterior != 0) {
|
||||
vec3 mocv = max(VertColor.rgb, vec3(0.5));
|
||||
result = texColor.rgb * mocv;
|
||||
} else {
|
||||
vec3 ldir = normalize(-lightDir.xyz);
|
||||
float diff = max(dot(norm, ldir), 0.0);
|
||||
|
||||
vec3 viewDir = normalize(viewPos.xyz - FragPos);
|
||||
vec3 halfDir = normalize(ldir + viewDir);
|
||||
float spec = pow(max(dot(norm, halfDir), 0.0), 32.0) * specularIntensity;
|
||||
|
||||
float shadow = 1.0;
|
||||
if (shadowParams.x > 0.5) {
|
||||
vec4 lsPos = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
vec3 proj = lsPos.xyz / lsPos.w * 0.5 + 0.5;
|
||||
if (proj.z <= 1.0) {
|
||||
float bias = max(0.005 * (1.0 - dot(norm, ldir)), 0.001);
|
||||
shadow = texture(uShadowMap, vec3(proj.xy, proj.z - bias));
|
||||
}
|
||||
shadow = mix(1.0, shadow, shadowParams.y);
|
||||
}
|
||||
|
||||
result = ambientColor.rgb * texColor.rgb
|
||||
+ shadow * (diff * lightColor.rgb * texColor.rgb + spec * lightColor.rgb);
|
||||
|
||||
result *= max(VertColor.rgb, vec3(0.5));
|
||||
}
|
||||
|
||||
float dist = length(viewPos.xyz - FragPos);
|
||||
float fogFactor = clamp((fogParams.y - dist) / (fogParams.y - fogParams.x), 0.0, 1.0);
|
||||
result = mix(fogColor.rgb, result, fogFactor);
|
||||
|
||||
outColor = vec4(result, texColor.a);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue