Custom hardware shaders now can use custom texture units

This commit is contained in:
usernameak 2018-07-04 21:36:33 +03:00 committed by Christoph Oelckers
parent 2d0fb4ed2e
commit 292458ee2d
3 changed files with 29 additions and 0 deletions

View file

@ -154,6 +154,12 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
{
if (tx->shaderindex >= FIRST_USER_SHADER)
{
for (auto &texture : tx->CustomShaderTextures)
{
if(texture == nullptr) continue;
ValidateSysTexture(texture, expanded);
mTextureLayers.Push({ texture, false });
}
mShaderIndex = tx->shaderindex;
}
else

View file

@ -1398,6 +1398,24 @@ class GLDefsParser
sc.MustGetFloat();
speed = float(sc.Float);
}
else if (sc.Compare("texture"))
{
sc.MustGetString();
bool okay = false;
for(int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++) {
if(!tex->CustomShaderTextures[i]) {
tex->CustomShaderTextures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (!tex->CustomShaderTextures[i]) {
sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)");
}
okay = true;
break;
}
}
if(!okay) {
sc.ScriptError("Error: out of texture units in texture '%s'", tex? tex->Name.GetChars() : "(null)");
}
}
}
if (!tex)
{

View file

@ -44,6 +44,9 @@
#include "r_data/r_translate.h"
#include <vector>
// 15 because 0th texture is our texture
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15
typedef TMap<int, bool> SpriteHits;
enum MaterialShaderIndex
@ -244,6 +247,8 @@ public:
FTexture *Metallic = nullptr; // Metalness texture for the physically based rendering (PBR) light model
FTexture *Roughness = nullptr; // Roughness texture for PBR
FTexture *AmbientOcclusion = nullptr; // Ambient occlusion texture for PBR
FTexture *CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES] = { nullptr }; // Custom texture maps for custom hardware shaders
FString Name;
ETextureType UseType; // This texture's primary purpose