1
0
forked from 0ad/0ad

Apply unit shading colour in shader renderpath.

Don't adjust the shading colour of units in FoW (the shading comes from
the LOS texture instead).

This was SVN commit r9142.
This commit is contained in:
Ykkrosh 2011-04-02 12:04:19 +00:00
parent 012c47057a
commit 97c934ad1c
9 changed files with 27 additions and 17 deletions

View File

@ -17,7 +17,8 @@
PARAM objectColor = program.local[0];
#endif
PARAM ambient = program.local[1];
PARAM shadingColor = program.local[1];
PARAM ambient = program.local[2];
TEMP tex;
TEMP temp;
@ -59,6 +60,6 @@ TEX tex, fragment.texcoord[0], texture[0], 2D;
TEX tex.a, fragment.texcoord[2], texture[2], 2D;
MUL color.rgb, color, tex.a;
MOV result.color.rgb, color;
MUL result.color.rgb, color, shadingColor;
END

View File

@ -17,7 +17,8 @@
<uniform name="losTex" loc="2" type="sampler2D"/>
<uniform name="objectColor" loc="0" type="vec3"/>
<uniform name="ambient" loc="1" type="vec3"/>
<uniform name="shadingColor" loc="1" type="vec3"/>
<uniform name="ambient" loc="2" type="vec3"/>
</fragment>
</program>

View File

@ -20,7 +20,8 @@
<uniform name="losTex" loc="2" type="sampler2D"/>
<uniform name="objectColor" loc="0" type="vec3"/>
<uniform name="ambient" loc="1" type="vec3"/>
<uniform name="shadingColor" loc="1" type="vec3"/>
<uniform name="ambient" loc="2" type="vec3"/>
</fragment>
</program>

View File

@ -15,6 +15,10 @@
PARAM ambient = program.local[0];
#ifdef DECAL
PARAM shadingColor = program.local[1];
#endif
TEMP tex;
TEMP temp;
TEMP diffuse;
@ -57,6 +61,10 @@ TEX color, fragment.texcoord[0], texture[0], 2D;
TEX tex.a, fragment.texcoord[3], texture[3], 2D;
MUL color.rgb, color, tex.a;
MOV result.color.rgb, color;
#ifdef DECAL
MUL result.color.rgb, color, shadingColor;
#else
MOV result.color.rgb, color;
#endif
END

View File

@ -15,6 +15,7 @@
<uniform name="losTex" loc="3" type="sampler2D"/>
<uniform name="ambient" loc="0" type="vec3"/>
<uniform name="shadingColor" loc="1" type="vec3"/>
</fragment>
</program>

View File

@ -66,7 +66,7 @@ void CDecalRData::Update()
}
}
void CDecalRData::Render()
void CDecalRData::Render(const CShaderProgramPtr& shader)
{
m_Decal->m_Decal.m_Texture->Bind(0);
@ -86,9 +86,10 @@ void CDecalRData::Render()
u8* indexBase = m_IndexArray.Bind();
// TODO: make the shading color available to shader-based rendering
// (which uses the color array) too
glColor3fv(m_Decal->GetShadingColor().FloatArray());
if (!shader)
glColor3fv(m_Decal->GetShadingColor().FloatArray());
else
shader->Uniform("shadingColor", m_Decal->GetShadingColor());
glVertexPointer(3, GL_FLOAT, stride, base + m_Position.offset);
glColorPointer(4, GL_UNSIGNED_BYTE, stride, base + m_DiffuseColor.offset);

View File

@ -19,6 +19,7 @@
#define INCLUDED_DECALRDATA
#include "graphics/RenderableObject.h"
#include "graphics/ShaderProgram.h"
#include "renderer/VertexArray.h"
class CModelDecal;
@ -31,7 +32,7 @@ public:
void Update();
void Render();
void Render(const CShaderProgramPtr& shader);
private:
void BuildArrays();

View File

@ -256,7 +256,7 @@ void TerrainRenderer::RenderTerrain(ShadowMap* shadow)
PROFILE_START("render terrain decals");
for (size_t i = 0; i < m->visibleDecals.size(); ++i)
m->visibleDecals[i]->Render();
m->visibleDecals[i]->Render(CShaderProgramPtr());
PROFILE_END("render terrain decals");
@ -608,7 +608,7 @@ void TerrainRenderer::RenderTerrainShader(ShadowMap* shadow)
PROFILE_START("render terrain decals");
for (size_t i = 0; i < m->visibleDecals.size(); ++i)
m->visibleDecals[i]->Render();
m->visibleDecals[i]->Render(shaderDecal);
PROFILE_END("render terrain decals");
shaderDecal->Unbind();

View File

@ -455,11 +455,7 @@ void CCmpVisualActor::Interpolate(float frameTime, float frameOffset)
if (m_Visibility != ICmpRangeManager::VIS_HIDDEN)
{
model.ValidatePosition();
if (m_Visibility == ICmpRangeManager::VIS_FOGGED)
model.SetShadingColor(CColor(0.5f * m_R.ToFloat(), 0.5f * m_G.ToFloat(), 0.5f * m_B.ToFloat(), 1.0f));
else
model.SetShadingColor(CColor(m_R.ToFloat(), m_G.ToFloat(), m_B.ToFloat(), 1.0f));
model.SetShadingColor(CColor(m_R.ToFloat(), m_G.ToFloat(), m_B.ToFloat(), 1.0f));
}
}