Default Backgrounds
Posted: Fri Apr 30, 2010 1:41 pm
Will backgrounds that do not exactly match window dimensions continue to leave ghosts, or will the new code actually clean up after itself?
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
As amusing as the thought is, wouldn't it be a more-useful thing to do to fill with black unless specifically instructed not to? Have a "config.backdrop" setting or something which defaults to "Solid('#000')"?PyTom wrote:The behavior of an unfilled screen is undefined. Ren'Py is free to do anything in that case, including making demons fly out of your nose.
Have you measured this? Because it's not when using software rendering.Wintermoon wrote:even conservatively filling the screen with black is fairly cheap.
Only in hardware rendering this applies. In software rendering this implies drawing every pixel on the screen at least twice in normal cases.PyTom wrote:Have you measured this? Because it's not when using software rendering.Wintermoon wrote:even conservatively filling the screen with black is fairly cheap.
Yes. Relevant code:PyTom wrote:Have you measured this? Because it's not when using software rendering.
Code: Select all
SDL_SetVideoMode(800, 600, 32, 0);
Uint32 time = SDL_GetTicks();
for (int i = 0; i < 1000; ++i) {
SDL_FillRect(SDL_GetVideoSurface(), 0, 0);
}
printf("1000 fills in %d ms.", SDL_GetTicks() - time);
That's slightly less than 3 milliseconds per frame on my old, outdated computer. If you're aiming at 60 fps, you have almost 17 millisecond per frame. Filling the screen with black apparently uses around 17 percent of that, which is not insignificant, but not necessarily big deal either. If the frame rate drops below 60 fps, the percentage of time spent blanking the screen will likewise drop.1000 fills in 2873 ms.
To be perfectly frank, anybody whose computer takes so long to blank the screen that it's noticeable to the user that Ren'Py's taking longer to draw frames than usual, their computer will also take so long to draw anything else that Ren'Py games are very unlikely to run smoothly in the first place, and the introduction of ATL and subsequent encouragement to use more animation and transformation stuff in Ren'Py games will likely be much more of a problem to them. But that didn't stop PyTom implementing ATL!Counter Arts wrote:Keep in mind with the new ATL language more people will have moving, rotating, zoomed images in software rendering. I think having it undefined for performance reasons would be a good idea if you want new users to start adopting ATL.
This is the wrong way to think about it. The percentage of time it takes to clear the screen is unimportant, as that that number is just scorekeeping. I could make the percentage of time spent clearing the screen drop to 0 by simply sleeping each frame - but that would drop the framerate to nothing, and would be totally unacceptable.Wintermoon wrote:The more stuff is happening on the screen and the more computationally expensive it is, the smaller the percentage of time used for clearing the screen.
The question isn't how long it takes to render a blank screen, but how much longer it takes to update the screen if you blank it before rendering than if you don't. This is, on my computer, at 800x600x32 resolution, 3 milliseconds.PyTom wrote:Wintermoon, a couple of points:
The first is that it's not enough to measure the time spent filling. You also need to measure the time spent filling and flipping the screen. The flip takes a substantial amount of time (since sending data from system to video memory is _slow_), and it eats substantially into the amount of time you have to actually render the frame.
Percentage of time used tells you where you need to optimize. If including screen blanking causes you to miss your target framerate but most of your execution time is spent elsewhere, then you should first optimize those other bits before dropping the screen blanking.PyTom wrote:This is the wrong way to think about it. The percentage of time it takes to clear the screen is unimportant, as that that number is just scorekeeping. I could make the percentage of time spent clearing the screen drop to 0 by simply sleeping each frame - but that would drop the framerate to nothing, and would be totally unacceptable.Wintermoon wrote:The more stuff is happening on the screen and the more computationally expensive it is, the smaller the percentage of time used for clearing the screen.
Without meaning to be facetious, weren't you going to do this flip anyway, regardless of whether you filled the screen before drawing everything else or not?PyTom wrote: The first is that it's not enough to measure the time spent filling. You also need to measure the time spent filling and flipping the screen. The flip takes a substantial amount of time (since sending data from system to video memory is _slow_), and it eats substantially into the amount of time you have to actually render the frame.
This is a fine attitude when you're writing code for programmers to use, but it's not a good attitude when you're writing code for normal people. Ren'Py is supposed to be "easy" to script and to "[make] it possible for non-programmers to make visual novels", so it behooves the engine to do things to pander to those people without having to explain to them the complexities of buffered graphics programming.PyTom wrote: There's also the fact that when a game doesn't fill the screen with an image, that's a problem with the game. The user isn't specifying what parts of the screen should look like - so why should Ren'Py specify it for them? It seems kinda silly to jeopardize the performance of correct code to make incorrect code function differently.
...
I'm not sure what the behavior should be. Should we fill with black? Or should we fill with Horrible Purple Color, so it's obvious there's a problem? Or something like the pattern used for images with alpha in image editors?
The nice thing about this suggestion is that it actually increases performance over the status quo. Currently, in order to get the same effect, you would need two layers: one for the background image and one for the black behind the background image. Requiring the user to explicitly specify both layers does not solve the performance problem of rendering a lot of pixels twice. Auto-letterboxing avoids the overdraw completely.Jake wrote: - draw graphics for 'scene' without alpha (less expensive!) and fill in any letterboxing space with black yourself (no more expensive than a full-screen image).