Skip to content

Normal map averaging #53

Description

@dtzxporter

Would you be interested a feature to calculate the blue channel of a normal map (Given R/G (X/Y))? It was included in the old NVidia tools and would make a great addition to the library, I'd be willing to write the code for this if you'd be willing to merge! Some flag like -navg or something...

Activity

  1. walbourn commented on Jun 4, 2017

    @walbourn
    Collaborator

    Can you explain the use-case for the feature a bit? The old D3DX function had a number of features which are in the DirectXTex version by combining CNMAP_CHANNEL_* flags. The code is already set up to use the first 0xf mask of the CNMAP_FLAGS to select the height-computation mode, so it should b easy enough to add another case.

  2. dtzxporter commented on Jun 5, 2017

    @dtzxporter
    Author

    Basically if someone had a previously lets say BC5 encoded image and wanted to decode and use it in Blender per say, it's easier on the user to plugin a normal map with a precalculated blue channel instead of adding the calculation into the material itself. So it would be useful when transcoding between various 2 channel compressions. It would also be useful to get this working on the GPU as well for the added performance.

  3. walbourn commented on Jan 29, 2019

    @walbourn
    Collaborator

    So basically you want a way to take a BC5_UNORM texture and have it generate a RGB texture where the 'missing' 3rd channel is reconstructed.

    In a shader, this is done with:

    float z = sqrt(1 - dot(xy, xy));
    

    That's probably an easy addition to the texconv tool with a special flag. -navg is probably not the right switch since it's not really an average. Maybe -reconstructz?

    For BC5_UNORM it would need to do an x2 debias and reconstruct. If the output is _UNORM, it would need to bias x2. This is already covered by TEX_FILTER_FLOAT_X2BIAS.

  4. dtzxporter commented on Jan 29, 2019

    @dtzxporter
    Author

    Yes that was the idea.

  5. walbourn commented on Sep 29, 2019

    @walbourn
    Collaborator

    Another way to achieve this would be to add special logic to Decompress so that if the target format has a blue channel it reconstructs it. Of course, that's probably the same as just having it always do that and the B channel would be saved or not depending on the output format.

  6. walbourn commented on Jul 14, 2020

    @walbourn
    Collaborator

    Fixed in this commit. Keep in mind you still need to ensure the output has a blue channel (such as with -f R8G8B8A8_UNORM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolsApplies to texconv, texdiag, texassemble, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions