caligari Posted October 31, 2010 Posted October 31, 2010 Hi, I've been playing around with the shader option in Demul, in order to add scanlines... At first I used some shaders found on the net, but ended up writing my own ones (using the scanline-tv formulaes from mame plus) Here are some screenshots (as you will see, there are different options, on based on the resolution you play in, you'll prefer using 2, 3 or 4 line modes) 1280x960, scanlines using 4 lines 1280x960, scanlines on 3 lines 1280x960, scanlines on 3 lines 1280x960, scanlines using 2 lines 640x480, scanlines using 4 lines 640x480, scanlines using 2 lines Now, to do that, you'll need two files (I saved them in a shaders subdirectory inside my Demul installation dir) First file : scanlines.slv You shouldn't have to change this one uniform vec4 OGL2Param; uniform vec4 OGL2Size; void main() { float x = (OGL2Size.x/2048.0)*OGL2Param.x; float y = (OGL2Size.y/1024.0)*OGL2Param.y; gl_Position = ftransform(); gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[1].xy = gl_TexCoord[0].xy + vec2( x, 0.0 ); } Second file : scanlines.slf It's in this file that you will decide to use 2, 3 or 4 lines (As is, it's in 4 lines mode. If you want to change that, just uncomment the appropriate mode by removing the //) You can adjust the intensity on the scanlines by playing with the gl_FragColor = rgb*??? : ??? indicates how dark it will be : ???=1.0 means the color of the line will be the same as the original, ???=0.0 means the color of the line will be pure black. uniform sampler2D OGL2Texture; void main() { vec4 rgb = texture2D(OGL2Texture, gl_TexCoord[0].xy); // if x is even => smooth with next pixel if (fract(gl_FragCoord.x*0.5)>0.5) rgb = ( rgb + texture2D(OGL2Texture,gl_TexCoord[1].xy) )*0.5; // Test on 2 lines // float test = fract(gl_FragCoord.y/2); // if (test>0.5) gl_FragColor = rgb; // else gl_FragColor = rgb*0.5; // Test on 3 lines // float test = fract(gl_FragCoord.y/3); // if (test>0.666) gl_FragColor = rgb; // else if(test>0.333) gl_FragColor = rgb*0.75; // else gl_FragColor = rgb*0.5; // Test on 4 lines float test = fract(gl_FragCoord.y/4); if (test>0.75) gl_FragColor = rgb; else if (test>0.5) gl_FragColor = rgb*0.75; else if (test>0.25) gl_FragColor = rgb*0.5; else gl_FragColor = rgb*0.25; }
Bilbotorm Posted April 5, 2011 Posted April 5, 2011 Interesting =) Thanks for sharing. BTW : do you have any other filters ? can't find any for that emu
caligari Posted April 5, 2011 Author Posted April 5, 2011 At one time, I got more but I don't think I still have them. Anyway, I think they are more or less (it might need some tweaking) shaders made for ePSXe opengl2 plugin. You can get more here Anyway, I'll probably dig a little more on that matter during my holidays, I'm quite interested by this rendering. I'd like to use it in Mame too (which may be possible using SDLMame and the same shader technique)
Bilbotorm Posted April 5, 2011 Posted April 5, 2011 Thank you for the link. Will wait to see your update then
caligari Posted May 2, 2011 Author Posted May 2, 2011 I got some time this week end, so I reopened this project of mine Here are some results, to simulate the "barrel distorsion" effect. Without scanlines: (Note : the grid on the second screenshot was here for testing... I forgot to remove it before making the screenshot) With scanlines (far from perfect, there are a lof of artifacts... Moreover the scanlines are not aligned on the game pixels)
caligari Posted May 9, 2011 Author Posted May 9, 2011 Round 3 I changed a few parameters, and I think it starts to look quite nice: the moire is still there but less noticable.
djcasey Posted July 19, 2011 Posted July 19, 2011 caligari really nice effects, is it compatible with lastest demul ?? can you share us how to make this effects
cnm Posted July 31, 2011 Posted July 31, 2011 Brilliant work, Caligari - thanks for sharing! I can't seem to find anywhere to enable shaders in Demul 0.5.6.. I have the files setup as described in your first post, but how are they enabled inside Demul?
Pyramid_Head Posted October 8, 2011 Posted October 8, 2011 Round 3 I changed a few parameters, and I think it starts to look quite nice: the moire is still there but less noticable. Amazing! Similar to the hlsl effects in the latest Mame(s). How did you achieve this? Sorry for bumpng
caligari Posted October 9, 2011 Author Posted October 9, 2011 Amazing! Similar to the hlsl effects in the latest Mame(s). How did you achieve this? Sorry for bumpng Well, it's more than similar, it's the same methods : we just add some pixel shaders In Demul, it's done by: 1. Putting some shaders (two files: a .slf and a .slv) in a shaders subdirectory 2. Selecting the OpenGL Video plugin 3. In the plugin configuration, check the shader effects box and select the one you wish to use Here are the one I have : shaders.zip I did not touch them for a while (I worked more recently on them, but with bsnes*, see here and here) so I'm not sure which one is which. The one from the last screenshots is probably one of the CRT-something. Also, the screen size needs to be entered in the .slf files : you'll find in the first lines something looking like static vec2 ScreenSize = vec2(1280.0, 960.0); This means that to get the intended effect, you have to use Demul in 1280x960! If you want another resolution, change those number before launching the emulator! (*) as a matter of fact, the first versions came from bsnes shaders that I ported to Demul. (My last bsnes shaders are now better than the one I just posted, but need to be ported to to Demul!)
djvj Posted October 9, 2011 Posted October 9, 2011 Those shaders are great caligari, thanks for your work on them "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."RocketLauncher's Official Home If you appreciate my work:My Apps:Window LoggerIdle Volume AdjusterExplorerRestorerRom Folder CleanerModule UpdaterMy Guides:How To Mod Guncons with Aimtrak
Pyramid_Head Posted October 9, 2011 Posted October 9, 2011 Well, it's more than similar, it's the same methods : we just add some pixel shaders In Demul, it's done by: 1. Putting some shaders (two files: a .slf and a .slv) in a shaders subdirectory 2. Selecting the OpenGL Video plugin 3. In the plugin configuration, check the shader effects box and select the one you wish to use Here are the one I have : shaders.zip I did not touch them for a while (I worked more recently on them, but with bsnes*, see here and here) so I'm not sure which one is which. The one from the last screenshots is probably one of the CRT-something. Also, the screen size needs to be entered in the .slf files : you'll find in the first lines something looking like static vec2 ScreenSize = vec2(1280.0, 960.0); This means that to get the intended effect, you have to use Demul in 1280x960! If you want another resolution, change those number before launching the emulator! (*) as a matter of fact, the first versions came from bsnes shaders that I ported to Demul. (My last bsnes shaders are now better than the one I just posted, but need to be ported to to Demul!) Thanks for the posting your shader effects! Though each time I try to load a game I get a little box that pops up saying "unable to compile fragment shader effects" I'm using Demul 0.5.6. *Edit* I've only tried the CRT ones. Not sure if I get the error on the others.
caligari Posted October 10, 2011 Author Posted October 10, 2011 Thanks for the posting your shader effects! Though each time I try to load a game I get a little box that pops up saying "unable to compile fragment shader effects" I'm using Demul 0.5.6.*Edit* I've only tried the CRT ones. Not sure if I get the error on the others. That may have to do with your graphic card... When I first wrote those shaders, I wasn't aware of some coding specifications, and on some ati(?) cards, they didn't work until the code was corrected to be compliant. I should be able to correct that, but right now I don't have the time to do it, sorry!
Pyramid_Head Posted October 10, 2011 Posted October 10, 2011 That may have to do with your graphic card... When I first wrote those shaders, I wasn't aware of some coding specifications, and on some ati(?) cards, they didn't work until the code was corrected to be compliant.I should be able to correct that, but right now I don't have the time to do it, sorry! It could be my graphics card. I'm using an Ati Radeon 4670. Is it easy to correct? I'd try myself but wouldn't really know what to do
caligari Posted October 10, 2011 Author Posted October 10, 2011 It could be my graphics card. I'm using an Ati Radeon 4670. Is it easy to correct? I'd try myself but wouldn't really know what to do Well it's not really hard, it's just... painful. For example, textures are stored (if I remember correctly) in vec4 structures: for each point you get one float for red, one for green, one for blue and one for alpha. So a texture point T will have 4 float values : r,g,b,a. Often in those shaders, we don't really care for the alpha value, and we will only manipulate r,g,b, so we work with T.rgb (it means red, green and blue componenents of T: we ditch the alpha value) But by doing so, we manipulate a vec3 structure... and at some point, you are expected to output a vec4 structure. I think that when asked to work with that, a nvidia card will accept the vec3 structure, and silently transform it into the expected vec4 by adding an alpha value of 1.0. An ati card will say "this should be a vec4, you give me a vec3... No way!" So basically, to fix this, one needs to use the correct structures where they are expected... Not difficult once you know what to look for. (Also, this vec4/vec3 problem is just an example! There are similar problems with vec2 and other structures) I don't really want to correct the above versions since the new ones I did for bsnes are better... It makes more sense to translate those!
Pyramid_Head Posted October 10, 2011 Posted October 10, 2011 Well it's not really hard, it's just... painful.For example, textures are stored (if I remember correctly) in vec4 structures: for each point you get one float for red, one for green, one for blue and one for alpha. So a texture point T will have 4 float values : r,g,b,a. Often in those shaders, we don't really care for the alpha value, and we will only manipulate r,g,b, so we work with T.rgb (it means red, green and blue componenents of T: we ditch the alpha value) But by doing so, we manipulate a vec3 structure... and at some point, you are expected to output a vec4 structure. I think that when asked to work with that, a nvidia card will accept the vec3 structure, and silently transform it into the expected vec4 by adding an alpha value of 1.0. An ati card will say "this should be a vec4, you give me a vec3... No way!" So basically, to fix this, one needs to use the correct structures where they are expected... Not difficult once you know what to look for. (Also, this vec4/vec3 problem is just an example! There are similar problems with vec2 and other structures) I don't really want to correct the above versions since the new ones I did for bsnes are better... It makes more sense to translate those! I see. Wow sounds difficult. I would give that a try but I'd be in over my head ha ha. I can wait till you translate your bsnes ones. Thanks for posting the info! At least my laptop has a decent Nvidia card I can always try it on that
caligari Posted October 27, 2011 Author Posted October 27, 2011 Well, you're in luck, I was on holidays so I had some time in the past days... Now a few things: * first, it's still a WIP, it needs some tuning * I have other versions to port back from bsnes, some may give better results! I just had time for this one * As before, you'll have to edit the first lines. The more important parameters are - ScreenSize : it's the resolution you play in - HWSize : it's the original resolution you want for the game (I wanted it to be 640x480 by default, but if your screen res is too low, you might want to reduce this one) - DOT Size : this is what will decide the shape of the effect. Playing with this, you'll get scanlines, (horizontal or vertical), linear blending... Or very ugly things. * There are a few other parameters... They are described in the file * I tried to be careful, but I don't garanty this version will work on an ATI card, I didn't get the chance to test it on my cab... File name: shaders_v2_wip.zip File size: 2.37 KB
Pyramid_Head Posted October 27, 2011 Posted October 27, 2011 Well, you're in luck, I was on holidays so I had some time in the past days...Now a few things: * first, it's still a WIP, it needs some tuning * I have other versions to port back from bsnes, some may give better results! I just had time for this one * As before, you'll have to edit the first lines. The more important parameters are - ScreenSize : it's the resolution you play in - HWSize : it's the original resolution you want for the game (I wanted it to be 640x480 by default, but if your screen res is too low, you might want to reduce this one) - DOT Size : this is what will decide the shape of the effect. Playing with this, you'll get scanlines, (horizontal or vertical), linear blending... Or very ugly things. * There are a few other parameters... They are described in the file * I tried to be careful, but I don't garanty this version will work on an ATI card, I didn't get the chance to test it on my cab... File name: shaders_v2_wip.zip File size: 2.37 KB Awesome, thanks! I'll give this a shot! I'm also interested in bsnes stuff since I replaced my SNES emu with that one
Pyramid_Head Posted June 17, 2012 Posted June 17, 2012 I apologize for bumping this thread. But I was wondering if you were still working on these shaders? I'm not sure if they are compatible with 5.7 but I still use 5.6 and would love to have HLSL effect in Demul for Naomi and Atomiswave. The only thing that seems to do the "curved" effect is the barrel shader.
AshuraX Posted May 3, 2013 Posted May 3, 2013 Round 3 I changed a few parameters, and I think it starts to look quite nice: the moire is still there but less noticable. Salut caligari! Je souhaiterais mettre l'effet barrel distortion comme sur tes screenshots peux tu m'expliqué comment tu ajoutes cet effet, j'ai créer les deux fichier mais j'ai pas compris ceux que tu as fais pour avoir la distortion! Merci ^^ My WIP Projects :Bezel Project Mame Horizontal : https://imageshack.com/a/auM4/1 Mame Vertical : https://imageshack.com/a/jEM4/1 Cave full pack : https://imageshack.com/a/7eJ4/1 Capcom : https://imageshack.com/a/eIM4/1 Themes Neo Geo Full Theme Pack : https://imageshack.com/a/oeJ4/1Mega CD Boxart : new thread will come....My First Cab Build : http://www.hyperspin-fe.com/topic/1221-ashurax-mon-projet-ghouls-ghost-arcade-cab/
Dogway Posted April 11, 2014 Posted April 11, 2014 Well, you're in luck, I was on holidays so I had some time in the past days...Now a few things: * first, it's still a WIP, it needs some tuning * I have other versions to port back from bsnes, some may give better results! I just had time for this one * As before, you'll have to edit the first lines. The more important parameters are - ScreenSize : it's the resolution you play in - HWSize : it's the original resolution you want for the game (I wanted it to be 640x480 by default, but if your screen res is too low, you might want to reduce this one) - DOT Size : this is what will decide the shape of the effect. Playing with this, you'll get scanlines, (horizontal or vertical), linear blending... Or very ugly things. * There are a few other parameters... They are described in the file * I tried to be careful, but I don't garanty this version will work on an ATI card, I didn't get the chance to test it on my cab... File name: shaders_v2_wip.zip File size: 2.37 KB Hello, can anyone repost the shaders? Or any other decent CRT shader to add to demul ? Playing arcade on bare pixels should be prohibited. or do you think SweetFX is a better option?
Rick74 Posted April 11, 2014 Posted April 11, 2014 I've been trying to figure out how to use sweet fx with Demul for a while with no luck... If anyone can figure it out, It'd be much appreciated.. Atomiswave needs them scanlines!
Dogway Posted April 12, 2014 Posted April 12, 2014 Rick74, I got it working. Unzip files on demul root folder, delete dx9 dll file, demul only accepts 10 or 11 so it will use dxgi.dll. 32bit files is OK. I'm going to upload some settings configurations here, do you too. Now on my 1280x1024 monitor screen, but tomorrow I will check on my HDReady TV. edit: here my crt settings, I only enable bloom along this. I don't seem to find a perfect scanline resolution, but 1.2 is near though. Also CRTDistance makes an ugly ghosting effect, I don't know if that's on purpose. And, can't seem to set CRTAngleY to 0, or it will blank screen. #define CRTAmount 0.5 //[0.00 to 1.00] Amount of CRT effect you want #define CRTResolution 1.2 //[1.0 to 8.0] Input size coefficent (low values gives the "low-res retro look"). Default is 1.2 #define CRTgamma 1.5 //[0.0 to 4.0] Gamma of simulated CRT (default 2.2) #define CRTmonitorgamma 2.9 //[0.0 to 4.0] Gamma of display monitor (typically 2.2 is correct) #define CRTBrightness 2.5 //[1.0 to 3.0] Used to boost brightness a little. Default is 1.0 #define CRTScanlineIntensity 2.0 //[2.0 to 4.0] Scanlines intensity (use integer values preferably). Default is 2.0 #define CRTScanlineGaussian 1 //[0 or 1] Use the "new nongaussian scanlines bloom effect". Default is on #define CRTCurvature 1 //[[0 or 1] "Barrel effect" enabled (1) or off (0) #define CRTCurvatureRadius 2.0 //[0.0 to 2.0] Curvature Radius (only effective when Curvature is enabled). Default is 1.5 #define CRTCornerSize 0.0300 //[0.0000 to 0.0020] Higher values, more rounded corner. Default is 0.001 #define CRTDistance 4.00 //[0.00 to 4.00] Simulated distance from viewer to monitor. Default is 2.00 #define CRTAngleX 0.00 //[-0.20 to 0.20] Tilt angle in radians (X coordinates) #define CRTAngleY -0.05 //[-0.20 to 0.20] Tilt angle in radians (Y coordinates). (Value of -0.15 gives the 'arcade tilt' look) #define CRTOverScan 1.00 //[1.00 to 1.10] Overscan (e.g. 1.02 for 2% overscan). Default is 1.01 #define CRTOversample 1 //[0 or 1] Enable 3x oversampling of the beam profile (warning : performance hit) I think it would be wise to load a custom shader, cgwg made a nice one, just read here. I was using retreoarch's shaders in custom.h and they seem to work if it wasn't for this error, so near, yet so far : ( SweetFX\Shaders\Custom.h(56,3): error X3086: the 'sampler2D' keyword is deprecated in strict mode; use 'SamplerState' instead
Rick74 Posted April 12, 2014 Posted April 12, 2014 Rick74, I got it working. Unzip files on demul root folder, delete dx9 dll file, demul only accepts 10 or 11 so it will use dxgi.dll. 32bit files is OK.I'm going to upload some settings configurations here, do you too. Now on my 1280x1024 monitor screen, but tomorrow I will check on my HDReady TV. edit: here my crt settings, I only enable bloom along this. I don't seem to find a perfect scanline resolution, but 1.2 is near though. Also CRTDistance makes an ugly ghosting effect, I don't know if that's on purpose. And, can't seem to set CRTAngleY to 0, or it will blank screen. #define CRTAmount 0.5 //[0.00 to 1.00] Amount of CRT effect you want #define CRTResolution 1.2 //[1.0 to 8.0] Input size coefficent (low values gives the "low-res retro look"). Default is 1.2 #define CRTgamma 1.5 //[0.0 to 4.0] Gamma of simulated CRT (default 2.2) #define CRTmonitorgamma 2.9 //[0.0 to 4.0] Gamma of display monitor (typically 2.2 is correct) #define CRTBrightness 2.5 //[1.0 to 3.0] Used to boost brightness a little. Default is 1.0 #define CRTScanlineIntensity 2.0 //[2.0 to 4.0] Scanlines intensity (use integer values preferably). Default is 2.0 #define CRTScanlineGaussian 1 //[0 or 1] Use the "new nongaussian scanlines bloom effect". Default is on #define CRTCurvature 1 //[[0 or 1] "Barrel effect" enabled (1) or off (0) #define CRTCurvatureRadius 2.0 //[0.0 to 2.0] Curvature Radius (only effective when Curvature is enabled). Default is 1.5 #define CRTCornerSize 0.0300 //[0.0000 to 0.0020] Higher values, more rounded corner. Default is 0.001 #define CRTDistance 4.00 //[0.00 to 4.00] Simulated distance from viewer to monitor. Default is 2.00 #define CRTAngleX 0.00 //[-0.20 to 0.20] Tilt angle in radians (X coordinates) #define CRTAngleY -0.05 //[-0.20 to 0.20] Tilt angle in radians (Y coordinates). (Value of -0.15 gives the 'arcade tilt' look) #define CRTOverScan 1.00 //[1.00 to 1.10] Overscan (e.g. 1.02 for 2% overscan). Default is 1.01 #define CRTOversample 1 //[0 or 1] Enable 3x oversampling of the beam profile (warning : performance hit) I think it would be wise to load a custom shader, cgwg made a nice one, just read here. I was using retreoarch's shaders in custom.h and they seem to work if it wasn't for this error, so near, yet so far : ( Keep me posted... I'd like to use RetroArch CRT_geom_flat.cg
Recommended Posts
Archived
This topic is now archived and is closed to further replies.