Drawing order in the renderer

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Drawing order in the renderer

Post by Parallax »

I am trying to do some fancy stuff with wallsets and I'd like to know exactly what the renderer draws and in what order. To be more specific, here is a series of questions, in which we will assume that the party stands at (lev, 0, 0), facing East:

1) Are the default (for level lev) floor and ceiling always drawn? If so, are they always drawn first?

2) Are the visible tiles drawn as tiles, or based on the surfaces? For instance, if (lev, 2, 1) is a wall, are the 'pers' view and the 'side' view drawn one after another, or is the pers view drawn with the other pers view at that distance and the side view drawn later, along with the other side view and the front view that are at the same distance from the party?

3) If (lev, 2, 1) and (lev, 2, 0) are both walls, is the pers view of (lev, 2, 1) drawn, even though it won't normally be visible?

4) When are wallitems and flooritems drawn? Are they drawn even if they won't be seen? What about flooritems on tiles that currently walls? (wallitems on tiles that are currently open are obviously not drawn.)

5) Custom wallsets. Does the presence of custom wallsets on certain tiles affect the answers to question 1)?

6) Priority: If two flooritems are on the center of the same tile, which one gets drawn first? In particular, for doors, does the order of doorframe, door, doorbutton matter? Does the answer hold for two wallitems on the same subtile as well? What about flooritems on different subtiles of the same tile (like monsters leaving unmoveable corpses), is the drawing order dependent on the perspective as it is for regular items?

I realize that I could test for some of this myself, but I would not be certain that the results I get are general, and not due to the particulars of the situation. Testing for every orientation, in particular, would be very tedious.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Drawing order in the renderer

Post by Sophia »

Parallax wrote:Are the default (for level lev) floor and ceiling always drawn? If so, are they always drawn first?
Not always drawn. They're only drawn if an override floor and/or ceiling are not set. In those cases, the override floor and/or ceiling are drawn. Otherwise, the level default floor and ceiling are drawn. In both cases, this is what is drawn first.
Parallax wrote:Are the visible tiles drawn as tiles, or based on the surfaces?
They're drawn as tiles: first pers, then side; first left, then right, finally, the center wall is drawn.
Parallax wrote:is the pers view of (lev, 2, 1) drawn, even though it won't normally be visible?
Yes. Due to the presence of masks and alpha transparency, DSB doesn't bother with any culling right now. If this becomes a speed issue somehow it could be made an option.
Parallax wrote:When are wallitems and flooritems drawn? Are they drawn even if they won't be seen? What about flooritems on tiles that currently walls? (wallitems on tiles that are currently open are obviously not drawn.)
Wallitems and flooritems are drawn at the end of the draw code for their particular tile. Floorflats are drawn first, then flooruprights. Flooritems on tiles that are currently walls are not drawn, but clouds are, just like DM.
Parallax wrote:Custom wallsets. Does the presence of custom wallsets on certain tiles affect the answers to question 1)
Not really. If the tile has a custom floor or ceiling, that is drawn immediately after the level's base floor and ceiling are drawn.
Parallax wrote:If two flooritems are on the center of the same tile, which one gets drawn first?
In general, they're drawn in the order they are in the tile, which is to say, the last item added to the tile will be on the "top" and thus drawn first.
Parallax wrote:In particular, for doors, does the order of doorframe, door, doorbutton matter?
No, there's a special hack in the renderer to keep this from being a headache. Doors and doorbuttons are automatically deferred to be drawn after doorframes, regardless of the tile order.
Parallax wrote:Does the answer hold for two wallitems on the same subtile as well?
Yes.
Parallax wrote:What about flooritems on different subtiles of the same tile (like monsters leaving unmoveable corpses), is the drawing order dependent on the perspective as it is for regular items?
Flooritems that aren't in the center of the tile aren't drawn at all. If you need this, we can figure something out... :)
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Re: Drawing order in the renderer

Post by Parallax »

Thanks for the prompt answers!

If I understand correctly, the drawing proceeds as:
- Floor/ceiling on every tile, regardless of whether it is open or a wall. For each tile, only the actual wallset used on the tile is drawn, the default wallset is not used as an "undercoat" everywhere.
- From back to front, left before right before center, every tile is drawn. Wall tiles get the walls (if applicable), pers view (with its wallitems) before front view (with its wallitems), while open tiles get flooritems (flat, then upright) followed by the instances in subtiles.

This seems like it should avoid the most obvious glitches (all the ones I can think of right now.)
Parallax wrote:is the pers view of (lev, 2, 1) drawn, even though it won't normally be visible?
Sophia wrote:Yes. Due to the presence of masks and alpha transparency, DSB doesn't bother with any culling right now. If this becomes a speed issue somehow it could be made an option.
I was thinking that, with transparency, this might become an issue. If there are transluscent walls, or a "panoramic" window spell, it might be desirable to not display surfaces that are in the bulk of the wall, as they would interfere with the view.
Parallax wrote:If two flooritems are on the center of the same tile, which one gets drawn first?
Sophia wrote:In general, they're drawn in the order they are in the tile, which is to say, the last item added to the tile will be on the "top" and thus drawn first.
Wouldn't it be the 'bottom' item, then, since drawing the second item on top of it may partially or totally mask it?
Parallax wrote:What about flooritems on different subtiles of the same tile (like monsters leaving unmoveable corpses), is the drawing order dependent on the perspective as it is for regular items?
Sophia wrote:Flooritems that aren't in the center of the tile aren't drawn at all. If you need this, we can figure something out... :)
I don't need it yet, and possibly never. instances can probably be made unpickable through other means. Don't bother with it unless you are bored out of your mind ;).
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Drawing order in the renderer

