libretro / common-shaders

Collection of commonly used Cg shaders. These shaders are usable by either HLSL and/or Cg runtime compilers. The cg2glsl script will translate most of these into GLSL shaders.
http://www.libretro.com
1.03k stars 250 forks source link

[Request] r57shell's PAL shader: add "USE RAW" / "USE LUT" to user-settings #165

Open eugene-s-nesdev opened 3 years ago

eugene-s-nesdev commented 3 years ago

https://github.com/libretro/common-shaders/blob/master/pal/shaders/pal-r57shell.cg

Most of retroarch NES cores (and puNES standalone emulator with shaders support) have RAW-palette option. If you're set emulator palette to RAW, and uncomment line 70 same time (#define USE_RAW) shader will generate true-palnes palette

If you're uncomment line 74 (#define USE_LUT) shader will generate less accurate colors, but performance will increase. NOTE: USE LUT works only when USE RAW enabled, otherwise it does nothing

This is very uncomfortable to comment/uncomment these parameters in shader source every time. Users use this shader not only with NES but with another systems too, like snes, genesis etc, which requires keep use_raw disabled. So if you're can, please, make GUI setting for this.

Default values must be OFF (0) for compatibility reasons. Value ON (1) is preferred for NES systems, but it works correct only if you're set raw-palette in emulator core options.

This issue relates to all versions of r57shell PAL shader (glsl/gles, cg, etc)

hizzlekizzle commented 3 years ago

I just tried this and it works well enough but has a very significant impact on performance, it seems. My framerate dropped by almost 50%. Is that worth the performance hit, you think? Here's a copy of the modified shader if you'd like to try it: https://pastebin.com/eJ4kCnQ9

eugene-s-nesdev commented 3 years ago

Thank you. Is this CG or GLSL code? Tried on puNES but it can't load it. Can you attach it?

Is that worth the performance hit, you think?

Yep, it worth. r57shell is once shader at this moment which can generate PAL NES palette very close to hardware. Maybe default values isn't very accurate yet, but user can adjust it. I will try to find more accurate values in the future. There are some hardware capturing screenshots: avermedia305.zip USE RAW (enabled) + //USE LUT (disabled) options works fullspeed at 1050ti. This is slowest mode.

hizzlekizzle commented 3 years ago

Ah, the pastebin is for slang, sorry. I'll try to get the other formats updated, as well, ASAP.

eugene-s-nesdev commented 3 years ago

Mistake about use USE LUT, it reduce quality but increase performance. Topic post fixed. Also USE LUT works only when USE RAW enabled, otherwise it does nothing (Look at comments in the shader's source code)

hizzlekizzle commented 3 years ago

Ok, here's a GLSL version to test: https://pastebin.com/LXaFngiS

Let me know how it treats you.

eugene-s-nesdev commented 3 years ago

Saved code to pal-r57shell.glsl and puNES crashes every time at startup. test.zip

hizzlekizzle commented 3 years ago

does it give you any kind of error? It seems to be working fine here in RetroArch.

eugene-s-nesdev commented 3 years ago

No. But it happens only on windows-glsl build. Emulator crashes with no-warnings. I've just compiled punes from scratch on mint 19.3 and both (old and new) shaders works perfectly. Strange thing.

Source and autobuilds are here: https://github.com/punesemu/puNES

eugene-s-nesdev commented 3 years ago

Fresh commit https://github.com/punesemu/puNES/commit/31a7bd2c101db15313806a075d17a1d4f6fcf437 fixes crash. For now it works.

hizzlekizzle commented 3 years ago

Ok, great to hear! I guess I'll get those changes pushed up to the repo, then :)

EDIT: alright, done, for glsl and slang, at least. I'll try to find time to handle the Cg version soon.