Author Topic: Day/night cycle using shaders?  (Read 2364 times)

Offline r0ber7

  • Prof. Inline
  • *****
  • Posts: 526
    • View Profile
Day/night cycle using shaders?
« 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

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1456
    • View Profile
Re: Day/night cycle using shaders?
« Reply #1 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...
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Re: Day/night cycle using shaders?
« Reply #2 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.

Offline r0ber7

  • Prof. Inline
  • *****
  • Posts: 526
    • View Profile
Re: Day/night cycle using shaders?
« Reply #3 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.


Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1456
    • View Profile
Re: Day/night cycle using shaders?
« Reply #4 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.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4186
    • View Profile
    • Portfolio
Re: Day/night cycle using shaders?
« Reply #5 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.