Post by Sophia »

Parallax wrote:I was thinking that, with transparency, this might become an issue. If there are transluscent walls, or a "panoramic" window spell, it might be desirable to not display surfaces that are in the bulk of the wall, as they would interfere with the view.
I don't really understand... :(
Parallax wrote:Wouldn't it be the 'bottom' item, then, since drawing the second item on top of it may partially or totally mask it?
Er, yes. :oops: My thinking was momentarily backwards. The top item is drawn last.
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

OK, let's put our party back at (0, 0), facing East. Now, assume that (1,0) (directly in front of the party) is a wall, and that (1,1), the tile to the right of the first wall, is a wall as well.

The difference with standard DM is that these walls are not solid rock. The party is stranded on the plane of purple jell-O, and that's what all the walls are made of here. From a technical standpoint, all wall views are semi-transparent bitmaps (say, with an opacity of about 80 out of 256 or so.) Even though the wall in front of the party shows no sign of discontinuity as it goes to the right, there is now a "special plane" though it along which it is "cracked." That's the plane that marks the limit between the two wall tiles. In order to get the feeling that the wall is continuous, the pers1 view of (1,1) should not be drawn.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

True. Though, standard DM has this rendering anomaly as well. It's not evident in walls, but it is with blue hazes. ;)
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Parallax wrote:OK, let's put our party back at (0, 0), facing East. Now, assume that (1,0) (directly in front of the party) is a wall, and that (1,1), the tile to the right of the first wall, is a wall as well.

The difference with standard DM is that these walls are not solid rock. The party is stranded on the plane of purple jell-O...etc
I'm trying to follow this but it makes no sense. So a picture is required, W = wall, x = party.

Code: Select all

xW
 W
Is this what you're describing? If so, I don't understand what you're going on about. Jell-O? Cracked planes? WTF?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Ok, Gambit. Assume that "x" is the party, facing east. 1 and 2 are walls.

Code: Select all

x1
 2
If the wallset is solid, everything looks just fine.

However, if the wallset has some transparency (or if these are blue hazes), the "perspective" view of wall 2 will be drawn underneath wall 1. It'll look like there's a crack in the plane, or something, because you'll see this perspective view of the wall going off into the distance (like you would if wall 1 didn't exist), because currently all views are drawn even if they'll be overlapped.
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Ah, I somehow managed to gloss over the whole bit about transparency! I think it was the purple Jell-O that threw me! :)
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

I understand that it's already a problem in original DM, and it even gets worse when you look at what happens on the next plane (if the space beyond the first wall is open, there is a wall-air interface there and a wall should be displayed (but it's not) but if there is a wall then the medium is continuous and no wall should be diplayed (but one is).* Additionally, (in the case where (2,0) is a wall) the opacity of the front0 view should increase since there is a "double wall". So yea, maybe the world is not ready for transparent walls.

Of course, when you add the window spell into the mix things get even more complicated, since the second wall's (2,0) front view should be diplayed inside the window (I mean the round, central area of the 'window' spell,) otherwise it appears as if the window had gone through both the (1,0) and (2,0) walls. What a pain.

*: Trying with a picture, for Gambit.
First, a single wall ('#' for surface, '.' for interior) in front of the party (tile limits marked with '+', '-' and '|', party members (facing East (i.e. right)) marked with '>')

Code: Select all

+----+######
|>  >|#....#
|    |#....#
|    |#....#
|>  >|#....#
+----+######
And now the same party, in front of a wall with a two tile depth.

Code: Select all

+----+############
|>  >|#..........#
|    |#..........#
|    |#..........#
|>  >|#..........#
+----+############
The interface between the two walls is technically gone, even though the renderer would still display it.
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Yeah, I see what you mean now. I never really thought of it as an issue before.

When playing the original game and using the window spell in your diagram above, the fact I could see the image of the second wall never bothered me -- I just assumed the dungeon was built out of Lego! ;)
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

Tom Hatfield
Ee Master
Posts: 688
Joined: Mon May 07, 2001 7:00 pm
Location: Indiana, USA
Contact:

Post by Tom Hatfield »

I'm still contemplating that. ;)

Truth be told, I have been working lately, and not just as a technician for the schools. Actually, I've been programming a 3-D modeling studio for LDraw, because none of those currently available have the features/user-friendliness I desire. But, it's a 3-D project, and while I'm quite familiar with the semantics and technical hoodoo behind 3-D graphics, I've done very little 3-D programming, so it's a chore.

Anyway, my point is, I want to take a break and step back into 2-D for a while. I'd been tossing between Lego-DM and another 2-D engine I want to actualize. Every time I come here to read up on the goings-on in the community, I lean quite a bit more toward the DM side. Wonder why. Anyway, Let me fiddled around in MLCad and Max a bit more and I'm sure I'll persuade myself to start work on it right away.

Thanks for the heads-up. Oh, and if it makes you feel any better Parallax, I knew what you were talking about from the start.

</offtopic>
Post Reply