I was really hoping to find some neat CRT type shaders used by all sorts of emulators but I can’t find anything for MonoGame.
Does anyone have something? I saw the bloom effect code but it’s so complicated. I wish for something simple like emus seem to have that just do it with single shader file.
If you look through the commits you’ll see specific optimizations that may or may not suit your purpose. The biggest win by far is to use 2 for the gamma exponent instead of 2.2. I tried all libretro CRT shaders and thought this was the best one.
Here’s the repo with libretro shaders: https://github.com/libretro/common-shaders
They’re pretty easy to port to HLSL for MG. I recommend trying out the effects with a game to see which ones you like
I recall writing a script to automate porting over the shaders for MG, if you (or anyone else) is interested in it I’ll look around if I can find it.
I never used any shaders before so I´m a newby. When I´m trying to use the crt-lottes-mg.fx-shader I get the error message “maximum temp register index exceeded” for quite a few codelines. For example for this line: return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);
And just one other error: return ToLinear(brightboost * tex2D(DecalSampler,pos.xy).rgb);
Thank you. That erased all the old errors but generated just 1 new error, which is: Compiled shader code uses too many arithmetic instruction slots (945). Max. allowed by the target (ps_2_x) is 512. Consider increasing optimization level to reduce instruction count.
It´s generated on this line: return float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));
I guess optimizations won´t cut the instrucion slots in half so is there something else I could do?
And I don´t know why it says ps_2_x as I set it to ps_4 and it´s just on opengl on ps_2 and I´m using standard win 10. Even if I change the opengl-stuff to ps_4 it tells me the same error message.
You’ll need ps_4_0 for the Windows build in the commit I linked, I was only testing DesktopGL back then. Note that you’ll need to set the GraphicsProfile to HiDef in Game1 to load the ps_4_0 shader.
Check out the later commits which take away some functionality, but work with ps_4_0_level_9_1 and run faster (timings on my laptop are in the commit messages and can give you an idea of relative performance).
The ps_4_0_level_9_1 and ps_4_0_level_9_3 targets are a bit weird. They are there for DirectX 9 compatibility and are weaker than ps_4_0. For DesktopGL you can always use 3_0, for DX you can use 4_0_level_9_3 for better compatibility or higher (up to 5_0) for more capabilities.