- move glossiness and specular level to GLDEFS

This commit is contained in:
Magnus Norddahl 2018-01-25 19:53:55 +01:00
parent 0855418475
commit 7a59bcde4c
8 changed files with 33 additions and 1 deletions

View File

@ -87,6 +87,8 @@ void FRenderState::Reset()
mSpecialEffect = EFF_NONE;
mClipHeight = 0.f;
mClipHeightDirection = 0.f;
mGlossiness = 0.0f;
mSpecularLevel = 0.0f;
mShaderTimer = 0.0f;
ClearClipSplit();
@ -178,6 +180,7 @@ bool FRenderState::ApplyShader()
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
activeShader->muClipSplit.Set(mClipSplit);
activeShader->muViewHeight.Set(viewheight);
activeShader->muSpecularMaterial.Set(mGlossiness, mSpecularLevel);
if (mGlowEnabled)
{

View File

@ -94,6 +94,7 @@ class FRenderState
bool mLastDepthClamp;
float mInterpolationFactor;
float mClipHeight, mClipHeightDirection;
float mGlossiness, mSpecularLevel;
float mShaderTimer;
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
@ -152,6 +153,7 @@ public:
}
mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex;
mShaderTimer = mat->tex->gl_info.shaderspeed;
SetSpecular(mat->tex->gl_info.Glossiness, mat->tex->gl_info.SpecularLevel);
mat->Bind(clampmode, translation);
}
@ -386,6 +388,12 @@ public:
mObjectColor2 = pe;
}
void SetSpecular(float glossiness, float specularLevel)
{
mGlossiness = glossiness;
mSpecularLevel = specularLevel;
}
void SetFog(PalEntry c, float d)
{
const float LOG2E = 1.442692f; // = 1/log(2)

View File

@ -254,6 +254,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
muClipHeight.Init(hShader, "uClipHeight");
muClipHeightDirection.Init(hShader, "uClipHeightDirection");
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
muSpecularMaterial.Init(hShader, "uSpecularMaterial");
muViewHeight.Init(hShader, "uViewHeight");
muTimer.Init(hShader, "timer");

View File

@ -285,6 +285,7 @@ class FShader
FBufferedUniform1f muClipHeightDirection;
FBufferedUniform1f muAlphaThreshold;
FBufferedUniform1i muViewHeight;
FBufferedUniform2f muSpecularMaterial;
FBufferedUniform1f muTimer;
int lights_index;

View File

@ -191,6 +191,8 @@ FTexture::MiscGLInfo::MiscGLInfo() throw()
mIsTransparent = -1;
shaderspeed = 1.f;
shaderindex = 0;
Glossiness = 0.0f;
SpecularLevel = 0.0f;
Material[1] = Material[0] = NULL;
SystemTexture[1] = SystemTexture[0] = NULL;
@ -598,6 +600,18 @@ void gl_ParseMaterial(FScanner &sc, int deflump)
// only affects textures defined in the IWAD.
iwad = true;
}
else if (sc.Compare("glossiness"))
{
sc.MustGetFloat();
if (tex)
tex->gl_info.Glossiness = sc.Float;
}
else if (sc.Compare("specularlevel"))
{
sc.MustGetFloat();
if (tex)
tex->gl_info.SpecularLevel = sc.Float;
}
else
{
for (int i = 0; keywords[i] != nullptr; i++)

View File

@ -372,6 +372,8 @@ public:
FTexture *Metallic; // Metalness texture for the physically based rendering (PBR) light model
FTexture *Roughness; // Roughness texture for PBR
FTexture *AmbientOcclusion; // Ambient occlusion texture for PBR
float Glossiness;
float SpecularLevel;
PalEntry GlowColor;
int GlowHeight;
FloatRect *areas;

View File

@ -369,7 +369,7 @@ vec2 pointLightAttenuation(vec4 lightpos, float lightcolorA)
float diffuseAmount = diffuseContribution(lightDirection, pixelnormal);
#if defined(SPECULAR)
float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, 100.0, 200.0);
float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, uSpecularMaterial.x, uSpecularMaterial.y);
return vec2(diffuseAmount, specularAmount) * attenuation;
#else
return vec2(attenuation * diffuseAmount, 0.0);

View File

@ -51,6 +51,9 @@ uniform int uLightIndex;
// Software fuzz scaling
uniform int uViewHeight;
// Blinn glossiness and specular level
uniform vec2 uSpecularMaterial;
// quad drawer stuff
#ifdef USE_QUAD_DRAWER
uniform mat4 uQuadVertices;