Garux / netradiant-custom

The open-source, cross-platform level editor for id Tech based games.
https://garux.github.io/NRC/
Other
316 stars 56 forks source link

Autocaulk unexpectedly applies nodraw on solid brushes #145

Closed Aciz closed 1 year ago

Aciz commented 1 year ago

image Shader for top brush (bottom brush is a plain texture)

textures/snow_sd/icelake2
{
    qer_trans 0.80
    qer_editorimage textures/snow_sd/icelake2.tga
    sort seethrough
    surfaceparm slick
    surfaceparm trans
    tesssize 256

    {
        map textures/effects/envmap_ice2.tga
        tcgen environment
        blendfunc blend
    }
    {
        map textures/snow_sd/icelake2.tga
        blendfunc blend
    }
    {
        map $lightmap
        blendfunc filter
        rgbGen identity
        depthWrite
    }
    {
        map textures/detail_sd/snowdetail_heavy.tga
        blendFunc GL_DST_COLOR GL_SRC_COLOR
        rgbgen identity
        tcMod scale 4 4
        detail
    }
}

Selecting these two brushes will use common/nowdraw for the bottom part of the ice, making it unexpectedly nonsolid. Haven't looked at the selection logic for which shader to use when autocaulking, but this seems like some sort of logic error?

Garux commented 1 year ago

It applies common/nodraw to nodraw-transparent and common/nodrawnonsolid to nodraw-transparent-nonsolid, so former is expected to be solid.

Aciz commented 1 year ago

They aren't though, both Q3 and W:ET in my case have surfaceparm nonsolid in common/nodraw

Garux commented 1 year ago

This is known confusion, OG Q3 shader has both nodraw and nodrawnonsolid... nonsolid :p This used to be fixed in tweaked shaders coming with radiants, i include such shader too.

Aciz commented 1 year ago

Wouldn't it be better to just not apply nodraw to anything that already isn't nonsolid? Applying caulk or even weapclip in such cases would produce same result without the unexpected change to nonsolid, and not require users to modify stock shaders, especially considering dev builds don't even ship gamepacks.

Garux commented 1 year ago

Okay, it would work in more cases, but it would be semantically wrong. Caulk is for opaque solid, nodraw for trans solid, nodrawnonsolid for trans nonsolid, weapclip for weapclip. This serves better map visual structure and filtering by texture. Dev builds ship gamepacks, they do not include shaders/textures. Working on this atm.

Aciz commented 1 year ago

I really don't agree that the solution to this is to modify stock common/nodraw though, any old map you might have that is built with the stock shaders (as you might reasonably expect) is going to behave differently if you suddenly start changing nodraw to not be nonsolid. There are many other shaders to choose from that you can use in place of nodraw to achieve the same effect it would have if it was solid.

This serves better map visual structure and filtering by texture.

Having caulk at the bottom of the ice in my example will still filter it fine when enabling translucent filter though.

The-Gig commented 1 year ago

Just on a side note, iirc years ago I did some tests trying to figure out the the difference between nodraw and nodrawnonsolid in q3, and for some reason the test brush which had nodrawnonsolid on some faces kept casting a shadow also when set as "detail", while the one with nodraw did not.... (So, for some strange reason "nodrawnonsolid" felt a bit more "solid" than the other one. Maybe due to the order of the surfaceparms? In some cases it makes a difference). But many years passes since those tests, it's totally possible I'm recalling it completely wrong!

Garux commented 1 year ago

Idk where i've got that solid nodraw, but it felt like some solid source, like ydnar or obsidian. Now i can't literally find a single solid nodraw shader source. Needless to say, that og shaders naming is uber clunky, it should have been something around nonsolid-trans & nonsolid-opaque to respect functionality. For latter can only imagine very exotic uses though; in Q3 maps they are used mindlessly as equals, even both on the same brush.

Since a lot of stuff has been designed with solid nodraw in mind, now workaround is to check solidity in autocaulk code and fall back to caulk, if nonsolid.

Garux commented 1 year ago

@The-Gig i recall same observation. Trying it now and can't tell surely how does it work xD

The-Gig commented 1 year ago

Mine was a test from 10 years ago, http://openarena.ws/board/index.php?topic=4679.msg47000#msg47000. While the screenshots there are only visible to registered forum users and registration is broken since years, the text explains the differences I did notice...

Garux commented 1 year ago

Described observations are in range of expectance, vis data is used for light calculation, so invisible structural brushes cast shadows. Trans property of nodraw makes it detail, hence the difference.

As for nodrawnonsolid estimated application, it would work for turning visually normal opaque geometry to nonsolid (to simplify collision?). There are _trans (actually nonsolid) shaders in vQ3 signing in favor of this theory.

Garux commented 1 year ago

Can see there _trans mainly for patches. Fun fact, this is nonsolid: image