콘텐츠로 건너뛰기

Detail-Map Expression texture norm Document

Detail Texture Norms

The R channel is a mask channel that specifies where to apply the detail map effect. It becomes the area where white is used.
For the Alpha channel, if you use Texture Array, record the index ID.
R 通道是一个遮罩通道,用于指定在何处应用细节贴图效果。 它成为使用白色的区域。
对于Alpha通道,如果使用Texture Array,记录下索引ID.

Mask

Texture Array function was not appied yet.

Use the Base Color alpha channel of the detailed Map.
This alpha channel is used as a mask to control which parts of the DetailMap will not be composited with the original Map.
Tiling is applied.
使用详细贴图的 Base Color alpha 通道。
此 Alpha 通道用作遮罩以控制细节贴图的哪些部分不会与原始贴图合成。
应用平铺。

Base Color

Things to discuss. @Kristian @November 9, 2021 It is necessary to discuss the DetailMap Mask processing method. The DetailMap Mask has two functions. A. Original Mask function. B. The Texture Array Index is being saved.
1. Are we going to use the Mask texture by adding a Texture Sampler?
2. Will the mask information be saved in the Alpha channel of Vertex Color?
– Based on the above selection method, DCC must determine the topology production norm.

Detail map GUI example.

If Texture is empty in Mask, use Vertex Color Mask automatically. 如果蒙版纹理为空,则自动使用顶点颜色蒙版。

Detailmap custom Code

ApplyDetailAlbedoDiscardByAlpha()

half3 ApplyDetailAlbedoDiscardByAlpha(float2 detailUv, half3 albedo, half4 detailAlbedoMap, half detailMask) { #if defined(_DETAIL) half3 detailAlbedo = detailAlbedoMap.rgb; half discardMask = detailAlbedoMap.a; // In order to have same performance as builtin, we do scaling only if scale is not 1.0 (Scaled version has 6 additional instructions) #if defined(_DETAIL_SCALED) detailAlbedo = ScaleDetailAlbedo(detailAlbedo, _DetailAlbedoMapScale); #else detailAlbedo = 2.0h * detailAlbedo; #endif return albedo * LerpWhiteTo(detailAlbedo, (discardMask * detailMask)); #else return albedo; #endif }
Code language: PHP (php)

ApplyDetailPackedMap()

half4 ApplyDetailPackedMap(float2 detailUv, half4 oldOutSurfaceData , half4 detailAlbedoMap, half detailMask) { # if defined(_DETAIL) half3 detailAlbedo = detailAlbedoMap.rgb; half discardMask = detailAlbedoMap.a; half4 detailPacked = SAMPLE_TEXTURE2D(_DetailPackedMap, sampler_DetailPackedMap, detailUv).rgba; half4 combinedDetailResult; return combinedDetailResult = lerp(oldOutSurfaceData,detailPacked, discardMask * detailMask); #else return oldOutSurfaceData; #endif } //This added function for need to replaced to original surface characteristic such as metalness, smoothness, ambient occlusion.
Code language: PHP (php)

ApplyDetailNormalDiscardDetailMask()

half3 ApplyDetailNormalDiscardDetailMask(float2 detailUv, half3 normalTS, half4 detailAlbedoMap, half detailMask) { #if defined(_DETAIL) half3 detailAlbedo = detailAlbedoMap.rgb; half discardMask = detailAlbedoMap.a; #if BUMP_SCALE_NOT_SUPPORTED half3 detailNormalTS = UnpackNormal(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv)); #else half3 detailNormalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv), _DetailNormalMapScale ); #endif // With UNITY_NO_DXT5nm unpacked vector is not normalized for BlendNormalRNM // For visual consistancy we going to do in all cases detailNormalTS = normalize(detailNormalTS); return lerp(normalTS, BlendNormalRNM(normalTS, detailNormalTS), detailMask * discardMask); // todo: detailMask should lerp the angle of the quaternion rotation, not the normals #else return normalTS; #endif }
Code language: PHP (php)

Composition with detail map that We called detail-packed map.

Since occlusion should preserve the mesh’s baked AO, we multiply this value again. 由于遮挡应该保留网格的烘焙 AO,我们再次乘以该值。

InitializeUberLitSurfaceData()

inline void InitializeUberLitSurfaceData(float2 uv, out UberSurfaceData outSurfaceData) { outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff); half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; outSurfaceData.metallic = specGloss.r; outSurfaceData.smoothness = specGloss.a; outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); outSurfaceData.occlusion = SampleOcclusionPacked(uv); outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); outSurfaceData.clearCoatMask = 0.0h; outSurfaceData.clearCoatSmoothness = 0.0h; #if defined(_DETAIL) half4 detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).rgba; float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; half4 detailAlbedoMap = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgba; outSurfaceData.albedo = ApplyDetailAlbedoDiscardByAlpha(detailUv, outSurfaceData.albedo,detailAlbedoMap, detailMask.r); outSurfaceData.normalTS = ApplyDetailNormalDiscardDetailMask(detailUv, outSurfaceData.normalTS,detailAlbedoMap, detailMask.r); outSurfaceData.metallic = ApplyDetailPackedMap(detailUv, outSurfaceData.metallic, detailAlbedoMap, detailMask.r).r; outSurfaceData.smoothness = ApplyDetailPackedMap(detailUv, outSurfaceData.smoothness, detailAlbedoMap, detailMask.r).a; outSurfaceData.occlusion *= ApplyDetailPackedMap(detailUv, outSurfaceData.occlusion, detailAlbedoMap, detailMask.r).g; #endif } //```glsl inline void InitializeUberLitSurfaceData(float2 uv, out UberSurfaceData outSurfaceData) { outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff); half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; outSurfaceData.metallic = specGloss.r; outSurfaceData.smoothness = specGloss.a; outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); outSurfaceData.occlusion = SampleOcclusionPacked(uv); outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); outSurfaceData.clearCoatMask = 0.0h; outSurfaceData.clearCoatSmoothness = 0.0h; #if defined(_DETAIL) half4 detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).rgba; float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; half4 detailAlbedoMap = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgba; outSurfaceData.albedo = ApplyDetailAlbedoDiscardByAlpha(detailUv, outSurfaceData.albedo,detailAlbedoMap, detailMask.r); outSurfaceData.normalTS = ApplyDetailNormalDiscardDetailMask(detailUv, outSurfaceData.normalTS,detailAlbedoMap, detailMask.r); outSurfaceData.metallic = ApplyDetailPackedMap(detailUv, outSurfaceData.metallic, detailAlbedoMap, detailMask.r).r; outSurfaceData.smoothness = ApplyDetailPackedMap(detailUv, outSurfaceData.smoothness, detailAlbedoMap, detailMask.r).a; outSurfaceData.occlusion *= ApplyDetailPackedMap(detailUv, outSurfaceData.occlusion, detailAlbedoMap, detailMask.r).g; #endif } //```glsl inline void InitializeUberLitSurfaceData(float2 uv, out UberSurfaceData outSurfaceData) { outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff); half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; outSurfaceData.metallic = specGloss.r; outSurfaceData.smoothness = specGloss.a; outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); outSurfaceData.occlusion = SampleOcclusionPacked(uv); outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); outSurfaceData.clearCoatMask = 0.0h; outSurfaceData.clearCoatSmoothness = 0.0h; #if defined(_DETAIL) half4 detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).rgba; float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; half4 detailAlbedoMap = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgba; outSurfaceData.albedo = ApplyDetailAlbedoDiscardByAlpha(detailUv, outSurfaceData.albedo,detailAlbedoMap, detailMask.r); outSurfaceData.normalTS = ApplyDetailNormalDiscardDetailMask(detailUv, outSurfaceData.normalTS,detailAlbedoMap, detailMask.r); outSurfaceData.metallic = ApplyDetailPackedMap(detailUv, outSurfaceData.metallic, detailAlbedoMap, detailMask.r).r; outSurfaceData.smoothness = ApplyDetailPackedMap(detailUv, outSurfaceData.smoothness, detailAlbedoMap, detailMask.r).a; outSurfaceData.occlusion *= ApplyDetailPackedMap(detailUv, outSurfaceData.occlusion, detailAlbedoMap, detailMask.r).g; #endif } ```glsl inline void InitializeUberLitSurfaceData(float2 uv, out UberSurfaceData outSurfaceData) { outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff); half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; outSurfaceData.metallic = specGloss.r; outSurfaceData.smoothness = specGloss.a; outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); outSurfaceData.occlusion = SampleOcclusionPacked(uv); outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); outSurfaceData.clearCoatMask = 0.0h; outSurfaceData.clearCoatSmoothness = 0.0h; #if defined(_DETAIL) half4 detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).rgba; float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; half4 detailAlbedoMap = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgba; outSurfaceData.albedo = ApplyDetailAlbedoDiscardByAlpha(detailUv, outSurfaceData.albedo,detailAlbedoMap, detailMask.r); outSurfaceData.normalTS = ApplyDetailNormalDiscardDetailMask(detailUv, outSurfaceData.normalTS,detailAlbedoMap, detailMask.r); outSurfaceData.metallic = ApplyDetailPackedMap(detailUv, outSurfaceData.metallic, detailAlbedoMap, detailMask.r).r; outSurfaceData.smoothness = ApplyDetailPackedMap(detailUv, outSurfaceData.smoothness, detailAlbedoMap, detailMask.r).a; outSurfaceData.occlusion *= ApplyDetailPackedMap(detailUv, outSurfaceData.occlusion, detailAlbedoMap, detailMask.r).g; #endif } //Since occlusion should keep the baked AO of the mesh, we multiply the value once more.
Code language: PHP (php)

태그:

댓글 남기기

%d 블로거가 이것을 좋아합니다: