- added objectcolor uniform. This will be used to hold the thingcolor for shader based rendering.

This commit is contained in:
Christoph Oelckers 2014-05-11 16:06:25 +02:00
parent f3a9cb0cfa
commit 53f4cd0108
10 changed files with 43 additions and 15 deletions

View file

@ -234,14 +234,6 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u
{ {
gl_RenderState.BlendEquation(GL_FUNC_ADD); 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); glColor3f(r,g,b);
return true; return true;
} }

View file

@ -78,6 +78,7 @@ void FRenderState::Reset()
mAlphaFunc = GL_GEQUAL; mAlphaFunc = GL_GEQUAL;
mAlphaThreshold = 0.5f; mAlphaThreshold = 0.5f;
mBlendEquation = GL_FUNC_ADD; mBlendEquation = GL_FUNC_ADD;
mObjectColor = 0xffffffff;
glBlendEquation = -1; glBlendEquation = -1;
m2D = true; m2D = true;
mVertexBuffer = mCurrentVertexBuffer = NULL; mVertexBuffer = mCurrentVertexBuffer = NULL;
@ -158,6 +159,7 @@ bool FRenderState::ApplyShader()
if (activeShader) if (activeShader)
{ {
int fogset = 0; int fogset = 0;
//glColor4fv(mColor.vec);
if (mFogEnabled) if (mFogEnabled)
{ {
if ((mFogColor & 0xffffff) == 0) if ((mFogColor & 0xffffff) == 0)
@ -226,6 +228,11 @@ bool FRenderState::ApplyShader()
{ {
glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight); 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; return true;
} }
@ -276,6 +283,8 @@ void FRenderState::Apply(bool forcenoshader)
} }
if (forcenoshader || !ApplyShader()) if (forcenoshader || !ApplyShader())
{ {
//if (mColor.vec[0] >= 0.f) glColor4fv(mColor.vec);
GLRenderer->mShaderManager->SetActiveShader(NULL); GLRenderer->mShaderManager->SetActiveShader(NULL);
if (mTextureMode != ffTextureMode) if (mTextureMode != ffTextureMode)
{ {

View file

@ -107,11 +107,12 @@ class FRenderState
bool m2D; bool m2D;
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
FStateVec4 mColor;
FStateVec3 mCameraPos; FStateVec3 mCameraPos;
FStateVec4 mGlowTop, mGlowBottom; FStateVec4 mGlowTop, mGlowBottom;
FStateVec4 mGlowTopPlane, mGlowBottomPlane; FStateVec4 mGlowTopPlane, mGlowBottomPlane;
PalEntry mFogColor; PalEntry mFogColor;
PalEntry mObjectColor;
float mFogDensity; float mFogDensity;
int mEffectState; int mEffectState;
@ -149,6 +150,26 @@ public:
mVertexBuffer = vb; 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) void SetTextureMode(int mode)
{ {
mTextureMode = mode; mTextureMode = mode;

View file

@ -325,7 +325,6 @@ void GLFlat::DrawSubsectors(int pass, bool istrans)
{ {
if (gl_usevbo && vboindex >= 0) if (gl_usevbo && vboindex >= 0)
{ {
//glColor3f( 1.f,.5f,.5f);
int index = vboindex; int index = vboindex;
for (int i=0; i<sector->subsectorcount; i++) for (int i=0; i<sector->subsectorcount; i++)
{ {

View file

@ -749,7 +749,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
if (gl_enhanced_nightvision && if (gl_enhanced_nightvision &&
(thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE)) (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;
} }
} }
} }

View file

@ -373,6 +373,7 @@ void GLWall::RenderFogBoundary()
gl_RenderState.AlphaFunc(GL_GREATER,0); gl_RenderState.AlphaFunc(GL_GREATER,0);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glColor4f(fc[0],fc[1],fc[2], fogd1); 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. if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun.
flags &= ~GLWF_GLOW; flags &= ~GLWF_GLOW;

View file

@ -40,7 +40,9 @@ class FShader
int glowtopcolor_index; int glowtopcolor_index;
int glowbottomplane_index; int glowbottomplane_index;
int glowtopplane_index; int glowtopplane_index;
int objectcolor_index;
PalEntry currentobjectcolor;
int currentglowstate; int currentglowstate;
int currentfogenabled; int currentfogenabled;
int currenttexturemode; int currenttexturemode;
@ -59,7 +61,7 @@ public:
currentglowstate = currentfogenabled = currenttexturemode = 0; currentglowstate = currentfogenabled = currenttexturemode = 0;
currentlightfactor = currentlightdist = 0.0f; currentlightfactor = currentlightdist = 0.0f;
currentfogdensity = -1; currentfogdensity = -1;
currentfogcolor = 0; currentobjectcolor = currentfogcolor = 0;
timer_index = -1; timer_index = -1;
desaturation_index = -1; desaturation_index = -1;
@ -73,6 +75,7 @@ public:
fogcolor_index = -1; fogcolor_index = -1;
lights_index = -1; lights_index = -1;
dlightcolor_index = -1; dlightcolor_index = -1;
objectcolor_index = -1;
glowtopplane_index = -1; glowtopplane_index = -1;
glowbottomplane_index = -1; glowbottomplane_index = -1;
glowtopcolor_index = -1; glowtopcolor_index = -1;

View file

@ -1,6 +1,6 @@
vec4 Process(vec4 color) vec4 Process(vec4 color)
{ {
return color; return color*objectcolor;
} }

View file

@ -23,6 +23,7 @@ uniform vec4 lights[128];
uniform int fogenabled; uniform int fogenabled;
uniform vec4 fogcolor; uniform vec4 fogcolor;
uniform vec4 objectcolor;
uniform vec3 dlightcolor; uniform vec3 dlightcolor;
uniform vec3 camerapos; uniform vec3 camerapos;
varying vec4 pixelpos; varying vec4 pixelpos;
@ -158,7 +159,7 @@ vec4 getTexel(vec2 st)
} }
#endif #endif
return desaturate(texel); return desaturate(texel * objectcolor);
} }
//=========================================================================== //===========================================================================

View file

@ -1,6 +1,7 @@
uniform int texturemode; uniform int texturemode;
uniform sampler2D tex; uniform sampler2D tex;
uniform vec4 objectcolor;
uniform vec3 colormapstart; uniform vec3 colormapstart;
uniform vec3 colormaprange; uniform vec3 colormaprange;
@ -28,7 +29,7 @@ vec4 getTexel(vec2 st)
texel.rgb = vec3(1.0,1.0,1.0); texel.rgb = vec3(1.0,1.0,1.0);
} }
return texel; return texel*objectcolor;
} }