Made ability to define custom material shaders for ProcessMaterial function

# Conflicts:
#	src/r_data/gldefs.cpp
This commit is contained in:
usernameak 2018-07-05 15:01:16 +03:00 committed by drfrag666
parent 4c106de5d7
commit 5cddbe4a16
2 changed files with 11 additions and 2 deletions

View file

@ -600,6 +600,7 @@ static const FDefaultShader defaultshaders[]=
};
TArray<FString> usershaders;
TArray<FString> usermaterials;
struct FEffectShader
{
@ -750,7 +751,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
FString name = ExtractFileBase(usershaders[i]);
FName sfn = name;
FShader *shc = Compile(sfn, usershaders[i], "shaders/glsl/material_normal.fp", "", true, passType);
FShader *shc = Compile(sfn, usershaders[i], usermaterials[i], "", true, passType);
mMaterialShaders.Push(shc);
}

View file

@ -57,6 +57,7 @@ void AddLightAssociation(const char *actor, const char *frame, const char *light
void InitializeActorLights(TArray<FLightAssociation> &LightAssociations);
extern TArray<FString> usershaders;
extern TArray<FString> usermaterials;
extern TDeletingArray<FLightDefaults *> LightDefaults;
@ -1384,6 +1385,7 @@ class GLDefsParser
bool iwad = false;
int maplump = -1;
FString maplumpname;
FString materiallumpname = "shaders/glsl/material_normal.fp";
float speed = 1.f;
sc.MustGetString();
@ -1399,6 +1401,11 @@ class GLDefsParser
sc.MustGetString();
maplumpname = sc.String;
}
else if (sc.Compare("material"))
{
sc.MustGetString();
materiallumpname = sc.String;
}
else if (sc.Compare("speed"))
{
sc.MustGetFloat();
@ -1438,13 +1445,14 @@ class GLDefsParser
tex->gl_info.shaderspeed = speed;
for (unsigned i = 0; i < usershaders.Size(); i++)
{
if (!usershaders[i].CompareNoCase(maplumpname))
if (!usershaders[i].CompareNoCase(maplumpname) && !usermaterials[i].CompareNoCase(materiallumpname))
{
tex->gl_info.shaderindex = i + FIRST_USER_SHADER;
return;
}
}
tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER;
usermaterials.Push(materiallumpname);
}
}
}