mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
- generate uniform declarations from c++
This commit is contained in:
parent
769867475c
commit
3207d8aef7
17 changed files with 113 additions and 131 deletions
|
@ -63,9 +63,117 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
static char buffer[10000];
|
static char buffer[10000];
|
||||||
FString error;
|
FString error;
|
||||||
|
|
||||||
int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i", 0);
|
FString i_data;
|
||||||
if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'");
|
|
||||||
FMemLump i_data = Wads.ReadLump(i_lump);
|
// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here.
|
||||||
|
i_data += "precision highp int;\n";
|
||||||
|
i_data += "precision highp float;\n";
|
||||||
|
|
||||||
|
i_data += "uniform vec4 uCameraPos;\n";
|
||||||
|
i_data += "uniform int uTextureMode;\n";
|
||||||
|
i_data += "uniform float uClipHeight;\n";
|
||||||
|
i_data += "uniform float uClipHeightDirection;\n";
|
||||||
|
i_data += "uniform vec2 uClipSplit;\n";
|
||||||
|
i_data += "uniform vec4 uClipLine;\n";
|
||||||
|
i_data += "uniform float uAlphaThreshold;\n";
|
||||||
|
|
||||||
|
// colors
|
||||||
|
i_data += "uniform vec4 uObjectColor;\n";
|
||||||
|
i_data += "uniform vec4 uObjectColor2;\n";
|
||||||
|
i_data += "uniform vec4 uDynLightColor;\n";
|
||||||
|
i_data += "uniform vec4 uFogColor;\n";
|
||||||
|
i_data += "uniform float uDesaturationFactor;\n";
|
||||||
|
i_data += "uniform float uInterpolationFactor;\n";
|
||||||
|
|
||||||
|
// Fixed colormap stuff
|
||||||
|
i_data += "uniform int uFixedColormap;\n"; // 0, when no fixed colormap, 1 for a light value, 2 for a color blend, 3 for a fog layer
|
||||||
|
i_data += "uniform vec4 uFixedColormapStart;\n";
|
||||||
|
i_data += "uniform vec4 uFixedColormapRange;\n";
|
||||||
|
|
||||||
|
// Glowing walls stuff
|
||||||
|
i_data += "uniform vec4 uGlowTopPlane;\n";
|
||||||
|
i_data += "uniform vec4 uGlowTopColor;\n";
|
||||||
|
i_data += "uniform vec4 uGlowBottomPlane;\n";
|
||||||
|
i_data += "uniform vec4 uGlowBottomColor;\n";
|
||||||
|
|
||||||
|
i_data += "uniform vec4 uSplitTopPlane;\n";
|
||||||
|
i_data += "uniform vec4 uSplitBottomPlane;\n";
|
||||||
|
|
||||||
|
// Lighting + Fog
|
||||||
|
i_data += "uniform vec4 uLightAttr;\n";
|
||||||
|
i_data += "#define uLightLevel uLightAttr.a\n";
|
||||||
|
i_data += "#define uFogDensity uLightAttr.b\n";
|
||||||
|
i_data += "#define uLightFactor uLightAttr.g\n";
|
||||||
|
i_data += "#define uLightDist uLightAttr.r\n";
|
||||||
|
i_data += "uniform int uFogEnabled;\n";
|
||||||
|
i_data += "uniform int uPalLightLevels;\n";
|
||||||
|
i_data += "uniform float uGlobVis;\n"; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
|
||||||
|
|
||||||
|
// dynamic lights
|
||||||
|
i_data += "uniform int uLightIndex;\n";
|
||||||
|
|
||||||
|
// Software fuzz scaling
|
||||||
|
i_data += "uniform int uViewHeight;\n";
|
||||||
|
|
||||||
|
// Blinn glossiness and specular level
|
||||||
|
i_data += "uniform vec2 uSpecularMaterial;\n";
|
||||||
|
|
||||||
|
// quad drawer stuff
|
||||||
|
i_data += "#ifdef USE_QUAD_DRAWER\n";
|
||||||
|
i_data += "uniform mat4 uQuadVertices;\n";
|
||||||
|
i_data += "uniform mat4 uQuadTexCoords;\n";
|
||||||
|
i_data += "uniform int uQuadMode;\n";
|
||||||
|
i_data += "#endif\n";
|
||||||
|
|
||||||
|
// matrices
|
||||||
|
i_data += "uniform mat4 ProjectionMatrix;\n";
|
||||||
|
i_data += "uniform mat4 ViewMatrix;\n";
|
||||||
|
i_data += "uniform mat4 ModelMatrix;\n";
|
||||||
|
i_data += "uniform mat4 NormalViewMatrix;\n";
|
||||||
|
i_data += "uniform mat4 NormalModelMatrix;\n";
|
||||||
|
i_data += "uniform mat4 TextureMatrix;\n";
|
||||||
|
|
||||||
|
// light buffers
|
||||||
|
i_data += "#ifdef SHADER_STORAGE_LIGHTS\n";
|
||||||
|
i_data += "layout(std430, binding = 1) buffer LightBufferSSO\n";
|
||||||
|
i_data += "{\n";
|
||||||
|
i_data += " vec4 lights[];\n";
|
||||||
|
i_data += "};\n";
|
||||||
|
i_data += "#elif defined NUM_UBO_LIGHTS\n";
|
||||||
|
i_data += "uniform LightBufferUBO\n";
|
||||||
|
i_data += "{\n";
|
||||||
|
i_data += " vec4 lights[NUM_UBO_LIGHTS];\n";
|
||||||
|
i_data += "};\n";
|
||||||
|
i_data += "#endif\n";
|
||||||
|
|
||||||
|
// textures
|
||||||
|
i_data += "uniform sampler2D tex;\n";
|
||||||
|
i_data += "uniform sampler2D ShadowMap;\n";
|
||||||
|
i_data += "uniform sampler2D texture2;\n";
|
||||||
|
i_data += "uniform sampler2D texture3;\n";
|
||||||
|
i_data += "uniform sampler2D texture4;\n";
|
||||||
|
i_data += "uniform sampler2D texture5;\n";
|
||||||
|
i_data += "uniform sampler2D texture6;\n";
|
||||||
|
|
||||||
|
// timer data
|
||||||
|
i_data += "uniform float timer;\n"; // To do: we must search user shaders for this declaration and remove it
|
||||||
|
|
||||||
|
// material types
|
||||||
|
i_data += "#if defined(SPECULAR)\n";
|
||||||
|
i_data += "#define normaltexture texture2\n";
|
||||||
|
i_data += "#define speculartexture texture3\n";
|
||||||
|
i_data += "#define brighttexture texture4\n";
|
||||||
|
i_data += "#elif defined(PBR)\n";
|
||||||
|
i_data += "#define normaltexture texture2\n";
|
||||||
|
i_data += "#define metallictexture texture3\n";
|
||||||
|
i_data += "#define roughnesstexture texture4\n";
|
||||||
|
i_data += "#define aotexture texture5\n";
|
||||||
|
i_data += "#define brighttexture texture6\n";
|
||||||
|
i_data += "#else\n";
|
||||||
|
i_data += "#define brighttexture texture2\n";
|
||||||
|
i_data += "#endif\n";
|
||||||
|
|
||||||
|
i_data += "#line 1\n";
|
||||||
|
|
||||||
int vp_lump = Wads.CheckNumForFullName(vert_prog_lump, 0);
|
int vp_lump = Wads.CheckNumForFullName(vert_prog_lump, 0);
|
||||||
if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump);
|
if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump);
|
||||||
|
@ -120,7 +228,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
|
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
vp_comb << defines << i_data.GetString().GetChars();
|
vp_comb << defines << i_data.GetChars();
|
||||||
FString fp_comb = vp_comb;
|
FString fp_comb = vp_comb;
|
||||||
|
|
||||||
vp_comb << vp_data.GetString().GetChars() << "\n";
|
vp_comb << vp_data.GetString().GetChars() << "\n";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
uniform sampler2D tex;
|
|
||||||
uniform sampler2D texture2;
|
|
||||||
in vec4 vTexCoord;
|
in vec4 vTexCoord;
|
||||||
in vec4 vColor;
|
in vec4 vColor;
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
#if defined(SPECULAR)
|
|
||||||
uniform sampler2D texture4;
|
|
||||||
#define brighttexture texture4
|
|
||||||
#elif defined(PBR)
|
|
||||||
uniform sampler2D texture6;
|
|
||||||
#define brighttexture texture6
|
|
||||||
#else
|
|
||||||
uniform sampler2D texture2;
|
|
||||||
#define brighttexture texture2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Fuzz effect as rendered by the software renderer
|
// Fuzz effect as rendered by the software renderer
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
#define FUZZTABLE 50
|
#define FUZZTABLE 50
|
||||||
#define FUZZ_RANDOM_X_SIZE 100
|
#define FUZZ_RANDOM_X_SIZE 100
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//created by Evil Space Tomato
|
//created by Evil Space Tomato
|
||||||
uniform float timer;
|
|
||||||
|
|
||||||
vec4 ProcessTexel()
|
vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,38 +12,6 @@ out vec4 FragFog;
|
||||||
out vec4 FragNormal;
|
out vec4 FragNormal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHADER_STORAGE_LIGHTS
|
|
||||||
layout(std430, binding = 1) buffer LightBufferSSO
|
|
||||||
{
|
|
||||||
vec4 lights[];
|
|
||||||
};
|
|
||||||
#elif defined NUM_UBO_LIGHTS
|
|
||||||
/*layout(std140)*/ uniform LightBufferUBO
|
|
||||||
{
|
|
||||||
vec4 lights[NUM_UBO_LIGHTS];
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
uniform sampler2D tex;
|
|
||||||
uniform sampler2D ShadowMap;
|
|
||||||
|
|
||||||
#if defined(SPECULAR)
|
|
||||||
uniform sampler2D texture2;
|
|
||||||
uniform sampler2D texture3;
|
|
||||||
#define normaltexture texture2
|
|
||||||
#define speculartexture texture3
|
|
||||||
#elif defined(PBR)
|
|
||||||
uniform sampler2D texture2;
|
|
||||||
uniform sampler2D texture3;
|
|
||||||
uniform sampler2D texture4;
|
|
||||||
uniform sampler2D texture5;
|
|
||||||
#define normaltexture texture2
|
|
||||||
#define metallictexture texture3
|
|
||||||
#define roughnesstexture texture4
|
|
||||||
#define aotexture texture5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec4 Process(vec4 color);
|
vec4 Process(vec4 color);
|
||||||
vec4 ProcessTexel();
|
vec4 ProcessTexel();
|
||||||
vec4 ProcessLight(vec4 color);
|
vec4 ProcessLight(vec4 color);
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
// This file contains common data definitions for both vertex and fragment shader
|
|
||||||
|
|
||||||
// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here.
|
|
||||||
precision highp int;
|
|
||||||
precision highp float;
|
|
||||||
|
|
||||||
uniform vec4 uCameraPos;
|
|
||||||
uniform int uTextureMode;
|
|
||||||
uniform float uClipHeight, uClipHeightDirection;
|
|
||||||
uniform vec2 uClipSplit;
|
|
||||||
uniform vec4 uClipLine;
|
|
||||||
|
|
||||||
uniform float uAlphaThreshold;
|
|
||||||
|
|
||||||
|
|
||||||
// colors
|
|
||||||
uniform vec4 uObjectColor;
|
|
||||||
uniform vec4 uObjectColor2;
|
|
||||||
uniform vec4 uDynLightColor;
|
|
||||||
uniform vec4 uFogColor;
|
|
||||||
uniform float uDesaturationFactor;
|
|
||||||
uniform float uInterpolationFactor;
|
|
||||||
|
|
||||||
// Fixed colormap stuff
|
|
||||||
uniform int uFixedColormap; // 0, when no fixed colormap, 1 for a light value, 2 for a color blend, 3 for a fog layer
|
|
||||||
uniform vec4 uFixedColormapStart;
|
|
||||||
uniform vec4 uFixedColormapRange;
|
|
||||||
|
|
||||||
// Glowing walls stuff
|
|
||||||
uniform vec4 uGlowTopPlane;
|
|
||||||
uniform vec4 uGlowTopColor;
|
|
||||||
uniform vec4 uGlowBottomPlane;
|
|
||||||
uniform vec4 uGlowBottomColor;
|
|
||||||
|
|
||||||
uniform vec4 uSplitTopPlane;
|
|
||||||
uniform vec4 uSplitBottomPlane;
|
|
||||||
|
|
||||||
// Lighting + Fog
|
|
||||||
uniform vec4 uLightAttr;
|
|
||||||
#define uLightLevel uLightAttr.a
|
|
||||||
#define uFogDensity uLightAttr.b
|
|
||||||
#define uLightFactor uLightAttr.g
|
|
||||||
#define uLightDist uLightAttr.r
|
|
||||||
uniform int uFogEnabled;
|
|
||||||
uniform int uPalLightLevels;
|
|
||||||
uniform float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
|
|
||||||
|
|
||||||
// dynamic lights
|
|
||||||
uniform int uLightIndex;
|
|
||||||
|
|
||||||
// Software fuzz scaling
|
|
||||||
uniform int uViewHeight;
|
|
||||||
|
|
||||||
// Blinn glossiness and specular level
|
|
||||||
uniform vec2 uSpecularMaterial;
|
|
||||||
|
|
||||||
// quad drawer stuff
|
|
||||||
#ifdef USE_QUAD_DRAWER
|
|
||||||
uniform mat4 uQuadVertices;
|
|
||||||
uniform mat4 uQuadTexCoords;
|
|
||||||
uniform int uQuadMode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// matrices
|
|
||||||
uniform mat4 ProjectionMatrix;
|
|
||||||
uniform mat4 ViewMatrix;
|
|
||||||
uniform mat4 ModelMatrix;
|
|
||||||
uniform mat4 NormalViewMatrix;
|
|
||||||
uniform mat4 NormalModelMatrix;
|
|
||||||
uniform mat4 TextureMatrix;
|
|
||||||
|
|
Loading…
Reference in a new issue