add offsets to decaldef

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: add offsets to decaldef

Re: add offsets to decaldef

by Sir Robin » Sat Feb 05, 2022 7:26 pm

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.

Re: add offsets to decaldef

by RockstarRaccoon » Sat Feb 05, 2022 12:49 pm

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...

Re: add offsets to decaldef

by Sir Robin » Fri Feb 04, 2022 12:47 pm

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.

Re: add offsets to decaldef

by 22alpha22 » Fri Feb 04, 2022 12:06 pm

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.

Re: add offsets to decaldef

by Sir Robin » Thu Feb 03, 2022 9:30 pm

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?

Re: add offsets to decaldef

by RockstarRaccoon » Tue Feb 01, 2022 8:43 pm

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.

Re: add offsets to decaldef

by 22alpha22 » Tue Jan 11, 2022 8:36 am

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.

Re: add offsets to decaldef

by Sir Robin » Mon Jan 10, 2022 9:15 am

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.

Re: add offsets to decaldef

by Logan MTM » Sun Jan 09, 2022 11:06 pm

Just curious. What would be the practical application of this?

add offsets to decaldef

by Sir Robin » Sun Jan 09, 2022 11:01 pm

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
}

Top