Particles now correctly update with the fog. Refs #276 .
This was SVN commit r12811.
This commit is contained in:
parent
9930500661
commit
d75ae52f56
@ -5,7 +5,26 @@ uniform sampler2D baseTex;
|
||||
varying vec2 v_tex;
|
||||
varying vec4 v_color;
|
||||
|
||||
uniform vec3 fogColor;
|
||||
uniform vec2 fogParams;
|
||||
|
||||
vec4 get_fog(vec4 color)
|
||||
{
|
||||
float density = fogParams.x;
|
||||
float maxFog = fogParams.y;
|
||||
|
||||
const float LOG2 = 1.442695;
|
||||
float z = gl_FragCoord.z / gl_FragCoord.w;
|
||||
float fogFactor = exp2(-density * density * z * z * LOG2);
|
||||
|
||||
fogFactor = fogFactor * (1.0 - maxFog) + maxFog;
|
||||
|
||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
|
||||
return vec4(mix(fogColor, color.rgb, fogFactor),color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(baseTex, v_tex) * v_color;
|
||||
gl_FragColor = get_fog(texture2D(baseTex, v_tex) * v_color);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "graphics/ParticleEmitterType.h"
|
||||
#include "graphics/ParticleManager.h"
|
||||
#include "graphics/TextureManager.h"
|
||||
#include "graphics/LightEnv.h"
|
||||
|
||||
#include "renderer/Renderer.h"
|
||||
|
||||
@ -165,6 +166,8 @@ void CParticleEmitter::UpdateArrayData()
|
||||
void CParticleEmitter::Bind(const CShaderProgramPtr& shader)
|
||||
{
|
||||
shader->BindTexture("baseTex", m_Type->m_Texture);
|
||||
shader->Uniform("fogColor", g_Renderer.GetLightEnv().m_FogColor);
|
||||
shader->Uniform("fogParams", g_Renderer.GetLightEnv().m_FogFactor, g_Renderer.GetLightEnv().m_FogMax, 0.f, 0.f);
|
||||
pglBlendEquationEXT(m_Type->m_BlendEquation);
|
||||
glBlendFunc(m_Type->m_BlendFuncSrc, m_Type->m_BlendFuncDst);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user