Search Unity

Tangent construction in shader

Discussion in 'Shaders' started by snacktime, Mar 3, 2021.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I'm working with HDRP although using Better Shaders so not limited to shader graph here.

    It's a water shader using data from Nvida Waveworks 2. I get world normals from texture samples. And vertices are displaced via the following formula:

    object space + geomorph(minor) * scale + offset + wave displacment. And that data is all from waveworks.

    In their own sample shaders they just use the world normal directly to calculate reflection, lights, fresnel, etc..

    I have a rendering setup that just uses static meshes with a different geomorph and no scale/offset, otherwise the same shader. And normals there look right.

    The version that scales and offsets, the normals are obviously wrong. I'm thinking I have enough data here to construct what I need but not sure on the specifics of what to do exactly.