add offsets to decaldef

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

add offsets to decaldef

Post by Sir Robin »

I wish that decaldef lump had offsets for the image, like the textures lump does. I know I can set offsets in the png files, but I'd like to have to option to override those in the decaldef lump.

So I could do this

Code: Select all

decal MyDecal235 235
{
offset 32,64
pic Image235
}
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: add offsets to decaldef

Post by Logan MTM »

Just curious. What would be the practical application of this?
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: add offsets to decaldef

Post by Sir Robin »

It would be for the same purpose as the textures lump, to set offsets for the image to be used as a decal. This would override the png grAb lump if it has one. This means I can adjust the offsets of a decal without having to use an external program like setpng or grabpng or whatever. It also means I can use the same image for different decals with different offsets. For example, I need to have some decals drawn from the center and some drawn from the bottom middle. Since I can't set the offsets here, I have to have 2 different image files for either of those decals. That adds unneeded bulk to my pk3 file. Something I haven't yet tested is to create a texture with the proper offsets then see if decaldef can load a texture. If that works, it's a work-around, but it would be nice to do that without those extra steps.
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: add offsets to decaldef

Post by 22alpha22 »

This would indeed be a useful feature. In my own projects there have been times I needed to use the same decal with multiple projectiles and have had to define the decal image several times with TEXTURES in order set different offsets so that decal lined up properly with the projectile. This was mildly annoying and being able to define offset overrides in DECALDEF would have been a better option I think.
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: add offsets to decaldef

Post by RockstarRaccoon »

You know, if you're at it, there should be a possibility for randomization there.

Anyway, I'm about to rework the decal-placement code in the rendering stuff, so... I'll try to remember that this is a request and get back with notes.
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: add offsets to decaldef

Post by Sir Robin »

RockstarRaccoon wrote:You know, if you're at it, there should be a possibility for randomization there.

Anyway, I'm about to rework the decal-placement code in the rendering stuff, so... I'll try to remember that this is a request and get back with notes.
Awesome!

Question - and this should probably be another feature request but I'm asking if it's reasonably feasible and worth requesting - Would it be possible to make texture offsets as fixed point instead of integers? In another thread I was trying to use a sprite as a cross hair, and wanted to center it on a pixel center instead of a pixel border. Is that feasible or is that a completely backwards-ass way to do that?
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: add offsets to decaldef

Post by 22alpha22 »

Sir Robin wrote:Question - and this should probably be another feature request but I'm asking if it's reasonably feasible and worth requesting - Would it be possible to make texture offsets as fixed point instead of integers? In another thread I was trying to use a sprite as a cross hair, and wanted to center it on a pixel center instead of a pixel border. Is that feasible or is that a completely backwards-ass way to do that?
A workaround you could use and one that I have used in the past is to render your crosshair as an overlay on the weapon and set its offsets with A_OverlayOffset. https://zdoom.org/wiki/A_OverlayOffset
There are other more robust solutions as well but they would require ZScript and EventHandlers or a custom statusbar/HUD.
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: add offsets to decaldef

Post by Sir Robin »

22alpha22 wrote:
Sir Robin wrote:Question - and this should probably be another feature request but I'm asking if it's reasonably feasible and worth requesting - Would it be possible to make texture offsets as fixed point instead of integers? In another thread I was trying to use a sprite as a cross hair, and wanted to center it on a pixel center instead of a pixel border. Is that feasible or is that a completely backwards-ass way to do that?
A workaround you could use and one that I have used in the past is to render your crosshair as an overlay on the weapon and set its offsets with A_OverlayOffset. https://zdoom.org/wiki/A_OverlayOffset
There are other more robust solutions as well but they would require ZScript and EventHandlers or a custom statusbar/HUD.
Yeah, there's a few different ways to handle it on a 2d plane. I'm actually using it as a 3d cursor though, as in I spawn it as a sprite out in the 3d world to mark exactly what I'm targeting. So think of it like a laser pointer. But I cannot spawn a sprite where it's origin is in the middle of a pixel, it's always going to be in the middle of a group of four pixels.

Example:
Spoiler:
The red X is my 3-d crosshair, the green dot is my 2d HUD crosshair. If they were perfectly aligned the green dot would be exactly in the middle of that red X, but that's not possible because that's only 1 pixel and I can't center it on one pixel. It's always going to be on one of the corners of that middle pixel. That's why I'd like to suggest that offsets could be floating point but I don't know how possible that is in the underlying code or what other things it would break. Alternatively I'd suggest adding a new flag, like +OffsetToMidPixel that would tell the rendered to automatically add 0.5 to the offsets when rendering.
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: add offsets to decaldef

Post by RockstarRaccoon »

Sir Robin wrote:Would it be possible to make texture offsets as fixed point instead of integers?
They already are. There's a ton of precise double math in here to make that work.

Try using the line-def edit in UDB to manually enter the alignment of a wall in a UDMF map. It'll work, though it's not as useful as one might think, at that scale.

EDIT:
Ok... I just checked that, and while the code IS in GZDoom to hold these things as floats (necessary for smooth animation and properly aligning scaled textures)...

Code: Select all

double xOffset;
double yOffset;
double xScale;
double yScale;
And the code is there to read it from UDMF...
Spoiler:
...when I enter a float in UDB, it accepts the float and will even save it as one, but it doesn't render in visual mode...

I guess we should add that to the list of things that need to be updated in UDB's renderer. We were talking about this the other day on UDB's Discord, and there is a rework of that code being planned, it's just on hold while there's all this updating being done to linedefs...
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: add offsets to decaldef

Post by Sir Robin »

I should have been more clear. Where I said offsets in textures, I meant offsets in the textures lump to define textures with patches. Not the offsets that a linedef has for it's tiered textures. Since I can also define sprites in that lump, I wanted to be able to set the offsets in a sprite to be mid-pixel (fractional) rather than pixel edge (integer), for example in the case of a crosshair sprite.

I hope that makes more sense.

Return to “Feature Suggestions [GZDoom]”