Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix particle to correctly display in the FOW, and to adapt slightly t…

…o sunColor settings (both on ARB and GLSL).

git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@13287 3db68df2-c116-0410-a063-a993310a9797
  • Loading branch information...
commit a53ed8395198f9437564dfe0d9a8dea3e00f6786 1 parent 73edd3c
wraitii authored
20 binaries/data/mods/public/shaders/arb/particle.fp
View
@@ -1,7 +1,23 @@
!!ARBfp1.0
-TEMP tex;
+
+ATTRIB v_los = fragment.texcoord[1];
+PARAM sunColor = program.local[0];
+
+TEMP tex, losTex, color;
TEX tex, fragment.texcoord[0], texture[0], 2D;
-MUL result.color, tex, fragment.color;
+
+TEMP temp;
+MOV temp, 0.5;
+
+ADD color.rgb, fragment.color, sunColor;
+MUL color.rgb, color, temp;
+
+MUL color.rgb, color, tex;
+
+// Multiply everything by the LOS texture
+TEX losTex, v_los, texture[1], 2D;
+MUL result.color.rgb, color, losTex.a;
+MUL result.color.a, tex, fragment.color;
END
6 binaries/data/mods/public/shaders/arb/particle.vp
View
@@ -3,6 +3,8 @@ ATTRIB uv = vertex.texcoord[0];
ATTRIB offset = vertex.texcoord[1];
PARAM axis1 = state.matrix.modelview.row[0];
PARAM axis2 = state.matrix.modelview.row[1];
+PARAM losTransform = program.local[0];
+
TEMP position;
MAD position.xyz, axis1, offset.x, vertex.position;
@@ -16,8 +18,8 @@ DP4 result.position.y, state.matrix.mvp.row[1], position;
DP4 result.position.z, state.matrix.mvp.row[2], position;
DP4 result.position.w, state.matrix.mvp.row[3], position;
-MOV result.texcoord, uv;
-
+MOV result.texcoord[0], uv;
MOV result.color, vertex.color;
+MAD result.texcoord[1], vertex.position.xzzz, losTransform.x, losTransform.y;
END
3  binaries/data/mods/public/shaders/arb/particle.xml
View
@@ -6,10 +6,13 @@
<stream name="color"/>
<stream name="uv0"/>
<stream name="uv1"/>
+ <uniform name="losTransform" loc="0" type="vec2"/>
</vertex>
<fragment file="arb/particle.fp">
<uniform name="baseTex" loc="0" type="sampler2D"/>
+ <uniform name="losTex" loc="1" type="sampler2D"/>
+ <uniform name="sunColor" loc="0" type="vec3"/>
</fragment>
</program>
11 binaries/data/mods/public/shaders/glsl/particle.fs
View
@@ -1,10 +1,13 @@
#version 110
uniform sampler2D baseTex;
+uniform sampler2D losTex;
varying vec2 v_tex;
+varying vec2 v_los;
varying vec4 v_color;
+uniform vec3 sunColor;
uniform vec3 fogColor;
uniform vec2 fogParams;
@@ -26,5 +29,11 @@ vec4 get_fog(vec4 color)
void main()
{
- gl_FragColor = get_fog(texture2D(baseTex, v_tex) * v_color);
+ vec4 color = texture2D(baseTex, v_tex) * vec4((v_color.rgb + sunColor)/2.0,v_color.a);
+
+ float los = texture2D(losTex, v_los).a;
+ los = los < 0.03 ? 0.0 : los;
+ color.rgb *= los;
+
+ gl_FragColor = get_fog(color);
}
5 binaries/data/mods/public/shaders/glsl/particle.vs
View
@@ -1,8 +1,10 @@
#version 110
uniform mat4 transform;
+uniform vec2 losTransform;
varying vec2 v_tex;
+varying vec2 v_los;
varying vec4 v_color;
attribute vec3 a_vertex;
@@ -19,7 +21,8 @@ void main()
vec3 position = axis1*offset.x + axis1*offset.y + axis2*offset.x + axis2*-offset.y + a_vertex;
gl_Position = transform * vec4(position, 1.0);
-
+
+ v_los = position.xz * losTransform.x + losTransform.y;
v_tex = a_uv0;
v_color = a_color;
}
12 source/graphics/ParticleEmitter.cpp
View
@@ -20,6 +20,7 @@
#include "ParticleEmitter.h"
#include "graphics/LightEnv.h"
+#include "graphics/LOSTexture.h"
#include "graphics/ParticleEmitterType.h"
#include "graphics/ParticleManager.h"
#include "graphics/TextureManager.h"
@@ -165,9 +166,16 @@ void CParticleEmitter::UpdateArrayData()
void CParticleEmitter::Bind(const CShaderProgramPtr& shader)
{
+ CLOSTexture& los = g_Renderer.GetScene().GetLOSTexture();
+ shader->BindTexture("losTex", los.GetTextureSmooth());
+ shader->Uniform("losTransform", los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
+
+ const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
+ shader->Uniform("sunColor", lightEnv.m_SunColor);
+ shader->Uniform("fogColor", lightEnv.m_FogColor);
+ shader->Uniform("fogParams", lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f);
+
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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.