mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 14:42:13 +00:00
fix r_wateralpha in the d3d9+d3d11 renderers too.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5196 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
3ff8d04cfc
commit
3f0f3e20b5
6 changed files with 45 additions and 13 deletions
|
@ -414,6 +414,7 @@ qboolean D3D11Shader_CreateProgram (program_t *prog, const char *name, unsigned
|
||||||
char *dsformat = NULL;
|
char *dsformat = NULL;
|
||||||
char *fsformat;
|
char *fsformat;
|
||||||
char *gsformat = NULL;
|
char *gsformat = NULL;
|
||||||
|
char *tmp;
|
||||||
D3D_SHADER_MACRO defines[64];
|
D3D_SHADER_MACRO defines[64];
|
||||||
ID3DBlob *vcode = NULL, *hcode = NULL, *dcode = NULL, *gcode = NULL, *fcode = NULL, *errors = NULL;
|
ID3DBlob *vcode = NULL, *hcode = NULL, *dcode = NULL, *gcode = NULL, *fcode = NULL, *errors = NULL;
|
||||||
qboolean success = false;
|
qboolean success = false;
|
||||||
|
@ -475,8 +476,10 @@ qboolean D3D11Shader_CreateProgram (program_t *prog, const char *name, unsigned
|
||||||
defines[consts].Definition = __DATE__;
|
defines[consts].Definition = __DATE__;
|
||||||
consts++;
|
consts++;
|
||||||
|
|
||||||
|
tmp = Z_Malloc(64);
|
||||||
|
Q_snprintfz(tmp, 64, "0x%x", d3dfeaturelevel);
|
||||||
defines[consts].Name = Z_StrDup("LEVEL");
|
defines[consts].Name = Z_StrDup("LEVEL");
|
||||||
defines[consts].Definition = Z_StrDup(va("0x%x", d3dfeaturelevel));
|
defines[consts].Definition = tmp;
|
||||||
consts++;
|
consts++;
|
||||||
|
|
||||||
for (; *precompilerconstants; precompilerconstants++)
|
for (; *precompilerconstants; precompilerconstants++)
|
||||||
|
|
|
@ -394,6 +394,7 @@ static void D3D9Shader_ProgAutoFields(program_t *prog, const char *progname, cva
|
||||||
struct programpermu_s *pp;
|
struct programpermu_s *pp;
|
||||||
unsigned int i, p;
|
unsigned int i, p;
|
||||||
int uniformloc;
|
int uniformloc;
|
||||||
|
char tmpbuffer[256];
|
||||||
|
|
||||||
#define ALTLIGHTMAPSAMP 13
|
#define ALTLIGHTMAPSAMP 13
|
||||||
#define ALTDELUXMAPSAMP 16
|
#define ALTDELUXMAPSAMP 16
|
||||||
|
@ -436,7 +437,8 @@ static void D3D9Shader_ProgAutoFields(program_t *prog, const char *progname, cva
|
||||||
//just directly sets uniforms. can't cope with cvars dynamically changing.
|
//just directly sets uniforms. can't cope with cvars dynamically changing.
|
||||||
cvarrefs[i]->flags |= CVAR_SHADERSYSTEM;
|
cvarrefs[i]->flags |= CVAR_SHADERSYSTEM;
|
||||||
|
|
||||||
uniformloc = D3D9Shader_FindUniform(&prog->permu[p].h, 1, va("cvar_%s", cvarnames[i]));
|
Q_snprintfz(tmpbuffer, sizeof(tmpbuffer), "cvar_%s", cvarnames[i]);
|
||||||
|
uniformloc = D3D9Shader_FindUniform(&prog->permu[p].h, 1, tmpbuffer);
|
||||||
if (uniformloc != -1)
|
if (uniformloc != -1)
|
||||||
{
|
{
|
||||||
if (cvartypes[i] == SP_CVARI)
|
if (cvartypes[i] == SP_CVARI)
|
||||||
|
@ -447,7 +449,7 @@ static void D3D9Shader_ProgAutoFields(program_t *prog, const char *progname, cva
|
||||||
else
|
else
|
||||||
IDirect3DDevice9_SetVertexShaderConstantF(pD3DDev9, 0, cvarrefs[i]->vec4, 1);
|
IDirect3DDevice9_SetVertexShaderConstantF(pD3DDev9, 0, cvarrefs[i]->vec4, 1);
|
||||||
}
|
}
|
||||||
uniformloc = D3D9Shader_FindUniform(&prog->permu[p].h, 2, va("cvar_%s", cvarnames[i]));
|
uniformloc = D3D9Shader_FindUniform(&prog->permu[p].h, 2, tmpbuffer);
|
||||||
if (uniformloc != -1)
|
if (uniformloc != -1)
|
||||||
{
|
{
|
||||||
if (cvartypes[i] == SP_CVARI)
|
if (cvartypes[i] == SP_CVARI)
|
||||||
|
@ -463,7 +465,8 @@ static void D3D9Shader_ProgAutoFields(program_t *prog, const char *progname, cva
|
||||||
/*set texture uniforms*/
|
/*set texture uniforms*/
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
uniformloc = D3D9Shader_FindUniform(&pp->h, 2, va("s_t%i", i));
|
Q_snprintfz(tmpbuffer, sizeof(tmpbuffer), "s_t%i", i);
|
||||||
|
uniformloc = D3D9Shader_FindUniform(&pp->h, 2, tmpbuffer);
|
||||||
if (uniformloc != -1)
|
if (uniformloc != -1)
|
||||||
{
|
{
|
||||||
int v[4] = {i};
|
int v[4] = {i};
|
||||||
|
|
|
@ -5831,7 +5831,7 @@ void Shader_DefaultSkybox(const char *shortname, shader_t *s, const void *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Shader_DefaultBSPWater(shader_t *s, const char *shortname)
|
char *Shader_DefaultBSPWater(shader_t *s, const char *shortname, char *buffer, size_t buffersize)
|
||||||
{
|
{
|
||||||
int wstyle;
|
int wstyle;
|
||||||
int type;
|
int type;
|
||||||
|
@ -5938,7 +5938,7 @@ char *Shader_DefaultBSPWater(shader_t *s, const char *shortname)
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
case 1: //vanilla style
|
case 1: //vanilla style
|
||||||
return va(
|
Q_snprintfz(buffer, buffersize,
|
||||||
"{\n"
|
"{\n"
|
||||||
"program defaultwarp%s\n"
|
"program defaultwarp%s\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -5953,6 +5953,7 @@ char *Shader_DefaultBSPWater(shader_t *s, const char *shortname)
|
||||||
"surfaceparm nomarks\n"
|
"surfaceparm nomarks\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
, explicitalpha?"":va("#ALPHA=%g",alpha), alpha, alpha);
|
, explicitalpha?"":va("#ALPHA=%g",alpha), alpha, alpha);
|
||||||
|
return buffer;
|
||||||
case 2: //refraction of the underwater surface, with a fresnel
|
case 2: //refraction of the underwater surface, with a fresnel
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -6038,7 +6039,8 @@ char *Shader_DefaultBSPWater(shader_t *s, const char *shortname)
|
||||||
|
|
||||||
void Shader_DefaultWaterShader(const char *shortname, shader_t *s, const void *args)
|
void Shader_DefaultWaterShader(const char *shortname, shader_t *s, const void *args)
|
||||||
{
|
{
|
||||||
Shader_DefaultScript(shortname, s, Shader_DefaultBSPWater(s, shortname));
|
char tmpbuffer[2048];
|
||||||
|
Shader_DefaultScript(shortname, s, Shader_DefaultBSPWater(s, shortname, tmpbuffer, sizeof(tmpbuffer)));
|
||||||
}
|
}
|
||||||
void Shader_DefaultBSPQ2(const char *shortname, shader_t *s, const void *args)
|
void Shader_DefaultBSPQ2(const char *shortname, shader_t *s, const void *args)
|
||||||
{
|
{
|
||||||
|
@ -6053,7 +6055,8 @@ void Shader_DefaultBSPQ2(const char *shortname, shader_t *s, const void *args)
|
||||||
}
|
}
|
||||||
else if (Shader_FloatArgument(s, "#WARP"))//!strncmp(shortname, "warp/", 5) || !strncmp(shortname, "warp33/", 7) || !strncmp(shortname, "warp66/", 7))
|
else if (Shader_FloatArgument(s, "#WARP"))//!strncmp(shortname, "warp/", 5) || !strncmp(shortname, "warp33/", 7) || !strncmp(shortname, "warp66/", 7))
|
||||||
{
|
{
|
||||||
Shader_DefaultScript(shortname, s, Shader_DefaultBSPWater(s, shortname));
|
char tmpbuffer[2048];
|
||||||
|
Shader_DefaultScript(shortname, s, Shader_DefaultBSPWater(s, shortname, tmpbuffer, sizeof(tmpbuffer)));
|
||||||
}
|
}
|
||||||
else if (Shader_FloatArgument(s, "#ALPHA"))// !strncmp(shortname, "trans/", 6))
|
else if (Shader_FloatArgument(s, "#ALPHA"))// !strncmp(shortname, "trans/", 6))
|
||||||
{
|
{
|
||||||
|
@ -6074,6 +6077,7 @@ void Shader_DefaultBSPQ2(const char *shortname, shader_t *s, const void *args)
|
||||||
void Shader_DefaultBSPQ1(const char *shortname, shader_t *s, const void *args)
|
void Shader_DefaultBSPQ1(const char *shortname, shader_t *s, const void *args)
|
||||||
{
|
{
|
||||||
char *builtin = NULL;
|
char *builtin = NULL;
|
||||||
|
char tmpbuffer[2048];
|
||||||
|
|
||||||
if (!strcmp(shortname, "mirror_portal"))
|
if (!strcmp(shortname, "mirror_portal"))
|
||||||
{
|
{
|
||||||
|
@ -6113,7 +6117,7 @@ void Shader_DefaultBSPQ1(const char *shortname, shader_t *s, const void *args)
|
||||||
|
|
||||||
if (!builtin && (*shortname == '*' || *shortname == '!'))
|
if (!builtin && (*shortname == '*' || *shortname == '!'))
|
||||||
{
|
{
|
||||||
builtin = Shader_DefaultBSPWater(s, shortname);
|
builtin = Shader_DefaultBSPWater(s, shortname, tmpbuffer, sizeof(tmpbuffer));
|
||||||
}
|
}
|
||||||
if (!builtin && !strncmp(shortname, "sky", 3))
|
if (!builtin && !strncmp(shortname, "sky", 3))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7349,7 +7349,11 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
|
||||||
"ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;\n"
|
"ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;\n"
|
||||||
"float3 ts = tex2D(s_diffuse, ntc).xyz;\n"
|
"float3 ts = tex2D(s_diffuse, ntc).xyz;\n"
|
||||||
|
|
||||||
|
"#ifdef ALPHA\n"
|
||||||
|
"return float4(ts, float(ALPHA));\n"
|
||||||
|
"#else\n"
|
||||||
"return float4(ts, cvar_r_wateralpha);\n"
|
"return float4(ts, cvar_r_wateralpha);\n"
|
||||||
|
"#endif\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
},
|
},
|
||||||
|
@ -7357,7 +7361,7 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
|
||||||
#ifdef D3D11QUAKE
|
#ifdef D3D11QUAKE
|
||||||
{QR_DIRECT3D11, 11, "defaultwarp",
|
{QR_DIRECT3D11, 11, "defaultwarp",
|
||||||
"!!samps diffuse\n"
|
"!!samps diffuse\n"
|
||||||
"!!cvarf r_wateralpha\n"
|
//!!cvarf r_wateralpha
|
||||||
|
|
||||||
"struct a2v\n"
|
"struct a2v\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -7392,9 +7396,16 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
|
||||||
"float4 main (v2f inp) : SV_TARGET\n"
|
"float4 main (v2f inp) : SV_TARGET\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float2 ntc;\n"
|
"float2 ntc;\n"
|
||||||
|
"float4 r;\n"
|
||||||
"ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125;\n"
|
"ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125;\n"
|
||||||
"ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;\n"
|
"ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;\n"
|
||||||
"return t_diffuse.Sample(s_diffuse, ntc);\n"
|
"r = t_diffuse.Sample(s_diffuse, ntc);\n"
|
||||||
|
"#ifdef ALPHA\n"
|
||||||
|
"r.a = float(ALPHA);\n"
|
||||||
|
"#else\n"
|
||||||
|
// r.a *= r_wateralpha;
|
||||||
|
"#endif\n"
|
||||||
|
"return r;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
!!samps diffuse
|
!!samps diffuse
|
||||||
!!cvarf r_wateralpha
|
//!!cvarf r_wateralpha
|
||||||
|
|
||||||
struct a2v
|
struct a2v
|
||||||
{
|
{
|
||||||
|
@ -34,8 +34,15 @@ struct v2f
|
||||||
float4 main (v2f inp) : SV_TARGET
|
float4 main (v2f inp) : SV_TARGET
|
||||||
{
|
{
|
||||||
float2 ntc;
|
float2 ntc;
|
||||||
|
float4 r;
|
||||||
ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125;
|
ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125;
|
||||||
ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;
|
ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;
|
||||||
return t_diffuse.Sample(s_diffuse, ntc);
|
r = t_diffuse.Sample(s_diffuse, ntc);
|
||||||
|
#ifdef ALPHA
|
||||||
|
r.a = float(ALPHA);
|
||||||
|
#else
|
||||||
|
// r.a *= r_wateralpha;
|
||||||
|
#endif
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -31,6 +31,10 @@ struct v2f {
|
||||||
ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;
|
ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125;
|
||||||
float3 ts = tex2D(s_diffuse, ntc).xyz;
|
float3 ts = tex2D(s_diffuse, ntc).xyz;
|
||||||
|
|
||||||
|
#ifdef ALPHA
|
||||||
|
return float4(ts, float(ALPHA));
|
||||||
|
#else
|
||||||
return float4(ts, cvar_r_wateralpha);
|
return float4(ts, cvar_r_wateralpha);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue