Author Topic: Simulate CRT  (Read 6194 times)

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Simulate CRT
« 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
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.

Asobi tech - the science of play.
Spare time indiegame developer.

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Re: Simulate CRT
« Reply #1 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
Asobi tech - the science of play.
Spare time indiegame developer.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4218
    • View Profile
    • Portfolio
Re: Simulate CRT
« Reply #2 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.

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Re: Simulate CRT
« Reply #3 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.
Asobi tech - the science of play.
Spare time indiegame developer.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Simulate CRT
« Reply #4 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.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Re: Simulate CRT
« Reply #5 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.
Asobi tech - the science of play.
Spare time indiegame developer.

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Re: Simulate CRT
« Reply #6 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

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4218
    • View Profile
    • Portfolio
Re: Simulate CRT
« Reply #7 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.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Simulate CRT
« Reply #8 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?
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: Simulate CRT
« Reply #9 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.

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4218
    • View Profile
    • Portfolio
Re: Simulate CRT
« Reply #10 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.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3679
    • View Profile
    • Space Fractal
Re: Simulate CRT
« Reply #11 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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Simulate CRT
« Reply #12 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.
I came. I saw. I played.

MrTAToad

  • Guest
Re: Simulate CRT
« Reply #13 on: 2015-Aug-28 »
They tried it with the remake of Flashback, and, in addition to no sound, it wasn't great...

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4218
    • View Profile
    • Portfolio
Re: Simulate CRT
« Reply #14 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.