GL: Add "frameCounter" uniform

Add the current frame counter as a uniform variable to the shaders, so
people can use it to do time-based animation.
liquid_container
Nicolas Hake 2016-03-31 01:44:44 +02:00
parent cd0032ccf0
commit 33b8d404a5
4 changed files with 7 additions and 0 deletions

View File

@ -227,6 +227,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
uniformNames[C4SSU_MaterialShininess] = "materialShininess"; // unused
uniformNames[C4SSU_Bones] = "bones"; // unused
uniformNames[C4SSU_CullMode] = "cullMode"; // unused
uniformNames[C4SSU_FrameCounter] = "frameCounter";
uniformNames[C4SSU_Count] = NULL;
const char* attributeNames[C4SSA_Count + 1];

View File

@ -77,6 +77,8 @@ enum C4SS_Uniforms
C4SSU_Bones, // for meshes
C4SSU_CullMode, // for meshes
C4SSU_FrameCounter, // for custom shaders
C4SSU_Count
};

View File

@ -538,6 +538,9 @@ namespace
pFoW->getFoW()->Ambient.GetFragTransform(pFoW->getViewportRegion(), clipRect, outRect, ambientTransform);
call.SetUniformMatrix2x3fv(C4SSU_AmbientTransform, 1, ambientTransform);
}
// Current frame counter
call.SetUniform1i(C4SSU_FrameCounter, ::Game.FrameCounter);
}
bool ResolveAutoParameter(C4ShaderCall& call, StdMeshMaterialShaderParameter& parameter, StdMeshMaterialShaderParameter::Auto value, DWORD dwModClr, DWORD dwPlayerColor, DWORD dwBlitMode, const C4FoWRegion* pFoW, const C4Rect& clipRect)

View File

@ -885,6 +885,7 @@ bool StdMeshMaterialProgram::CompileShader(StdMeshMaterialLoader& loader, C4Shad
uniformNames[C4SSU_MaterialShininess] = "materialShininess";
uniformNames[C4SSU_Bones] = "bones";
uniformNames[C4SSU_CullMode] = "cullMode";
uniformNames[C4SSU_FrameCounter] = "frameCounter";
for (unsigned int i = 0; i < ParameterNames.size(); ++i)
uniformNames[C4SSU_Count + i] = ParameterNames[i].getData();
uniformNames[C4SSU_Count + ParameterNames.size()] = NULL;