Doors not cropped at 'front3' view

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
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Doors not cropped at 'front3' view

Post by Gambit37 »

Doors have a few pixels cropped off the bottom at front1 and front2 views (to replicate DMs idea that they slot "into" the floor).

However, while DSB does the same for front1 and front2 door views, it doesn't crop those pixels for the front 3 view.

It's hard to spot with the default graphics, but once I started replacing door images, it was easy to see the bug.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Doors not cropped at 'front3' view

Post by Sophia »

It is definitely hard to spot with the default graphics.

Can you post a screenshot with your own graphics showing what you mean?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Doors not cropped at 'front3' view

Post by Gambit37 »

Here's my custom door, at the expected 2x size of 192 x 176. Notice that there are 4 pixels below the bottom gold trim:

Image

Here's screengrabs of a custom door in the default DM wallset, at 3 views. DSB has cropped the bottom pixels for view 1 and 2.

Image

Image

Image

Here's that third level door with it's brightness boosted:

Image

And here it is again, zoomed in. You can see the bottom pixels aren't cropped. (Also its vertical position is 1 pixel out, but that's a separate issue.)

Image

I think the view3 for doors is too big anyway. DSB renders these at exactly 50% of the front1 size, and while that makes for a lovely crisp image, it's not correct because the door is slightly larger than it should be and breaks out over the door pillar.

In FTLs original graphics, they pre-drew all door scalings, and adjusted the heights as necessary to look good, rather than using a scaling algorithm.

Image

Would it be possible therefore to allow doors to have pre-drawn images for all three views? Like you did for the wallitems? I could then fix any errors in the pre-drawn image myself. Or would that mess up the whole pixel-cropping thing that DSB does to simulate the door going into the floor?

(On an related note, I've also discovered that stair positions are quite broken with the default DSB graphics too, but as it's not that noticeable in the default graphics, probably not much point fixing it. I'll correct those stair positions for my custom wallset.)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Doors not cropped at 'front3' view

Post by Sophia »

Thanks for all this. I was just expecting one screenshot but this level of detail really helped a lot!

I think a big problem is that there are a lot of parameters that are hardcoded that look decent with the DM dungeon but were mostly numbers I came up with via trial and error, and they might not work for other dungeons. So the first step is to make them not hardcoded. In DSB 0.70 I'll add a door_draw_info table to render.lua that will give the dungeon designer control over such things. So far the numbers that would be easy to tweak are x and y offsets, the amount that is cut off the bottom when the door is shut, and scale factors. Something like:

Code: Select all

door_draw_info = {
	-- scale factor is N/240
	view0 = { x_off = 0, y_off = -6, bottom_cut = 4 },
	view1 = { x_off = 0, x_off_side = 64, y_off = -4, bottom_cut = 2, xscale = 160, yscale = 166 },
	view2 = { x_off = 0, x_off_side = 100, y_off = 2, bottom_cut = 2, xscale = 120, yscale = 120 }
}
What do you think of this, so far?

I'm busy this weekend but next week I'll have more time so I'll look into how well this code would interact with using pre-scaled images instead of using DSB's dynamic scaler.

Once we've sorted out doors, maybe we can talk about stairs... :mrgreen:
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Doors not cropped at 'front3' view

Post by Gambit37 »

Cool, your suggestion sounds great. Although I'd standardise the "viewX" to match the terminology used elsewhere, such as "near, med, far" etc.

I'm not completely clear what the xscale/yscale numbers mean, and how they relate to the numbers I posted above?

Anyway, yeah, I'm not expecting a reply until you're back, just wanted to get my next question lined up... ;-)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Doors not cropped at 'front3' view

Post by Sophia »

Ok, I'll use near/med/far instead of numbers.

The xscale/yscale numbers are used in the following formula: size = (actual_size * scale) / 240

For example, the far view's x and y scale values are 120, so 120/240 would mean it's half size. If you wanted a more DM style door you could reduce the value of yscale because that would kind of "squash" the door. A value of 115 might be more to your liking.

I use a scale factor instead of a pixel size because doors can vary in size.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Doors not cropped at 'front3' view

Post by Gambit37 »

OK, thanks, but where does the 240 value come from?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Doors not cropped at 'front3' view

Post by Sophia »

240 is a number I decided on semi-arbitrarily as being "full size."
Post Reply