mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Rename mTextureEffects to mMaterialShaders to help distinguish between those and effect shaders (mEffectShaders)
- Add MaterialShaderIndex enum
This commit is contained in:
parent
f3c55c01c8
commit
4dd2d789f4
3 changed files with 51 additions and 37 deletions
|
@ -376,8 +376,7 @@ struct FDefaultShader
|
||||||
const char * gettexelfunc;
|
const char * gettexelfunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: the FIRST_USER_SHADER constant in gl_shader.h needs
|
// Note: the ShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified.
|
||||||
// to be updated whenever the size of this array is modified.
|
|
||||||
static const FDefaultShader defaultshaders[]=
|
static const FDefaultShader defaultshaders[]=
|
||||||
{
|
{
|
||||||
{"Default", "shaders/glsl/func_normal.fp"},
|
{"Default", "shaders/glsl/func_normal.fp"},
|
||||||
|
@ -522,8 +521,8 @@ FShaderCollection::~FShaderCollection()
|
||||||
|
|
||||||
void FShaderCollection::CompileShaders(EPassType passType)
|
void FShaderCollection::CompileShaders(EPassType passType)
|
||||||
{
|
{
|
||||||
mTextureEffects.Clear();
|
mMaterialShaders.Clear();
|
||||||
mTextureEffectsNAT.Clear();
|
mMaterialShadersNAT.Clear();
|
||||||
for (int i = 0; i < MAX_EFFECTS; i++)
|
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||||
{
|
{
|
||||||
mEffectShaders[i] = NULL;
|
mEffectShaders[i] = NULL;
|
||||||
|
@ -532,11 +531,11 @@ void FShaderCollection::CompileShaders(EPassType passType)
|
||||||
for(int i=0;defaultshaders[i].ShaderName != NULL;i++)
|
for(int i=0;defaultshaders[i].ShaderName != NULL;i++)
|
||||||
{
|
{
|
||||||
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType);
|
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType);
|
||||||
mTextureEffects.Push(shc);
|
mMaterialShaders.Push(shc);
|
||||||
if (i <= 3)
|
if (i <= SHADER_Brightmap)
|
||||||
{
|
{
|
||||||
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType);
|
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType);
|
||||||
mTextureEffectsNAT.Push(shc);
|
mMaterialShadersNAT.Push(shc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +545,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
|
||||||
FName sfn = name;
|
FName sfn = name;
|
||||||
|
|
||||||
FShader *shc = Compile(sfn, usershaders[i], true, passType);
|
FShader *shc = Compile(sfn, usershaders[i], true, passType);
|
||||||
mTextureEffects.Push(shc);
|
mMaterialShaders.Push(shc);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<MAX_EFFECTS;i++)
|
for(int i=0;i<MAX_EFFECTS;i++)
|
||||||
|
@ -569,21 +568,21 @@ void FShaderCollection::CompileShaders(EPassType passType)
|
||||||
|
|
||||||
void FShaderCollection::Clean()
|
void FShaderCollection::Clean()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++)
|
for (unsigned int i = 0; i < mMaterialShadersNAT.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i];
|
if (mMaterialShadersNAT[i] != NULL) delete mMaterialShadersNAT[i];
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < mTextureEffects.Size(); i++)
|
for (unsigned int i = 0; i < mMaterialShaders.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mTextureEffects[i] != NULL) delete mTextureEffects[i];
|
if (mMaterialShaders[i] != NULL) delete mMaterialShaders[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < MAX_EFFECTS; i++)
|
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||||
{
|
{
|
||||||
if (mEffectShaders[i] != NULL) delete mEffectShaders[i];
|
if (mEffectShaders[i] != NULL) delete mEffectShaders[i];
|
||||||
mEffectShaders[i] = NULL;
|
mEffectShaders[i] = NULL;
|
||||||
}
|
}
|
||||||
mTextureEffects.Clear();
|
mMaterialShaders.Clear();
|
||||||
mTextureEffectsNAT.Clear();
|
mMaterialShadersNAT.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -596,9 +595,9 @@ int FShaderCollection::Find(const char * shn)
|
||||||
{
|
{
|
||||||
FName sfn = shn;
|
FName sfn = shn;
|
||||||
|
|
||||||
for(unsigned int i=0;i<mTextureEffects.Size();i++)
|
for(unsigned int i=0;i<mMaterialShaders.Size();i++)
|
||||||
{
|
{
|
||||||
if (mTextureEffects[i]->mName == sfn)
|
if (mMaterialShaders[i]->mName == sfn)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -636,19 +635,19 @@ void FShaderCollection::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
|
||||||
VSMatrix norm;
|
VSMatrix norm;
|
||||||
norm.computeNormalMatrix(*view);
|
norm.computeNormalMatrix(*view);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < SHADER_NoTexture; i++)
|
||||||
{
|
{
|
||||||
mTextureEffects[i]->ApplyMatrices(proj, view, &norm);
|
mMaterialShaders[i]->ApplyMatrices(proj, view, &norm);
|
||||||
mTextureEffectsNAT[i]->ApplyMatrices(proj, view, &norm);
|
mMaterialShadersNAT[i]->ApplyMatrices(proj, view, &norm);
|
||||||
}
|
}
|
||||||
mTextureEffects[4]->ApplyMatrices(proj, view, &norm);
|
mMaterialShaders[SHADER_NoTexture]->ApplyMatrices(proj, view, &norm);
|
||||||
if (gl_fuzztype != 0)
|
if (gl_fuzztype != 0)
|
||||||
{
|
{
|
||||||
mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view, &norm);
|
mMaterialShaders[SHADER_NoTexture + gl_fuzztype]->ApplyMatrices(proj, view, &norm);
|
||||||
}
|
}
|
||||||
for (unsigned i = 12; i < mTextureEffects.Size(); i++)
|
for (unsigned i = FIRST_USER_SHADER; i < mMaterialShaders.Size(); i++)
|
||||||
{
|
{
|
||||||
mTextureEffects[i]->ApplyMatrices(proj, view, &norm);
|
mMaterialShaders[i]->ApplyMatrices(proj, view, &norm);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < MAX_EFFECTS; i++)
|
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -355,8 +355,8 @@ private:
|
||||||
|
|
||||||
class FShaderCollection
|
class FShaderCollection
|
||||||
{
|
{
|
||||||
TArray<FShader*> mTextureEffects;
|
TArray<FShader*> mMaterialShaders;
|
||||||
TArray<FShader*> mTextureEffectsNAT;
|
TArray<FShader*> mMaterialShadersNAT;
|
||||||
FShader *mEffectShaders[MAX_EFFECTS];
|
FShader *mEffectShaders[MAX_EFFECTS];
|
||||||
|
|
||||||
void Clean();
|
void Clean();
|
||||||
|
@ -372,13 +372,13 @@ public:
|
||||||
|
|
||||||
void ResetFixedColormap()
|
void ResetFixedColormap()
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < mTextureEffects.Size(); i++)
|
for (unsigned i = 0; i < mMaterialShaders.Size(); i++)
|
||||||
{
|
{
|
||||||
mTextureEffects[i]->currentfixedcolormap = -1;
|
mMaterialShaders[i]->currentfixedcolormap = -1;
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < mTextureEffectsNAT.Size(); i++)
|
for (unsigned i = 0; i < mMaterialShadersNAT.Size(); i++)
|
||||||
{
|
{
|
||||||
mTextureEffectsNAT[i]->currentfixedcolormap = -1;
|
mMaterialShadersNAT[i]->currentfixedcolormap = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,17 +387,32 @@ public:
|
||||||
// indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom
|
// indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom
|
||||||
if (!alphateston && eff <= 3)
|
if (!alphateston && eff <= 3)
|
||||||
{
|
{
|
||||||
return mTextureEffectsNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway
|
return mMaterialShadersNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway
|
||||||
}
|
}
|
||||||
if (eff < mTextureEffects.Size())
|
if (eff < mMaterialShaders.Size())
|
||||||
{
|
{
|
||||||
return mTextureEffects[eff];
|
return mMaterialShaders[eff];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FIRST_USER_SHADER 12
|
enum MaterialShaderIndex
|
||||||
|
{
|
||||||
|
SHADER_Default = 0,
|
||||||
|
SHADER_Warp1 = 1,
|
||||||
|
SHADER_Warp2 = 2,
|
||||||
|
SHADER_Brightmap = 3,
|
||||||
|
SHADER_NoTexture = 4,
|
||||||
|
SHADER_BasicFuzz = 5,
|
||||||
|
SHADER_SmoothFuzz = 6,
|
||||||
|
SHADER_SwirlyFuzz = 7,
|
||||||
|
SHADER_TranslucentFuzz = 8,
|
||||||
|
SHADER_JaggedFuzz = 9,
|
||||||
|
SHADER_NoiseFuzz = 10,
|
||||||
|
SHADER_SmoothNoiseFuzz = 11,
|
||||||
|
FIRST_USER_SHADER = 12
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -438,7 +438,7 @@ int FMaterial::mMaxBound;
|
||||||
|
|
||||||
FMaterial::FMaterial(FTexture * tx, bool expanded)
|
FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
{
|
{
|
||||||
mShaderIndex = 0;
|
mShaderIndex = SHADER_Default;
|
||||||
tex = tx;
|
tex = tx;
|
||||||
|
|
||||||
// TODO: apply custom shader object here
|
// TODO: apply custom shader object here
|
||||||
|
@ -449,7 +449,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
*/
|
*/
|
||||||
if (tx->bWarped)
|
if (tx->bWarped)
|
||||||
{
|
{
|
||||||
mShaderIndex = tx->bWarped;
|
mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2
|
||||||
tx->gl_info.shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
|
tx->gl_info.shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
|
||||||
}
|
}
|
||||||
else if (tx->bHasCanvas)
|
else if (tx->bHasCanvas)
|
||||||
|
@ -474,7 +474,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
ValidateSysTexture(tx->gl_info.Brightmap, expanded);
|
ValidateSysTexture(tx->gl_info.Brightmap, expanded);
|
||||||
FTextureLayer layer = {tx->gl_info.Brightmap, false};
|
FTextureLayer layer = {tx->gl_info.Brightmap, false};
|
||||||
mTextureLayers.Push(layer);
|
mTextureLayers.Push(layer);
|
||||||
mShaderIndex = 3;
|
mShaderIndex = SHADER_Brightmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const
|
||||||
|
|
||||||
int FMaterial::GetAreas(FloatRect **pAreas) const
|
int FMaterial::GetAreas(FloatRect **pAreas) const
|
||||||
{
|
{
|
||||||
if (mShaderIndex == 0) // texture splitting can only be done if there's no attached effects
|
if (mShaderIndex == SHADER_Default) // texture splitting can only be done if there's no attached effects
|
||||||
{
|
{
|
||||||
FTexture *tex = mBaseLayer->tex;
|
FTexture *tex = mBaseLayer->tex;
|
||||||
*pAreas = tex->gl_info.areas;
|
*pAreas = tex->gl_info.areas;
|
||||||
|
|
Loading…
Reference in a new issue