Repository navigation
Normal map averaging #53
Description
Activity
Can you explain the use-case for the feature a bit? The old
D3DXfunction had a number of features which are in the DirectXTex version by combiningCNMAP_CHANNEL_*flags. The code is already set up to use the first0xfmask of theCNMAP_FLAGSto select the height-computation mode, so it should b easy enough to add another case.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.
So basically you want a way to take a
BC5_UNORMtexture 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
texconvtool with a special flag.-navgis probably not the right switch since it's not really an average. Maybe-reconstructz?For
BC5_UNORMit would need to do an x2 debias and reconstruct. If the output is_UNORM, it would need to bias x2. This is already covered byTEX_FILTER_FLOAT_X2BIAS.- addedtoolsApplies to texconv, texdiag, texassemble, etc.Applies to texconv, texdiag, texassemble, etc.and removed
on Jan 29, 2019 Yes that was the idea.
Another way to achieve this would be to add special logic to
Decompressso 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.Fixed in this commit. Keep in mind you still need to ensure the output has a blue channel (such as with
-f R8G8B8A8_UNORM.
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...