Trilinear filtering limited implementation.
Fixes lighter field areas in NFL 2K2
This commit is contained in:
parent
3c4913a35a
commit
a1997637bb
|
@ -152,6 +152,16 @@ template <u32 Type, bool SortingEnabled>
|
|||
__forceinline
|
||||
void SetGPState(const PolyParam* gp,u32 cflip=0)
|
||||
{
|
||||
if (gp->pcw.Texture && gp->tsp.FilterMode > 1)
|
||||
{
|
||||
ShaderUniforms.trilinear_alpha = 0.25 * (gp->tsp.MipMapD & 0x3);
|
||||
if (gp->tsp.FilterMode == 2)
|
||||
// Trilinear pass A
|
||||
ShaderUniforms.trilinear_alpha = 1.0 - ShaderUniforms.trilinear_alpha;
|
||||
}
|
||||
else
|
||||
ShaderUniforms.trilinear_alpha = 1.0;
|
||||
|
||||
CurrentShader = &gl.pogram_table[
|
||||
GetProgramID(Type == ListType_Punch_Through ? 1 : 0,
|
||||
SetTileClip(gp->tileclip, false) + 1,
|
||||
|
@ -166,7 +176,11 @@ __forceinline
|
|||
|
||||
if (CurrentShader->program == -1)
|
||||
CompilePipelineShader(CurrentShader);
|
||||
glcache.UseProgram(CurrentShader->program);
|
||||
else
|
||||
{
|
||||
glcache.UseProgram(CurrentShader->program);
|
||||
ShaderUniforms.Set(CurrentShader);
|
||||
}
|
||||
SetTileClip(gp->tileclip,true);
|
||||
|
||||
//This bit control which pixels are affected
|
||||
|
|
|
@ -223,6 +223,7 @@ uniform lowp vec4 pp_ClipTest; \n\
|
|||
uniform lowp vec3 sp_FOG_COL_RAM,sp_FOG_COL_VERT; \n\
|
||||
uniform highp float sp_FOG_DENSITY; \n\
|
||||
uniform sampler2D tex,fog_table; \n\
|
||||
uniform lowp float trilinear_alpha; \n\
|
||||
/* Vertex input*/ \n\
|
||||
INTERPOLATION " vary " lowp vec4 vtx_base; \n\
|
||||
INTERPOLATION " vary " lowp vec4 vtx_offs; \n\
|
||||
|
@ -312,6 +313,8 @@ void main() \n\
|
|||
color.rgb=mix(color.rgb,sp_FOG_COL_RAM.rgb,fog_mode2(gl_FragCoord.w)); \n\
|
||||
} \n\
|
||||
#endif\n\
|
||||
color *= trilinear_alpha; \n\
|
||||
\n\
|
||||
#if cp_AlphaTest == 1 \n\
|
||||
color.a=1.0; \n\
|
||||
#endif \n\
|
||||
|
@ -670,37 +673,7 @@ GLuint fogTextureId;
|
|||
|
||||
#endif
|
||||
|
||||
struct ShaderUniforms_t
|
||||
{
|
||||
float PT_ALPHA;
|
||||
float scale_coefs[4];
|
||||
float depth_coefs[4];
|
||||
float fog_den_float;
|
||||
float ps_FOG_COL_RAM[3];
|
||||
float ps_FOG_COL_VERT[3];
|
||||
|
||||
void Set(PipelineShader* s)
|
||||
{
|
||||
if (s->cp_AlphaTestValue!=-1)
|
||||
glUniform1f(s->cp_AlphaTestValue,PT_ALPHA);
|
||||
|
||||
if (s->scale!=-1)
|
||||
glUniform4fv( s->scale, 1, scale_coefs);
|
||||
|
||||
if (s->depth_scale!=-1)
|
||||
glUniform4fv( s->depth_scale, 1, depth_coefs);
|
||||
|
||||
if (s->sp_FOG_DENSITY!=-1)
|
||||
glUniform1f( s->sp_FOG_DENSITY,fog_den_float);
|
||||
|
||||
if (s->sp_FOG_COL_RAM!=-1)
|
||||
glUniform3fv( s->sp_FOG_COL_RAM, 1, ps_FOG_COL_RAM);
|
||||
|
||||
if (s->sp_FOG_COL_VERT!=-1)
|
||||
glUniform3fv( s->sp_FOG_COL_VERT, 1, ps_FOG_COL_VERT);
|
||||
}
|
||||
|
||||
} ShaderUniforms;
|
||||
struct ShaderUniforms_t ShaderUniforms;
|
||||
|
||||
GLuint gl_CompileShader(const char* shader,GLuint type)
|
||||
{
|
||||
|
@ -852,6 +825,7 @@ bool CompilePipelineShader( PipelineShader* s)
|
|||
gu = glGetUniformLocation(s->program, "fog_table");
|
||||
if (gu != -1)
|
||||
glUniform1i(gu, 1);
|
||||
s->trilinear_alpha = glGetUniformLocation(s->program, "trilinear_alpha");
|
||||
|
||||
ShaderUniforms.Set(s);
|
||||
|
||||
|
@ -1651,16 +1625,16 @@ bool RenderFrame()
|
|||
|
||||
ShaderUniforms.PT_ALPHA=(PT_ALPHA_REF&0xFF)/255.0f;
|
||||
|
||||
for (u32 i=0;i<sizeof(gl.pogram_table)/sizeof(gl.pogram_table[0]);i++)
|
||||
{
|
||||
PipelineShader* s=&gl.pogram_table[i];
|
||||
if (s->program == -1)
|
||||
continue;
|
||||
|
||||
glcache.UseProgram(s->program);
|
||||
|
||||
ShaderUniforms.Set(s);
|
||||
}
|
||||
// for (u32 i=0;i<sizeof(gl.pogram_table)/sizeof(gl.pogram_table[0]);i++)
|
||||
// {
|
||||
// PipelineShader* s=&gl.pogram_table[i];
|
||||
// if (s->program == -1)
|
||||
// continue;
|
||||
//
|
||||
// glcache.UseProgram(s->program);
|
||||
//
|
||||
// ShaderUniforms.Set(s);
|
||||
// }
|
||||
//setup render target first
|
||||
if (is_rtt)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ struct PipelineShader
|
|||
GLuint scale,depth_scale;
|
||||
GLuint pp_ClipTest,cp_AlphaTestValue;
|
||||
GLuint sp_FOG_COL_RAM,sp_FOG_COL_VERT,sp_FOG_DENSITY;
|
||||
GLuint trilinear_alpha;
|
||||
|
||||
//
|
||||
u32 cp_AlphaTest; s32 pp_ClipTestMode;
|
||||
|
@ -129,3 +130,40 @@ bool CompilePipelineShader(PipelineShader* s);
|
|||
GLuint loadPNG(const string& subpath, int &width, int &height);
|
||||
|
||||
enum ModifierVolumeMode { Xor, Or, Inclusion, Exclusion, ModeCount };
|
||||
|
||||
extern struct ShaderUniforms_t
|
||||
{
|
||||
float PT_ALPHA;
|
||||
float scale_coefs[4];
|
||||
float depth_coefs[4];
|
||||
float fog_den_float;
|
||||
float ps_FOG_COL_RAM[3];
|
||||
float ps_FOG_COL_VERT[3];
|
||||
float trilinear_alpha;
|
||||
|
||||
void Set(PipelineShader* s)
|
||||
{
|
||||
if (s->cp_AlphaTestValue!=-1)
|
||||
glUniform1f(s->cp_AlphaTestValue,PT_ALPHA);
|
||||
|
||||
if (s->scale!=-1)
|
||||
glUniform4fv( s->scale, 1, scale_coefs);
|
||||
|
||||
if (s->depth_scale!=-1)
|
||||
glUniform4fv( s->depth_scale, 1, depth_coefs);
|
||||
|
||||
if (s->sp_FOG_DENSITY!=-1)
|
||||
glUniform1f( s->sp_FOG_DENSITY,fog_den_float);
|
||||
|
||||
if (s->sp_FOG_COL_RAM!=-1)
|
||||
glUniform3fv( s->sp_FOG_COL_RAM, 1, ps_FOG_COL_RAM);
|
||||
|
||||
if (s->sp_FOG_COL_VERT!=-1)
|
||||
glUniform3fv( s->sp_FOG_COL_VERT, 1, ps_FOG_COL_VERT);
|
||||
|
||||
if (s->trilinear_alpha != -1)
|
||||
glUniform1f(s->trilinear_alpha, trilinear_alpha);
|
||||
}
|
||||
|
||||
} ShaderUniforms;
|
||||
|
||||
|
|
Loading…
Reference in New Issue