Skip to content
Permalink
Browse files
Add resolution uniform for sprite and mesh shaders (#2031)
The landscape shader already has such a uniform.
  • Loading branch information
lluchs committed Apr 18, 2018
1 parent 9a6772c commit 9fed69f3fab42e2942618d759da866763e8c276b
Showing with 8 additions and 0 deletions.
  1. +5 −0 src/graphics/C4DrawGL.cpp
  2. +1 −0 src/graphics/C4DrawGL.h
  3. +1 −0 src/graphics/C4DrawMeshGL.cpp
  4. +1 −0 src/lib/StdMeshMaterial.cpp
@@ -203,6 +203,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
uniformNames[C4SSU_NormalMatrix] = "normalMatrix";
uniformNames[C4SSU_ClrMod] = "clrMod";
uniformNames[C4SSU_Gamma] = "gamma";
uniformNames[C4SSU_Resolution] = "resolution";
uniformNames[C4SSU_BaseTex] = "baseTex";
uniformNames[C4SSU_OverlayTex] = "overlayTex";
uniformNames[C4SSU_OverlayClr] = "overlayClr";
@@ -609,6 +610,10 @@ void CStdGL::PerformMultiBlt(C4Surface* sfcTarget, DrawOperation op, const C4Blt
assert(sfcTarget->IsRenderTarget());
if(!PrepareRendering(sfcTarget)) return;

// Set resolution. The other uniforms are set in SetupMultiBlt, but the
// surface size is still unknown there.
shader_call->SetUniform2f(C4SSU_Resolution, sfcTarget->Wdt, sfcTarget->Hgt);

// Select a buffer
const unsigned int vbo_index = CurrentVBO;
CurrentVBO = (CurrentVBO + 1) % N_GENERIC_VBOS;
@@ -55,6 +55,7 @@ enum C4SS_Uniforms

C4SSU_ClrMod, // always
C4SSU_Gamma, // always
C4SSU_Resolution, // always

C4SSU_BaseTex, // C4SSC_BASE
C4SSU_OverlayTex, // C4SSC_OVERLAY
@@ -513,6 +513,7 @@ namespace
};
call.SetUniform4fv(C4SSU_ClrMod, 1, fMod);
call.SetUniform3fv(C4SSU_Gamma, 1, pDraw->gammaOut);
call.SetUniform2f(C4SSU_Resolution, outRect.Wdt, outRect.Hgt);

// Player color
const float fPlrClr[3] = {
@@ -852,6 +852,7 @@ bool StdMeshMaterialProgram::CompileShader(StdMeshMaterialLoader& loader, C4Shad
uniformNames[C4SSU_NormalMatrix] = "normalMatrix";
uniformNames[C4SSU_ClrMod] = "clrMod";
uniformNames[C4SSU_Gamma] = "gamma";
uniformNames[C4SSU_Resolution] = "resolution";
uniformNames[C4SSU_BaseTex] = "baseTex"; // unused
uniformNames[C4SSU_OverlayTex] = "overlayTex"; // unused
uniformNames[C4SSU_OverlayClr] = "oc_PlayerColor";

0 comments on commit 9fed69f

Please sign in to comment.