Bart
WiseBart
Hi all.
I've been playing around with the application surface recently and, while doing so, tried to code a gradient that acts as the sky for a day and night cycle.
While I originally used a half sphere model for the sky, I figured that it could be more interesting to draw a gradient (draw_rectangle_color) in the Pre-Draw event for this. By changing the colors, it's quite easy to get a convincing day-night cycle.
Visually, this is the effect I'm after.
But it required a few 'tricks' to get this working right. The application surface needs to be cleared with an alpha value of 0 in a Draw Begin event for the things drawn in Pre-Draw to still be visible on screen. In that Draw Begin event, it's not possible to draw the rectangle, since all transformations are already being applied.
Also, it appears that you have to draw the application surface manually in the Post-Draw event so it blends correctly with the back buffer.
But this slows down the thing quite a bit, since in Pre-Draw, all rendering is done to the back buffer, which doesn't appear to work out so well on a 4K monitor in fullscreen... Also, the alpha blending of the application surface with the back buffer probably takes place 3840x2160 times.
In a second attempt, to solve the above issues, I switched to rendering to a view surface of 1920x1080 that is then scaled up to fit the actual window size. This seems to work fine, but it requires disabling the application surface completely, since there's no use using it when I have a custom surface to render to.
I'm wondering if there are better ways to achieve the effect I'm after that don't require the use of a custom view surface or ways that are more efficient.
Has anyone done something similar or have experience with this?
I've been playing around with the application surface recently and, while doing so, tried to code a gradient that acts as the sky for a day and night cycle.
While I originally used a half sphere model for the sky, I figured that it could be more interesting to draw a gradient (draw_rectangle_color) in the Pre-Draw event for this. By changing the colors, it's quite easy to get a convincing day-night cycle.
Visually, this is the effect I'm after.
But it required a few 'tricks' to get this working right. The application surface needs to be cleared with an alpha value of 0 in a Draw Begin event for the things drawn in Pre-Draw to still be visible on screen. In that Draw Begin event, it's not possible to draw the rectangle, since all transformations are already being applied.
Also, it appears that you have to draw the application surface manually in the Post-Draw event so it blends correctly with the back buffer.
But this slows down the thing quite a bit, since in Pre-Draw, all rendering is done to the back buffer, which doesn't appear to work out so well on a 4K monitor in fullscreen... Also, the alpha blending of the application surface with the back buffer probably takes place 3840x2160 times.
In a second attempt, to solve the above issues, I switched to rendering to a view surface of 1920x1080 that is then scaled up to fit the actual window size. This seems to work fine, but it requires disabling the application surface completely, since there's no use using it when I have a custom surface to render to.
I'm wondering if there are better ways to achieve the effect I'm after that don't require the use of a custom view surface or ways that are more efficient.
Has anyone done something similar or have experience with this?