Programming a "TV"

Started by
5 comments, last by LorenzoGatti 10 years, 5 months ago

Sorry, I hope this is the right forum.

Anyway, I would like to do something that looks like an old CRT-TV.

I already got the scan-line and vignette shader (GLSL), now my problem is that I need to slightly "bend" the surface on the edges to the back to create this illusion of an old CRT-TV surface. I am using Game Maker Studio, so I have only 2D capabilities and limited 3d functionality, like drawing models and manipulating matrices.

Can someone help me to get this started? smile.png

edit: A picture of what I mean in a game where I saw it. It is very subtle and I hope you can spot it in the screen well enough.

tHcVFUL.png

If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
Advertisement


I already got the scan-line and vignette shader (GLSL)

Where did you get it from?

Anyway, you can create the bent screen effect by using a bump map.

How would such a bump map look like?

Also, Game Maker can't really utilize bump maps :S.

Is there any other solution, except drawing a picture over the surface and faking it?

If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/

I would generally not use the term 'bump map' to describe it as that's a reference to an entirely different, very specific technique that just so happens to use a similar-looking texture as an input.

In simpler terms, you're using a distortion shader that adds or subtracts a value to the texture coordinate (distinct from the value sampled from a texture at that texture coordinate, though the actual offset would be taken from a second texture) depending on the location onscreen. tonemgub's soltution is basically to paint a texture that contains offsets gradually pointing towards the middle of the screen, with decreasing magnitude as you move away from one of the corners. It would work, but is likely more computationally expensive than it could be.

Fortunately, folks have already worked out how to do most of this with math. If you're interested in a really detailed CRT monitor simulation, give this neat site/shader a gander.

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.

Bump mapping is a lighting effect and completely unrelated. You just want to add some offsets to where you read your texture from in the GLSL shader - where you have something like texture(textureUniform, uv); try uv*=strength; texture(textureUniform, vec2(uv.x*sqrt(1.0-uv.y*uv.y*.5),uv.y*sqrt(1.0-uv.x*uv.x*.5))/strength); or some other similar mapping from square to disc instead.


distortion shader

Yup, that's exactly what I was thinking of too, but I tried to put it in simpler terms and it came out wrong. Sorry.


uv*=strength; texture(textureUniform, vec2(uv.x*sqrt(1.0-uv.y*uv.y*.5),uv.y*sqrt(1.0-uv.x*uv.x*.5))/strength);

But is it really faster to use real time calculations instead of a pre-rendered texture for the distortion offsets? I always thought it was the other way around - texture sampling should be faster than these calculations, at least. You're doing the calculations every frame, whereas for the texture - it is only filled with the distortion offsets once.

But is it really faster to use real time calculations instead of a pre-rendered texture for the distortion offsets? I always thought it was the other way around - texture sampling should be faster than these calculations, at least. You're doing the calculations every frame, whereas for the texture - it is only filled with the distortion offsets once.[/quote] Don't guess, measure. Run benchmarks with both versions of the shader applied to a set of computationally heavy cases of your game (e.g. multisampling and unusual amounts of overdraw to stress fragment processing, lots of geometry to stress vertex processing, artificially inflated texture number and sizes, etc.)

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement