Assests and shader for fireplace particle example
This commit is contained in:
parent
1d987dd040
commit
40ca99955b
11 changed files with 201 additions and 0 deletions
44
data/shaders/particlefire/normalmap.frag
Normal file
44
data/shaders/particlefire/normalmap.frag
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D sColorMap;
|
||||
layout (binding = 2) uniform sampler2D sNormalHeightMap;
|
||||
|
||||
#define lightRadius 35.0
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inLightVec;
|
||||
layout (location = 2) in vec3 inLightVecB;
|
||||
layout (location = 5) in vec3 inLightDir;
|
||||
layout (location = 6) in vec3 inViewVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 specularColor = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
float invRadius = 1.0/lightRadius;
|
||||
float ambient = 0.0;
|
||||
|
||||
vec3 rgb, normal;
|
||||
|
||||
rgb = texture(sColorMap, inUV).rgb;
|
||||
normal = normalize((texture(sNormalHeightMap, inUV).rgb - 0.5) * 2.0);
|
||||
|
||||
float distSqr = dot(inLightVecB, inLightVecB);
|
||||
vec3 lVec = inLightVecB * inversesqrt(distSqr);
|
||||
|
||||
float atten = max(clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0), ambient);
|
||||
float diffuse = clamp(dot(lVec, normal), 0.0, 1.0);
|
||||
|
||||
vec3 light = normalize(-inLightVec);
|
||||
vec3 view = normalize(inViewVec);
|
||||
vec3 reflectDir = reflect(-light, normal);
|
||||
|
||||
float specular = pow(max(dot(view, reflectDir), 0.0), 8.0);
|
||||
|
||||
outFragColor = vec4((rgb * atten + (diffuse * rgb + 0.5 * specular * specularColor.rgb)) * atten, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue