|
Converting CG and GLSL shader types to BGFX??
#357185 - 07/31/16 03:12 PM
|
|
|
How difficult is it to convert existing CG or GLSL based shaders (RetroArch) to BGFX format?, I have noticed that the 'crt-geom' shader has now been converted to BGFX for mame and wonder if 'crt-easymode-halation' could also be converted over to BGFX?. Its probably one of the best CRT shaders out and can product awesome results.....
![](http://i.imgur.com/Kg1IeDG.jpg)
![](http://i.imgur.com/dtpvBco.jpg)
![](http://i.imgur.com/uHuvNOP.jpg)
|
|
|
|
Re: Converting CG and GLSL shader types to BGFX??
[Re: lettuce]
#357198 - 08/01/16 02:56 AM
|
|
|
> How difficult is it to convert existing CG or GLSL based shaders (RetroArch) to BGFX > format?, I have noticed that the 'crt-geom' shader has now been converted to BGFX for > mame and wonder if 'crt-easymode-halation' could also be converted over to BGFX?. Its > probably one of the best CRT shaders out and can product awesome results.....
BGFX shaders in MAME can do a lot of the same stuff as Retroarch shaders as far as multiple passes, and editable parameters and so on.
Looking at 'crt-easymode-halation' I'd guess that it would be a couple of hours to get working. The shader is longish but doesn't seem to be doing anything crazy. It's more a question whether anybody wants to spend the time porting it.
For example, I'm building a little bartop arcade cab that will use a 1280x1024 LCD monitor and a small PC with intel graphics. I won't spend the time right now to port 'crt-easymode-halation' because it probably won't run full speed on that PC and the scanlines look sharp enough that there will be aliasing at low resolutions. So it's not a fit for the hardware I'm working with.
Meanwhile, MAME's hlsl shader can be tweaked to look pretty much however you want assuming you have enough horsepower to run it. So there's not much motivation for me to port another CRT shader over.
And MooglyGuy, the dude that write the hlsl shader and ported over all the non-'crt-geom' shaders is doing regular emu stuff at the moment, so he probably won't do it any time soon. There are other people that could do it. Jezze could, and others too. But who knows if they will.
That shader does look very good though.
|
|
|
|
Re: Converting CG and GLSL shader types to BGFX??
[Re: lettuce]
#357221 - 08/01/16 10:05 PM
|
|
|
Thanks for the reply. According to Easymode the Shader isnt too demanding, he also has a 'Crt-easymode' minus the halation and that just about runs on a Raspberry Pi 3 device
|
|
|
|
Re: Converting CG and GLSL shader types to BGFX??
[Re: lettuce]
#357241 - 08/02/16 11:11 AM
|
|
|
> How difficult is it to convert existing CG or GLSL based shaders (RetroArch) to BGFX > format?
It depends. If you pull the MAME source code off of Github and look in src/osd/modules/render/bgfx/shaders, you can see what a number of converted shaders from RetroArch look like.
At build time, the BGFX shaders are converted to either GLSL, GLES-compliant GLSL, or HLSL, and then compiled into binaries. As a result of supporting GLES, the shaders supplied to BGFX must meet a handful of requirements, which can make converting shaders a bit of a pain, requiring manual rather than automatic conversion:
- No implicit conversion between scalar and vector types. - No implicit conversion between boolean and float types. - No uniforms other than vec4. - Most syntax favors GLSL tokens over HLSL tokens: vec4 instead of float4, mix instead of lerp, and so on.
|
|
|
|
Aye. That is awful pre-tty. (nt)
[Re: SoltanGris42]
#357255 - 08/02/16 10:03 PM
|
|
|
|
Scifi frauds. SF illuminates.
_________________
Culture General Contact Unit (Eccentric)
|
|
|
|
Well I gave it a shot this evening because I had some free time. I didn't get it working perfectly yet, but you can try it out.
Here's what's still broken:
- The DX9 version is completely BROKEN. More on this below. So you MUST use either dx11 or opengl for your 'bgfx_backend'.
- Interlacing screws up the curvature settings because of the way it adjusts texture coordinates. I just noticed after I zipped it all up to post here. It's probably easy to fix.
- Halation might not be exactly right (it still looks fine though). As far as I can tell, the original retroarch version doesn't rely on bilinear filtering when sampling the blurred texture but I had to in order for it to look right. I messed something up or this is correct. I don't know which.
- I had to use "#define"s to special case HLSL and GLSL because they assume opposite matrix alignments. This is ugly, but I didn't want to split the matrix vector calculations out into scalar ops until it mostly worked. This is one possible place that dx9 might be going wrong.
- I've read that dx9 has an offset that needs to be accounted for in the texture coordinates. If that's the issue it will be harder to fix.
- MAME's shaders should respect alpha so that compositing multiple layers is correct. I didn't worry about that at all for now.
- Every file will need a 'license' and 'author' indicated. The license is just 'GPL' in the original I think. And the author is 'easymode' and maybe someone else too.
- And so many more bugs!
I'll try to fix this up enough that MAME will take it with a pull request. But for now, here you go. BTW, the default settings I used don't look too much like your pictures, but I added pretty much everything as a slider option so you can adjust it to your liking. If you're new to MAME's bgfx shaders, be aware that you actually have to edit the 'crt-easymode-halation.json' file by hand in ...MAME/bgfx/chains to change the defaults.
Just merge the 'bgfx' folder in this zip file with the one in your mame folder and it should work. Don't forget to change your 'bgfx_backend' to 'dx11' or 'opengl' if the 'auto' option gives you dx9...
Here's the file on another site: http://filebin.ca/2qGqizsiYP7r/crt-easymode-halation-TEST_VERSION.zip
And I'll also attach it to this post.
Edited by SoltanGris42 (08/03/16 10:25 AM)
|
|
|
|
Re: Converting CG and GLSL shader types to BGFX??
[Re: lettuce]
#357302 - 08/04/16 02:33 AM
|
|
|
> How difficult is it to convert existing CG or GLSL based shaders (RetroArch) to BGFX > format?, I have noticed that the 'crt-geom' shader has now been converted to BGFX for > mame and wonder if 'crt-easymode-halation' could also be converted over to BGFX?. Its > probably one of the best CRT shaders out and can product awesome results.....
That first image:
http://i.imgur.com/Kg1IeDG.jpg
is posted on shmups as "current HLSL settings" by you!
I was going to ask what crt-easymode settings they were so I could try to reproduce them, but now I'm confused as to whether they are HLSL or crt-easymode??
|
|
|
|
|
It looks like the raster.ini preset without the shadow mask, less color saturation, including screen distortion and some scanline tweaks.
|
|
|
B2K24 |
MAME @ 15 kHz Sony Trinitron CRT user
|
|
|
Reged: 10/25/10
|
Posts: 2663
|
|
|
Send PM
|
|
|
Re: Converting CG and GLSL shader types to BGFX??
[Re: Jezze]
#364338 - 03/17/17 07:50 AM
|
|
|
|