DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
306 stars 60 forks source link

talk: liquid shader syntax design #261

Open illwieckz opened 4 years ago

illwieckz commented 4 years ago

This is the historic XreaL liquid shader design:

textures/test-water_custom/water
{
    qer_editorImage textures/test-water_custom_src/water_d
    qer_trans .6

    surfaceparm nobuild
    surfaceparm trans
    surfaceparm water
    surfaceparm nonsolid

    {
        stage liquidMap
        map textures/test-water_custom_src/water_n

        scroll time * .1, time * .1
        scale .5, .5
        refractionIndex 1.3
        fresnelPower 2
        fresnelScale .85
        fresnelBias  .05
    }
}

There is problems with that design: there is no fallback if liquidMapping is disabled, and we can't feed diffusemap to tint with colors, and we can't feed material map that may tweak reflectance.

My proposition is that:

textures/test-water_custom/water
{
    qer_editorImage textures/test-water_custom_src/water_d
    qer_trans .6

    surfaceparm nobuild
    surfaceparm trans
    surfaceparm water
    surfaceparm nonsolid

    {
        <keyword> liquidMap
        diffuseMap textures/test-water_custom_src/water_d
        normalHeightMap textures/test-water_custom_src/water_nh
        physicalMap textures/test-water_custom_src/water_orm

        scroll time * .1, time * .1
        scale .5, .5
        refractionIndex 1.3
        fresnelPower 2
        fresnelScale .85
        fresnelBias  .05
    }
}

If liquidMapping is disabled, the code would fallback to lightmapping shader instead (which does not look bad when using normal maps etc.). It would be better to merge liquid shader with lightmapping shader to achieves this.

VReaperV commented 2 months ago

The current liquid and lightMapping shaders are different enough that it makes sense to keep them separate. Other than that this is reasonable.

VReaperV commented 1 week ago

I don't get what the change from stage liquidMap to <keyword> liquidMap is supposed to accomplish though, or what <keyword> even is.