|
|
|
|
|
|
return _DecalDatas[j]; |
|
|
|
} |
|
|
|
|
|
|
|
// Caution: We can't compute LOD inside a dynamic loop. The gradient are not accessible. |
|
|
|
// we need to find a way to calculate mips. For now just fetch first mip of the decals |
|
|
|
src.xyz = mul(decalToWorld, UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, ComputeTextureLOD(texCoords)))) * 0.5f + 0.5f; |
|
|
|
src.xyz = mul(decalToWorld, UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, 0 /* ComputeTextureLOD(texCoords) */))) * 0.5f + 0.5f; |
|
|
|
src.w = blend; |
|
|
|
dst.xyz = src.xyz * src.w + dst.xyz * (1.0f - src.w); |
|
|
|
dst.w = dst.w * (1.0f - src.w); |
|
|
|
|
|
|
void ApplyBlendDiffuse(inout float4 dst, inout int matMask, float2 texCoords, int sliceIndex, int mapMask, float blend) |
|
|
|
{ |
|
|
|
float4 src = SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, ComputeTextureLOD(texCoords)); |
|
|
|
float4 src = SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, 0 /* ComputeTextureLOD(texCoords) */); |
|
|
|
src.w *= blend; |
|
|
|
dst.xyz = src.xyz * src.w + dst.xyz * (1.0f - src.w); |
|
|
|
dst.w = dst.w * (1.0f - src.w); |
|
|
|
|
|
|
void ApplyBlendMask(inout float4 dst, inout int matMask, float2 texCoords, int sliceIndex, int mapMask, float blend) |
|
|
|
{ |
|
|
|
float4 src = SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, ComputeTextureLOD(texCoords)); |
|
|
|
float4 src = SAMPLE_TEXTURE2D_ARRAY_LOD(_DecalAtlas, sampler_DecalAtlas, texCoords, sliceIndex, 0 /* ComputeTextureLOD(texCoords) */); |
|
|
|
src.z = src.w; |
|
|
|
src.w = blend; |
|
|
|
dst.xyz = src.xyz * src.w + dst.xyz * (1.0f - src.w); |
|
|
|