Custom shaders work with XNA, but "not" with Monogame

I’m trying to get this awesome 2D lighting thingy (http://rabidlion.com/?p=302) to work with the MonoGame. The original XNA project works without problems when I build and run it, but if I try the same code and shaders with MonoGame there are no lights.

Works (XNA): http://imgur.com/cu9JsuK,vrvvT59#1
Doesn’t (MG): http://imgur.com/cu9JsuK,vrvvT59#0

I have tried to convert the .fx files with the 2MGFX tool to OpenGL files. Also tried to just use the .fx files “normally” with the content pipeline. There seems to be no difference on the outcome of the two.

I am very baffled and would appreciate any help and ideas, thanks!

I have been doing a lot of trial and error, and I think the problem is somewhere in the LightRenderer class: http://pastebin.com/NF5e762p

I assume that there is no problems with the shader files, because the .xnb shader files made by the XNA project shows the same outcome when using with the MonoGame project. Also I have “converted” couple very simple one shader file XNA tutorials/projects to MonoGame and they work well with the content pipeline.

I wonder if there is some bugs or differences with the MonoGame RenderTarget or spritebatch? Google tells me not.

I would have to take a closer look at shader itself but sadly mono do lot of things wrong. For example content pipeline is bit absurd, from my experience if I don´t use samplers (inside shader) in same order as they are declared and defined then content tool simply throw them out.

If you directly assigned textures to sampler (not through .fx) then it also wont work as MG will set that sampler to null. I do believe I found thread where devs were talking about it, and decided that this is proper XNA behavior… fact I had to rewrite my project to render something else then pure black begs differ.

Surfaces in RTs works well, at least from what I´ve tried including HDR rendering, so this part should be fine.

Hey dude, Cant add a comment. But Im glad you share the tutorials your following on making 2D lights. Just like you I want to learn making 2D lights but I cant find a decent tutorial that will explain whats happening behind the scene. The site you gave is awesome.

Thanks :smiley:

Mostly likely this is a shader issue, heres some tips: