Made ability to define custom material shaders for ProcessMaterial function

This commit is contained in:
usernameak 2018-07-05 15:01:16 +03:00 committed by Christoph Oelckers
parent 292458ee2d
commit fa51a54042
2 changed files with 11 additions and 2 deletions

View file

@ -496,6 +496,7 @@ static const FDefaultShader defaultshaders[]=
}; };
TArray<FString> usershaders; TArray<FString> usershaders;
TArray<FString> usermaterials;
struct FEffectShader struct FEffectShader
{ {
@ -647,7 +648,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
FString name = ExtractFileBase(usershaders[i]); FString name = ExtractFileBase(usershaders[i]);
FName sfn = name; 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); mMaterialShaders.Push(shc);
} }

View file

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