I’m working on an 80s arcade style game.
When I started I chose the “MonoGame Windows Project” model.
The game is well underway and I would now like to apply a scanline type shader.
I found the “crt-lottes-mg.fx” shader that would do just for me.
The problem is that it seems that this shader is compatible only for OpenGL (DesktopGL, model “MonoGame Cross Platform Desktop Project”).
Is there a possibility to adapt this shader to my project as it is?
Or, is there a scanline type shader suitable for my project?
Are you sure it’s only compatible with DesktopGL…? Have you had a chance to try and import it into your Content Pipeline and use it?
Yes, I added the fx into the Content Pipeline and when I build the fx directly from the pipeline I get the error
“Shader uses texture addressing operations in a dependency chain that is too complex for the target shader model (ps_2_0) to handle” followed by hundred of “maximum temp register index exceeded” errors. Should I modify the shader? I’m coding my first game after many years and I’m new to MonoGame, C#, and shaders. Just out of curiosity, I also tryed to change the Content Platform property from Windows to DesktopGL and it builds correctly, but when I run the game I get the error “This MGFX effect was built for a different platform!”.
Hmm, I’m not too experienced with shaders either, but… perhaps change the shader model to
ps_3_0 instead? Should be doable somewhere inside the shader. Perhaps even
ps_4_0'll work too. Just a shot in the dark though.
Check out this page: http://www.monogame.net/documentation/?page=Custom_Effects
It explains the differences in how effects work between DirectX and OpenGL projects and how to work around them
Post the shader. …
The shader is just the one I downloaded from https://github.com/Jjagg/mg-crt/blob/81bcf73e02f1087a6223b14aa97145478ead45fd/Game1/Content/crt-lottes-mg.fx.
In the shader code there isn’t any reference to ps_2_0.
These are the first lines of the code, just in case:
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
For testing, if I create a “MonoGame Cross Platform Desktop Project” project and add the shader to the Content Pipeline it builds correctly (apart a couple of warnings about negative values). If I create a “MonoGame Windows Project” project and add the shader to the Content Pipeline it doesn’t build. Is it possible that the ps_2_0 model is used by mistake?
…Also, if I change the PS_SHADERMODEL to ps_2_0 or ps_3_0 it doesn’t build. If I change it to ps_4_0, ps_4_1, ps_5_0 or ps_4_0_level_9_3 it builds but when I run the program I get an exception error…
Ok, I followed Jjagg’s directions. I didn’t even know what was meant by “commit” before. So I downloaded the commit called “Replace branching by arithmetic” dated 9 Oct 2017 (from here https://github.com/Jjagg/mg-crt/blob/8d3949114ac2daf92e526638a023e15982273d5b/Game1/Content/crt-lottes-mg.fx), I built the project and got 64 errors … Arggh !!! I tried modifying the model from ps_4_0_level_9_1 to ps_4_0_level_9_3 and … tadah … it works !!!
Thank you all…