GLBasic forum

Main forum => GLBasic - en => Topic started by: quangdx on 2015-Aug-27

Title: Simulate CRT
Post by: quangdx on 2015-Aug-27
Hello everyone,
does anyone have any idea how I would simulate a CRT effect with GLBasic?
As covered in this article
http://gamasutra.com/blogs/KylePittman/20150420/241442/CRT_Simulation_in_Super_Win_the_Game.php (http://gamasutra.com/blogs/KylePittman/20150420/241442/CRT_Simulation_in_Super_Win_the_Game.php)
I make a lot of stuff in a low res, like 320x200 and 256x244 and it would be nice to give the player the option to have a CRT effect in place.
I've read elsewhere in the forum that GLBasic supports shaders, but I don't know where to even start with shaders.
Any help would be great, thanks.

(http://i.imgur.com/1WCUmzt.png)
Title: Re: Simulate CRT
Post by: quangdx on 2015-Aug-27
I found this cool tutorial, but no idea how to implement it in GLBasic
http://code.tutsplus.com/tutorials/create-a-retro-crt-distortion-effect-using-rgb-shifting--active-3359
Title: Re: Simulate CRT
Post by: erico on 2015-Aug-27
I didn´t check the links, but you can probably do by rendering your game on a virtual screen and uvmap it on a 3d tube.
Apply a scanline map with a set transparency and someother bits and bobs, like another map with darker borders and so on.

Overall, I will be sincere, I fully dislike crt simulation and on all games with it, I search for how to turn it off, like the locomalito´s games.
Cheers.
Title: Re: Simulate CRT
Post by: quangdx on 2015-Aug-27
UVMap erico?
I appreciate you may not like the effect. But that's why you give the choice to the player.
Title: Re: Simulate CRT
Post by: kanonet on 2015-Aug-27
You can simply draw an image with Alpha channel on top that contains those buttom to top lines etc. Would need proper alpha mode settings too of cause.
Title: Re: Simulate CRT
Post by: quangdx on 2015-Aug-27
Quote from: kanonet on 2015-Aug-27
You can simply draw an image with Alpha channel on top that contains those buttom to top lines etc. Would need proper alpha mode settings too of cause.

That's fine for the scan lines,
but I was more looking for the curve of the CRT and to some extent the separation of RGB channels.
Title: Re: Simulate CRT
Post by: mentalthink on 2015-Aug-27
For do the curve you can use Polyvector tray to do a "mesh" with divided segments and use the UW map like said erico, (Take a look to polyvector you will see what I want say with UW).

Another way but really I think don't works, is: In 3D put a plane curved, use a viewport for paint in 2d, and use grabsprite and capture the 2d viwewport (perhaps using memsprite runs quick, but I don't know how works) , then paint this sprite in the 3d mesh with X_texture, but I think this will be very slow and you can see the game working fine.

About divide the RGB channels, search in the forum, we have some tutorial about this, I think in sample folder have one, is easy to do.

No more ideas  =D
Title: Re: Simulate CRT
Post by: erico on 2015-Aug-27
The 3d uvmap that Mental described is what I meant.
You can CREATESCREEN and do your game stuff there, then use it as a texture on a tube curved 3d object.
Title: Re: Simulate CRT
Post by: kanonet on 2015-Aug-27
I think you would need a mixture of different technics:

-Alpha overlay image for scan lines

-USESCREEN+POLYVECTOR for drawing in curved shape

-Color distortion/RGB separations could be achieved either by shipping your game with a second set of images in that colors or manipulate them on loading with MEM2SPRITE etc. I would not go with manipulation on runtime, that probably would be to slow. If you can use shaders on your target devices this also is an option. Or did you try if you can achieve a mild version of that effect with a special semitransparent overlay image and some playing with settings for alpha blending?
Title: Re: Simulate CRT
Post by: Hemlos on 2015-Aug-28
Please, no offense...
Lemme get this right, you WANT your game to look crappy??

I remember the CRT days......I want to make mention about the image that is simulated on the link to the tutorial ...
This simulation of a CRT tube , is one that:
A. the crt monitor is in CRAPPY CRAPPY condition, probably old.
B. Probably sitting next to a stereo speaker, or even ON a speaker.

CRT were distorted by magnets......thats what usually caused that weird color shift.

A shader can definetly do this to any game, but the shader will need to be custom designed for GLBasic language, by you.
In other words...you need to edit your shader, so that it can accept the proper inputs from your program.
X_PUTSHADER only lets you pass floating point numbers....sad but true.

Perfect in your case: you only need to send GETTIMERALL(), the shader should be able to do the rest of the work.

Title: Re: Simulate CRT
Post by: erico on 2015-Aug-28
Yep, I guess for old people, that dirty arcade with a crt that was never cleaned and was probably burned with the game´s title looks crappy.
But there is the nostalgia thing and it is also cool to nowadays kids to experience such. Personally, I never liked it.

I think using shaders would be overkill, even a 3d object would be too.
My guess is that Kanonet´s solution is the best one.
Title: Re: Simulate CRT
Post by: spacefractal on 2015-Aug-28
im would also not like deformed picture either, that does not work on LCD at all. Also many 16 bit games also ran on monitores using scanlines.

So instead, its better to uses color blending, noise, scanlines, motionblur and such artifact effects. Scanline is property the easiest one.
Title: Re: Simulate CRT
Post by: Ian Price on 2015-Aug-28
Yeah, I don't see the point of CRT style games either. I love and have loved thousands of old games, and I've been there with them throughout the history of gaming, and I'm a real chunky pixel guy, but scanlines and such? Nah.
Title: Re: Simulate CRT
Post by: MrTAToad on 2015-Aug-28
They tried it with the remake of Flashback, and, in addition to no sound, it wasn't great...
Title: Re: Simulate CRT
Post by: erico on 2015-Aug-28
Also, if you want the tube look, be sure that the output of your game is in a very high resolution, otherwise you will have problems with broken pixels and blending.
A 320x240 game will work on a full HD resolution. Same game with an 800x600 will have a lot of garbage.
Title: Re: Simulate CRT
Post by: spacefractal on 2015-Aug-29
also NES and SNES horizontal stretched the image as well, so they did not produce a 1x1 pixel. This should of course been simulated as well.

Im also have did a game in even lower resolution (CatchOut), which simulated a Fairchild F resolution. Here im diddent go after CRT simulator as well, but used its palette.

Scanlines does not work in every thing, and im dont like 100% scanlines as well, but often im uses about 50% scanline in emulators, if there is such a feature. This can easy to been simulated in glbasic eventuelly.

PS. The CRT shader used in that link IS really nicely.
Title: Re: Simulate CRT
Post by: quangdx on 2015-Aug-30
It all comes down to personal preference,  and as Erico it's a form of enhancing nostalgia.
Thanks for all the feedback on this.
Title: Re: Simulate CRT
Post by: erico on 2015-Aug-30
The border reflection of the screen as your prime example is way way harder and way off realistic. ;)
Apart from personal opinions, let us know how it goes.

I don´t know...it all depends on your needs and target, but to be really old school, I´d go for a 320x240, 640x480, 800x600 or 1024x728 as high quality tubes can go that way, put it all on an arcade cabinet as it was. :)

Let´s not count later tube development and neither the likes of 2 tubes together (darius or punch out).  :P

Cheers.
Title: Re: Simulate CRT
Post by: Gary on 2015-Sep-04
I found out on Rare Replay on Xbox One last night if you click the right analog stick it puts a CRT filter on the screen with the curving, blurring effect. 3 seconds later I clicked it and turned it off. It actually looked better all pixelated rather than that filter