Updated particle fire shaders (Fixes #259)
This commit is contained in:
parent
a88ddff390
commit
ef26748142
8 changed files with 45 additions and 41 deletions
|
|
@ -21,7 +21,7 @@ void main(void)
|
|||
vec3 specularColor = vec3(0.85, 0.5, 0.0);
|
||||
|
||||
float invRadius = 1.0/lightRadius;
|
||||
float ambient = 0.0;
|
||||
float ambient = 0.25;
|
||||
|
||||
vec3 rgb, normal;
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -18,6 +18,12 @@ layout (binding = 0) uniform UBO
|
|||
vec4 cameraPos;
|
||||
} ubo;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
};
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out vec3 outLightVec;
|
||||
layout (location = 2) out vec3 outLightVecB;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,10 +7,9 @@ layout (binding = 1) uniform sampler2D samplerSmoke;
|
|||
layout (binding = 2) uniform sampler2D samplerFire;
|
||||
|
||||
layout (location = 0) in vec4 inColor;
|
||||
layout (location = 1) in float inPointSize;
|
||||
layout (location = 2) in float inAlpha;
|
||||
layout (location = 3) in flat int inType;
|
||||
layout (location = 4) in float inRotation;
|
||||
layout (location = 1) in float inAlpha;
|
||||
layout (location = 2) in flat int inType;
|
||||
layout (location = 3) in float inRotation;
|
||||
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -11,10 +11,9 @@ layout (location = 4) in float inRotation;
|
|||
layout (location = 5) in int inType;
|
||||
|
||||
layout (location = 0) out vec4 outColor;
|
||||
layout (location = 1) out float outPointSize;
|
||||
layout (location = 2) out float outAlpha;
|
||||
layout (location = 3) out flat int outType;
|
||||
layout (location = 4) out float outRotation;
|
||||
layout (location = 1) out float outAlpha;
|
||||
layout (location = 2) out flat int outType;
|
||||
layout (location = 3) out float outRotation;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
|
|
@ -24,27 +23,27 @@ layout (binding = 0) uniform UBO
|
|||
float pointSize;
|
||||
} ubo;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
};
|
||||
|
||||
void main ()
|
||||
{
|
||||
gl_PointSize = ubo.pointSize;
|
||||
outColor = inColor;
|
||||
outAlpha = inAlpha;
|
||||
outType = inType;
|
||||
outRotation = inRotation;
|
||||
|
||||
vec4 eyePos = ubo.modelview * vec4(inPos.xyz, 1.0);
|
||||
vec4 projVoxel = ubo.projection * vec4(ubo.pointSize, ubo.pointSize, eyePos.z, eyePos.w);
|
||||
vec2 projSize = ubo.viewportDim * projVoxel.xy / projVoxel.w;
|
||||
|
||||
outPointSize = inSize * 0.25 * (projSize.x + projSize.y);
|
||||
|
||||
gl_PointSize = outPointSize;
|
||||
|
||||
gl_Position = ubo.projection * ubo.modelview * vec4(inPos.xyz, 1.0);
|
||||
|
||||
float pointDist = (gl_Position.w == 0.0) ? 0.00001 : gl_Position.w;
|
||||
float viewportAR = ubo.viewportDim.x / ubo.viewportDim.y;
|
||||
// Base size of the point sprites
|
||||
float spriteSize = 8.0 * inSize;
|
||||
|
||||
gl_PointSize = (((inSize * 2048.0 * viewportAR) / pointDist) * viewportAR);
|
||||
// Scale particle size depending on camera projection
|
||||
vec4 eyePos = ubo.modelview * vec4(inPos.xyz, 1.0);
|
||||
vec4 projectedCorner = ubo.projection * vec4(0.5 * spriteSize, 0.5 * spriteSize, eyePos.z, eyePos.w);
|
||||
gl_PointSize = ubo.viewportDim.x * projectedCorner.x / projectedCorner.w;
|
||||
|
||||
}
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue