mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- added objectcolor uniform. This will be used to hold the thingcolor for shader based rendering.
This commit is contained in:
parent
f3a9cb0cfa
commit
53f4cd0108
10 changed files with 43 additions and 15 deletions
|
@ -234,14 +234,6 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u
|
|||
{
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
}
|
||||
if (desaturation>0)
|
||||
{
|
||||
float gray=(r*77 + g*143 + b*37)/257;
|
||||
|
||||
r= (r*(32-desaturation)+ gray*desaturation)/32;
|
||||
g= (g*(32-desaturation)+ gray*desaturation)/32;
|
||||
b= (b*(32-desaturation)+ gray*desaturation)/32;
|
||||
}
|
||||
glColor3f(r,g,b);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ void FRenderState::Reset()
|
|||
mAlphaFunc = GL_GEQUAL;
|
||||
mAlphaThreshold = 0.5f;
|
||||
mBlendEquation = GL_FUNC_ADD;
|
||||
mObjectColor = 0xffffffff;
|
||||
glBlendEquation = -1;
|
||||
m2D = true;
|
||||
mVertexBuffer = mCurrentVertexBuffer = NULL;
|
||||
|
@ -158,6 +159,7 @@ bool FRenderState::ApplyShader()
|
|||
if (activeShader)
|
||||
{
|
||||
int fogset = 0;
|
||||
//glColor4fv(mColor.vec);
|
||||
if (mFogEnabled)
|
||||
{
|
||||
if ((mFogColor & 0xffffff) == 0)
|
||||
|
@ -226,6 +228,11 @@ bool FRenderState::ApplyShader()
|
|||
{
|
||||
glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight);
|
||||
}
|
||||
if (mObjectColor != activeShader->currentobjectcolor)
|
||||
{
|
||||
activeShader->currentobjectcolor = mObjectColor;
|
||||
glUniform4f(activeShader->objectcolor_index, mObjectColor.r / 255.f, mObjectColor.g / 255.f, mObjectColor.b / 255.f, mObjectColor.a / 255.f);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -276,6 +283,8 @@ void FRenderState::Apply(bool forcenoshader)
|
|||
}
|
||||
if (forcenoshader || !ApplyShader())
|
||||
{
|
||||
//if (mColor.vec[0] >= 0.f) glColor4fv(mColor.vec);
|
||||
|
||||
GLRenderer->mShaderManager->SetActiveShader(NULL);
|
||||
if (mTextureMode != ffTextureMode)
|
||||
{
|
||||
|
|
|
@ -107,11 +107,12 @@ class FRenderState
|
|||
bool m2D;
|
||||
|
||||
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
||||
|
||||
FStateVec4 mColor;
|
||||
FStateVec3 mCameraPos;
|
||||
FStateVec4 mGlowTop, mGlowBottom;
|
||||
FStateVec4 mGlowTopPlane, mGlowBottomPlane;
|
||||
PalEntry mFogColor;
|
||||
PalEntry mObjectColor;
|
||||
float mFogDensity;
|
||||
|
||||
int mEffectState;
|
||||
|
@ -149,6 +150,26 @@ public:
|
|||
mVertexBuffer = vb;
|
||||
}
|
||||
|
||||
void SetColor(float r, float g, float b, float a = 1.f, int desat = 0)
|
||||
{
|
||||
mColor.Set(r, g, b, a);
|
||||
}
|
||||
|
||||
void SetColor(PalEntry pe, int desat = 0)
|
||||
{
|
||||
mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, pe.a/255.f);
|
||||
}
|
||||
|
||||
void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0)
|
||||
{
|
||||
mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, alpha);
|
||||
}
|
||||
|
||||
void ResetColor()
|
||||
{
|
||||
mColor.Set(1,1,1,1);
|
||||
}
|
||||
|
||||
void SetTextureMode(int mode)
|
||||
{
|
||||
mTextureMode = mode;
|
||||
|
|
|
@ -325,7 +325,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans)
|
|||
{
|
||||
if (gl_usevbo && vboindex >= 0)
|
||||
{
|
||||
//glColor3f( 1.f,.5f,.5f);
|
||||
int index = vboindex;
|
||||
for (int i=0; i<sector->subsectorcount; i++)
|
||||
{
|
||||
|
|
|
@ -749,7 +749,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
if (gl_enhanced_nightvision &&
|
||||
(thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE))
|
||||
{
|
||||
Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP;
|
||||
// needs to be fixed later
|
||||
//Colormap.colormap = CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,6 +373,7 @@ void GLWall::RenderFogBoundary()
|
|||
gl_RenderState.AlphaFunc(GL_GREATER,0);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glColor4f(fc[0],fc[1],fc[2], fogd1);
|
||||
gl_RenderState.SetColor(-1, 0, 0, 0); // we do not want the render state to control the color.
|
||||
if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun.
|
||||
|
||||
flags &= ~GLWF_GLOW;
|
||||
|
|
|
@ -40,7 +40,9 @@ class FShader
|
|||
int glowtopcolor_index;
|
||||
int glowbottomplane_index;
|
||||
int glowtopplane_index;
|
||||
int objectcolor_index;
|
||||
|
||||
PalEntry currentobjectcolor;
|
||||
int currentglowstate;
|
||||
int currentfogenabled;
|
||||
int currenttexturemode;
|
||||
|
@ -59,7 +61,7 @@ public:
|
|||
currentglowstate = currentfogenabled = currenttexturemode = 0;
|
||||
currentlightfactor = currentlightdist = 0.0f;
|
||||
currentfogdensity = -1;
|
||||
currentfogcolor = 0;
|
||||
currentobjectcolor = currentfogcolor = 0;
|
||||
|
||||
timer_index = -1;
|
||||
desaturation_index = -1;
|
||||
|
@ -73,6 +75,7 @@ public:
|
|||
fogcolor_index = -1;
|
||||
lights_index = -1;
|
||||
dlightcolor_index = -1;
|
||||
objectcolor_index = -1;
|
||||
glowtopplane_index = -1;
|
||||
glowbottomplane_index = -1;
|
||||
glowtopcolor_index = -1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
vec4 Process(vec4 color)
|
||||
{
|
||||
return color;
|
||||
return color*objectcolor;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ uniform vec4 lights[128];
|
|||
|
||||
uniform int fogenabled;
|
||||
uniform vec4 fogcolor;
|
||||
uniform vec4 objectcolor;
|
||||
uniform vec3 dlightcolor;
|
||||
uniform vec3 camerapos;
|
||||
varying vec4 pixelpos;
|
||||
|
@ -158,7 +159,7 @@ vec4 getTexel(vec2 st)
|
|||
}
|
||||
#endif
|
||||
|
||||
return desaturate(texel);
|
||||
return desaturate(texel * objectcolor);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
uniform int texturemode;
|
||||
uniform sampler2D tex;
|
||||
|
||||
uniform vec4 objectcolor;
|
||||
uniform vec3 colormapstart;
|
||||
uniform vec3 colormaprange;
|
||||
|
||||
|
@ -28,7 +29,7 @@ vec4 getTexel(vec2 st)
|
|||
texel.rgb = vec3(1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
return texel;
|
||||
return texel*objectcolor;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue