That looks extremely authentic. I think a lot of folks would be interested in a generalized dot matrix shader.
Yeah Iām interested too. Very cool.
Newest version can be found here https://github.com/HarlequinVG/shaders/tree/master/gameboy_shader. Looks about the same as above but the code is a lot cleaner. There seems to be an issue under D3D where itās setting alpha values of all output textures to 1.0 when theyāre passed down the chain, so run it in OpenGL for now. If it wonāt work for you, posting the relevant lines from the error log will help me identify and correct the issue.
The readme file lists where you can find the different configuration variables (contrast, shadows, blending, etcā¦) to tweak the output to your liking. You can change the palette as well, but I havenāt had a chance to test the color system with other colors so Iām not sure how itāll look.
Going to work on integrating motion blur next. I think I can make the ghosting effect a lot more genuine looking than the old method under the new color system.
āedit-- Tried some other palettes, it seems to work fine as long as you think about it like the foreground color is a tint. If the background is black, youāre only going to see see black because no matter what color you tint black itās still going to be⦠black.
āedit2-- Motion blur is now implemented. You might have to play around with the response_time variable in gb_pass_0.cg a little to get it to your personal preference. Iāve found that 0.3 to 0.4 seems to work fairly well.
It works great on my Radeon. The verisimilitude is really uncanny at this point, and the motion blur looks really nice. Itās funny running other cores through it and seeing them Gameboy-ified
All in all, youāve done a great job on it, and having clean, commented code is icing on the cake.
Updated the git with a new background system that allows for background images with highlights (before it just multiplied the background image by the background color, so it could never be brighter than the background color). Should allow for more metallic looking backgrounds. Also put in a smoothing option that lets your control how much of the backgroundās color variance is hidden directly beneath the foreground since this can result in a lot of visual clutter and make the game hard to see. This is listed in the gb_pass_4.cg file under the config header as ābg_smoothingā.
I added some more built in color palette and background options. My photoshop skills arenāt the greatest, but they should give people an idea what to do if they want to make their own backgrounds. The image dmg_background.png is the best approximation of the actual dot matrix Gameboy screen that I could produce using photoshopās built in filters. The gbp_palette.png was created with the help of an anon on emulation general and the grainy_background.png is loosely based photos that he provided of the Gameboy Pocket (itās really not very good, though, my photoshop skills failed me).
Oh, and I changed around the default configuration to what seemed a little more authentic to me. I donāt suppose itās possible to put these into their own config file somehow and load them in as uniforms, is it?
Was playing around in Photoshop trying to come up with a good technique for reproducing the GBC screen. All my attempts seem to end up looking more like an aperture grille from a CRT than an LCD pixel though.
This is the best mock up I could come up with, but it only passingly resembles the GBC. Going to have to play around some more, looks like itās going to be a little more complicated than the original Gameboy.
In 0.9.9-wip1, I fixed an issue in D3D9 which might interest you. FBOs were in XRGB8888 format instead of ARGB8888 format. Your shader might work now.
I kind of patchworked in some changes to the GB shader for use with color just to see what itād look like (itās not on the git, the code is a mess of conditionals that Iām surprised even runs). Without all the alpha blending it kind of just looks like⦠a grid and a border. I think Iām going to try approaching it more like an exaggerated LCD screen.
I suppose I should share the LCD shader that I put together. Itās a combination of a shader that I made a couple months ago (which began from a modification of the Pixellate shader; Iād post the link, but Iām only allowed one link per post for some reason) and the simple motion blur from hunterk. The shader is here.
Interesting, similar basis to one of the methods I experimented with earlier in Photoshop. The magenta/yellow/cyan route definitely helps retain a lot of the brightness over RGB and seems to help with color fidelity.
Currently having issues figuring out a method that scales well, though. In this image Iām using non-scaling virtual pixels made up of 3x3 actual pixels, resulting in pixel quadrupling for what should be a single pixel in a 6x scale image. Just extending the colors out into a gradient to enlarge the virtual pixels drastically reduced the image quality. Still experimenting but I havenāt found anything Iām happy with yet.
Great, updated the GB shader with a minor change and it now functions with D3D with this fix.
I made a little bit of progress in my search for an approach to an LCD shader for GBC and other handhelds. This seems to be the best compromise I could come up with so far for scaling images without too much color separation. Thereās a definite darkening of the image, but I think I can solve that while simulating lighting (the colors on a backlit screen will look different from the colors on a frontlit screen).
āedit-- Started applying the approach above in an actual shader rather than just a mockup. Still needs work, but the general effect seems somewhat handheld LCD-like. Hereās a shot of it running in-game currently:
āedit2-- You can find an early version of the LCD shader here:
If the default settings are too subtle or too strong for your liking, you can take a look through the .cg files and play around with some of the config options. Iāve mostly tested it with VBA, so Iām not sure if itāll work well with other emulators or not. Higher resolutions seem to result in better image quality (would recommend minimum 4-5x scale). Practically speaking, I wouldnāt mess with cell_scale value in lcd_pass_1.cg unless youāre playing at 6x or 9x scale and are sitting far back from your display, like on a HTPC or something.
Iāve tried both the gameboy an the new lcd shader with RA 0.9.9-wip. They run fine in windowed mode, but not when in fullscreen mode (fps <60).
Is it an issue that youāve only had with that specific build, eadmaster?
Iām not surprised that it might run slow for some users, though. Iāve only done some ghetto performance testing by unlocking the framerate and looking at the FPS hits, the overhead of just chaining stock shaders together in a .cgp file seems to be about a 7-8% FPS drop per pass on my GTX460. These are probably more severe than that since thereās a lot more operations and texture lookups involved than in a stock shader. The sudden performance drop between windowed and fullscreen might be due to the FBOs going from 1024x1024 to 2048x2048, depending on the viewport resolutions.
I could probably make a more lightweight version of the Gameboy shader with only some minimal sacrifices. The LCD shader is probably a little bloated too (the border system really isnāt necessary, just tacked it on while I was internally forcing integer scaling which can be forced through RA anyways, and might not even be necessary in the next version of the shader).
Sorry for the lack of updates lately. Playing around with shaders kind of got me interested in graphics programming so Iāve been doing a lot of reading on OpenGL the past few days. Fun stuff.
No problems here at all with the lcd_shader
Iāve tested with GBC and GBA on my i7 3770K with GTX480 and AMD A5700 with Radeon 7660D (integrated GPU on CPU) (both OpenGL).
Works in window mode and fullscreen (prefer windows fullscreen) without problems and fps drops.
Nice work!
EDIT: well⦠it just looks completly different to your Screenshot: http://i.imagebanana.com/img/f7sshacu/RetroArch0427230825.png
Iāve just re-tried lcd_shader with a lower fullscreen resolution, and this time it worked fullspeed⦠probably my integrated GPU (Radeon 6530D) is too slow for 1920x1080.
Harlequin - Iāve given you commit acess to common-shaders. Hyllian thought it was a good idea so there you go.
If youād like you could upload your Game Boy shader and other things youāre working on.
Thanks Squarepusher, I went ahead and added the Gameboy and LCD shaders to the repository under the handheld directory.
Tried out the Game Boy shader on PS3 for the first time and it doesnāt work.
EDIT 1:
Found the issue with Nvidiaās cgc for PS3 -
<Squarepusher> [twinaphex@lenovo shader_files]$ sce-cgc.exe -e main_fragment -p sce_fp_rsx -o gb_pass_0.fpo gb_pass_0.cg <Squarepusher> gb_pass_0.cg <Squarepusher> gb_pass_0.cg(150) : error C1008: undefined variable āmodā <Squarepusher> gb_pass_0.cg(150) : error C1105: cannot call a non-function <Squarepusher> gb_pass_0.cg(150) : error C1008: undefined variable āmodā <Squarepusher> gb_pass_0.cg(150) : error C1105: cannot call a non-function <Squarepusher> gb_pass_0.cg(150) : error C1008: undefined variable āmodā <Squarepusher> gb_pass_0.cg(150) : error C1105: cannot call a non-function <Squarepusher> gb_pass_0.cg(150) : error C1008: undefined variable āmodā <Squarepusher> gb_pass_0.cg(150) : error C1105: cannot call a non-function
Replaced it with fmod and that seems to work for both PC and PS3.
Now it fails at loading one of the PNG textures (background.png). Iāll try to investigate that one as well. It might just be too big (2048x2048). Does it really need to be so huge? Itās pretty abnormal to have a huge 2048x2048 texture for something that just looks - well - āgreyā with no real apparent detail or reason why it needs to be so big.
Can you downsize it to 1024x1024?
EDIT2; Downsizing background.png to 1024x1024 makes it work at least. I will commit the updated background.png (1024x1024). Let me know if you have any objections to this later on - I asked Hyllian and hunterk and they thought going from 2048x2048 to 1024x1024 for the background texture shouldnāt matter.
Yeah, it really doesnāt need to be that big. That was a remnant from the first version of the shader when I was setting the FBOs to an absolute size of 2048x2048 and I thought itād be easiest to keep the background image the same size as the FBO, was still learning Cg at the time. I should rework that part of the shader anyways, itās literally just mapping the entire image to the screen currently so you end up with stretching no matter what size the texture is (didnāt notice this during development because I was using really simple backgrounds).
Kind of cool that you got it working on the PS3, though. Didnāt know much about optimizing shaders or compatibility issues when I started, I was surprised that it even ran on my PC with reasonable performance.
Just curious if I can be helpful with my makro lens to create a perfekt lcd shader (or Game Boy) I have every Game Boy handheld in my library (GB, GBC, GBP, GBL, GBA, GBA SPā¦). Here is an example of the Game Boy Color Screen (CGB-001): http://i.imagebanana.com/img/7i6u7wzt/IMG_0023.JPG As you can see, the subpixel gets more tiny at the lower end and the gap between pixels in horizontal way is bigger than vertical. Here is the Screen of my DSi-XL: http://farm5.staticflickr.com/4116/4777128707_2d68c5dd0e_o.jpg Itās slightly different. Your filters feels more a touch of red, but it is more of yellow, like on my photo.