GLBasic forum

Main forum => GLBasic - en => Topic started by: r0ber7 on 2017-Mar-24

Title: Day/night cycle using shaders?
Post by: r0ber7 on 2017-Mar-24
Hi,

Question: could I use X_LOADSHADER to load a shader that would change over time, giving a day/night cycle effect? I've tried setting up shaders before but didn't get them working correctly. I saw Hemlos knows a lot about it. Just wondering if it's worth the effort.

http://www.glbasic.com/forum/index.php?topic=1089.15

http://www.glbasic.com/forum/index.php?topic=10525.msg92970#msg92970
Title: Re: Day/night cycle using shaders?
Post by: MrPlow on 2017-Mar-26
You could turn on a transparent png and stagger the alpha setting over time?
Not sure how CPU intensive this option would be...
Title: Re: Day/night cycle using shaders?
Post by: mentalthink on 2017-Mar-27
I'm not sure how done with Shaders (perhaps you have to take a look to Complete Screen Shaders, in Leadwerks you can use this, and can apply an Shader to all complete Screen).

But if you use a Ligth, only is change the Color and Intensity, remind you have the OpenGL Port in Sample Folder, you can handle more things than the simple 3d in GLbasic.
Title: Re: Day/night cycle using shaders?
Post by: r0ber7 on 2017-Mar-31
Thanks for the suggestions.

I tried the lighting approach, this works but RGB(255,255,255) would show the image as normal, and only be able to make it darker. This wasn't exactly how I wanted it. Also the .png seems a good approach, but I couldn't get it to work well as I wanted (it was changing the underlying images in ways that looked too much like an overlay).

I think for now I will stop trying to do this, but in another project I may try it. I think if you start with images that are full daylight maybe a bit too bright, you can do this with a simple light, like mentalthink suggested.

Title: Re: Day/night cycle using shaders?
Post by: MrPlow on 2017-Mar-31
You could use the png on background objects and have a different png for foreground - if you are talking about a 2D game like your amiga-styled one.
Title: Re: Day/night cycle using shaders?
Post by: erico on 2017-Mar-31
Back in the amiga days, a pallet smooth swap would do the trick.
If you have indexed images on your games and control of single colors, you could code that.
You could also have 2 sets of each sprite, one day one night and fade between them.

My gameĀ“s case of day/storm cycle is resolved by switching the background image. I have some 5 images for that.
It does not mess with the front layer, it is just the background. Some sort of blueish overlay on the front objects could also help but it is not necessary in this case.

Apart from shaders, you could try alphamode, transparency and the likes overlaying the whole image.