Add "simplified" grain option, for extra performance.

Uses PRNG calls instead of texture fetches, so it tends to look more harsh and have patterning issues depending on the GPU.
This commit is contained in:
Marisa the Magician 2022-11-10 16:11:44 +01:00
commit 7efc84adb5
6 changed files with 105 additions and 19 deletions

View file

@ -10,6 +10,7 @@ Class MariFXHandler : StaticEventHandler
{
Shader.SetEnabled(p,"mfx_lumasharp",false);
Shader.SetEnabled(p,"mfx_grain",false);
Shader.SetEnabled(p,"mfx_grain_simple",false);
Shader.SetEnabled(p,"mfx_dirt",false);
Shader.SetEnabled(p,"mfx_grading",false);
Shader.SetEnabled(p,"mfx_lutgrading",false);
@ -34,17 +35,32 @@ Class MariFXHandler : StaticEventHandler
Shader.SetUniform1f(p,"mfx_lumasharp","sharpclamp",mfx_lsharpclamp);
Shader.SetUniform1f(p,"mfx_lumasharp","sharpblend",mfx_lsharpblend);
// FILM GRAIN
Shader.SetEnabled(p,"mfx_grain",mfx_ne);
Shader.SetUniform1f(p,"mfx_grain","nf",mfx_nf/10.);
Shader.SetUniform1f(p,"mfx_grain","ni",mfx_ni);
Shader.SetUniform1f(p,"mfx_grain","ns",mfx_ns);
Shader.SetUniform3f(p,"mfx_grain","nm1",(mfx_nm1_r,mfx_nm1_g,mfx_nm1_b));
Shader.SetUniform1f(p,"mfx_grain","nk",mfx_nk);
Shader.SetUniform3f(p,"mfx_grain","nm2",(mfx_nm2_r,mfx_nm2_g,mfx_nm2_b));
Shader.SetUniform1f(p,"mfx_grain","np",mfx_np);
Shader.SetUniform1f(p,"mfx_grain","bnp",mfx_bnp);
Shader.SetUniform1i(p,"mfx_grain","nb",mfx_nb);
Shader.SetUniform1f(p,"mfx_grain","Timer",(gametic+e.fractic)/35.);
if ( mfx_nc )
{
Shader.SetEnabled(p,"mfx_grain",mfx_ne);
Shader.SetEnabled(p,"mfx_grain_simple",false);
Shader.SetUniform1f(p,"mfx_grain","nf",mfx_nf/10.);
Shader.SetUniform1f(p,"mfx_grain","ni",mfx_ni);
Shader.SetUniform1f(p,"mfx_grain","ns",mfx_ns);
Shader.SetUniform3f(p,"mfx_grain","nm1",(mfx_nm1_r,mfx_nm1_g,mfx_nm1_b));
Shader.SetUniform1f(p,"mfx_grain","nk",mfx_nk);
Shader.SetUniform3f(p,"mfx_grain","nm2",(mfx_nm2_r,mfx_nm2_g,mfx_nm2_b));
Shader.SetUniform1f(p,"mfx_grain","np",mfx_np);
Shader.SetUniform1f(p,"mfx_grain","bnp",mfx_bnp);
Shader.SetUniform1i(p,"mfx_grain","nb",mfx_nb);
Shader.SetUniform1f(p,"mfx_grain","Timer",(gametic+e.fractic)/35.);
}
else
{
Shader.SetEnabled(p,"mfx_grain",false);
Shader.SetEnabled(p,"mfx_grain_simple",mfx_ne);
Shader.SetUniform1f(p,"mfx_grain_simple","ni",mfx_ni);
Shader.SetUniform1f(p,"mfx_grain_simple","ns",mfx_ns);
Shader.SetUniform1f(p,"mfx_grain_simple","np",mfx_np);
Shader.SetUniform1f(p,"mfx_grain_simple","bnp",mfx_bnp);
Shader.SetUniform1i(p,"mfx_grain_simple","nb",mfx_nb);
Shader.SetUniform1f(p,"mfx_grain_simple","Timer",(gametic+e.fractic)/35.);
}
// SCREEN DIRT
Shader.SetEnabled(p,"mfx_dirt",mfx_dirtenable);
Shader.SetUniform1f(p,"mfx_dirt","dirtmc",mfx_dirtmc);
@ -170,6 +186,7 @@ Class MariFXHandler : StaticEventHandler
{
case 0:
CVar.FindCVar('mfx_ne').ResetToDefault();
CVar.FindCVar('mfx_nc').ResetToDefault();
CVar.FindCVar('mfx_ni').ResetToDefault();
CVar.FindCVar('mfx_nf').ResetToDefault();
CVar.FindCVar('mfx_ns').ResetToDefault();