mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-04-25 00:41:15 +00:00
Disable user shaders for GLES2
This commit is contained in:
parent
7a050f7a6c
commit
87e1822b47
6 changed files with 50 additions and 10 deletions
|
@ -62,6 +62,7 @@ EXTERN_CVAR (Bool, vid_vsync)
|
|||
EXTERN_CVAR(Bool, r_drawvoxels)
|
||||
EXTERN_CVAR(Int, gl_tonemap)
|
||||
EXTERN_CVAR(Bool, cl_capfps)
|
||||
EXTERN_CVAR(Bool, gl_customshader)
|
||||
|
||||
void Draw2D(F2DDrawer *drawer, FRenderState &state);
|
||||
|
||||
|
@ -118,6 +119,8 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
{
|
||||
static bool first=true;
|
||||
|
||||
gl_customshader = false;
|
||||
|
||||
InitGLES();
|
||||
|
||||
// Move some state to the framebuffer object for easier access.
|
||||
|
|
|
@ -229,12 +229,15 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
|
|||
FString vert_prog_lump = vert_prog_lump_;
|
||||
FString frag_prog_lump = frag_prog_lump_;
|
||||
FString proc_prog_lump = proc_prog_lump_;
|
||||
FString light_fragprog = light_fragprog_;
|
||||
|
||||
vert_prog_lump.Substitute("shaders/", "shaders_gles/");
|
||||
frag_prog_lump.Substitute("shaders/", "shaders_gles/");
|
||||
proc_prog_lump.Substitute("shaders/", "shaders_gles/");
|
||||
|
||||
FString light_fragprog = light_fragprog_;
|
||||
light_fragprog.Substitute("shaders/", "shaders_gles/");
|
||||
|
||||
//light_fragprog.Substitute("material_pbr", "material_normal");
|
||||
|
||||
if(light_fragprog.Len())
|
||||
light_fragprog = "shaders_gles/glsl/material_normal.fp"; // NOTE: Always use normal material for now, ignore others
|
||||
|
||||
|
@ -332,9 +335,27 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
|
|||
uniform float timer;
|
||||
|
||||
// material types
|
||||
#if defined(SPECULAR)
|
||||
#define normaltexture texture2
|
||||
#define speculartexture texture3
|
||||
#define brighttexture texture4
|
||||
#define detailtexture texture5
|
||||
#define glowtexture texture6
|
||||
#elif defined(PBR)
|
||||
#define normaltexture texture2
|
||||
#define metallictexture texture3
|
||||
#define roughnesstexture texture4
|
||||
#define aotexture texture5
|
||||
#define brighttexture texture6
|
||||
#define detailtexture texture7
|
||||
#define glowtexture texture8
|
||||
#else
|
||||
#define brighttexture texture2
|
||||
#define detailtexture texture3
|
||||
#define glowtexture texture4
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
)";
|
||||
|
||||
|
@ -671,7 +692,7 @@ bool FShader::Bind(ShaderFlavourData& flavour)
|
|||
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_SUB %d\n", flavour.dynLightsSub);
|
||||
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_ADD %d\n", flavour.dynLightsAdd);
|
||||
|
||||
Printf("Shader: %s", variantConfig.GetChars());
|
||||
Printf("Shader: %s, %08x %s", mFragProg2.GetChars(), tag, variantConfig.GetChars());
|
||||
|
||||
Load(mName.GetChars(), mVertProg, mFragProg, mFragProg2, mLightProg, mDefinesBase + variantConfig);
|
||||
|
||||
|
@ -807,6 +828,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for(unsigned i = 0; i < usershaders.Size(); i++)
|
||||
{
|
||||
FString name = ExtractFileBase(usershaders[i].shader);
|
||||
|
@ -814,6 +836,7 @@ void FShaderCollection::CompileShaders(EPassType passType)
|
|||
FShader *shc = Compile(name, usershaders[i].shader, defaultshaders[usershaders[i].shaderType].lightfunc, defines, true, passType);
|
||||
mMaterialShaders.Push(shc);
|
||||
}
|
||||
#endif
|
||||
|
||||
for(int i=0;i<MAX_EFFECTS;i++)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "gles_system.h"
|
||||
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <dlfcn.h>
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include "c_cvars.h"
|
||||
#include "v_video.h"
|
||||
|
||||
CVAR(Bool, gl_customshader, true, 0)
|
||||
|
||||
|
||||
static IHardwareTexture* (*layercallback)(int layer, int translation);
|
||||
|
||||
void FMaterial::SetLayerCallback(IHardwareTexture* (*cb)(int layer, int translation))
|
||||
|
@ -123,17 +126,20 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags)
|
|||
}
|
||||
|
||||
auto index = tx->GetShaderIndex();
|
||||
if (index >= FIRST_USER_SHADER)
|
||||
if (gl_customshader)
|
||||
{
|
||||
const UserShaderDesc &usershader = usershaders[index - FIRST_USER_SHADER];
|
||||
if (usershader.shaderType == mShaderIndex) // Only apply user shader if it matches the expected material
|
||||
if (index >= FIRST_USER_SHADER)
|
||||
{
|
||||
for (auto &texture : tx->CustomShaderTextures)
|
||||
const UserShaderDesc& usershader = usershaders[index - FIRST_USER_SHADER];
|
||||
if (usershader.shaderType == mShaderIndex) // Only apply user shader if it matches the expected material
|
||||
{
|
||||
if (texture == nullptr) continue;
|
||||
mTextureLayers.Push({ texture.get(), 0 }); // scalability should be user-definable.
|
||||
for (auto& texture : tx->CustomShaderTextures)
|
||||
{
|
||||
if (texture == nullptr) continue;
|
||||
mTextureLayers.Push({ texture.get(), 0 }); // scalability should be user-definable.
|
||||
}
|
||||
mShaderIndex = index;
|
||||
}
|
||||
mShaderIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
void SetupMaterial(inout Material material)
|
||||
{
|
||||
material.Base = ProcessTexel();
|
||||
material.Normal = ApplyNormalMap(vTexCoord.st);
|
||||
material.Bright = texture2D(brighttexture, vTexCoord.st);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ struct Material
|
|||
vec4 Bright;
|
||||
vec4 Glow;
|
||||
vec3 Normal;
|
||||
vec3 Specular;
|
||||
float Glossiness;
|
||||
float SpecularLevel;
|
||||
};
|
||||
|
||||
vec4 Process(vec4 color);
|
||||
|
@ -403,6 +406,9 @@ void main()
|
|||
material.Bright = vec4(0.0);
|
||||
material.Glow = vec4(0.0);
|
||||
material.Normal = vec3(0.0);
|
||||
material.Specular = vec3(0.0);
|
||||
material.Glossiness = 0.0;
|
||||
material.SpecularLevel = 0.0;
|
||||
SetupMaterial(material);
|
||||
#else
|
||||
Material material = ProcessMaterial();
|
||||
|
|
Loading…
Reference in a new issue