浏览代码

Clean code. Remove now unused hack (as applyHeight formula have change)

/stochastic_alpha_test
Sebastien Lagarde 7 年前
当前提交
10a115ec
共有 1 个文件被更改,包括 6 次插入16 次删除
  1. 22
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

22
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


// Apply scaling from tiling properties (TexWorldScale and tiling from BaseColor)
ApplyDisplacementTileScale(height0, height1, height2, height3);
float4 blendMask = GetBlendMask(layerTexCoord, vertexColor, true, lod);
float4 blendMasks = GetBlendMask(layerTexCoord, vertexColor, true, lod);
float influenceMask = blendMask.a * GetInfluenceMask(layerTexCoord, true, lod);
float influenceMask = blendMasks.a * GetInfluenceMask(layerTexCoord, true, lod);
height1 += height0 * _InheritBaseHeight1 * influenceMask;
height2 += height0 * _InheritBaseHeight2 * influenceMask;
height3 += height0 * _InheritBaseHeight3 * influenceMask;

#if defined(_HEIGHT_BASED_BLEND)
// Modify blendMask to take into account the height of the layer. Higher height should be more visible.
blendMask = ApplyHeightBlend(float4(height0, height1, height2, height3), blendMask);
blendMasks = ApplyHeightBlend(float4(height0, height1, height2, height3), blendMasks);
ComputeMaskWeights(blendMask, weights);
ComputeMaskWeights(blendMasks, weights);
// Applying scaling of the object if requested
#ifdef _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE

outWeights[i] = 0.0f;
}
#if defined(_DENSITY_MODE)
// Note: blendMasks.argb because a is main layer
float4 opacityAsDensity = saturate((inputAlphaMask - (float4(1.0, 1.0, 1.0, 1.0) - blendMasks.argb)) * 20.0); // 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically)

#if defined(_HEIGHT_BASED_BLEND)
#if defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3)
// If no heightmap is set on any layer, we don't need to try and blend them based on height...
#if defined(_HEIGHT_BASED_BLEND) && (defined(_HEIGHTMAP0) || defined(_HEIGHTMAP1) || defined(_HEIGHTMAP2) || defined(_HEIGHTMAP3))
float height0 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base0).r - _HeightCenter0) * _HeightAmplitude0;
float height1 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1).r - _HeightCenter1) * _HeightAmplitude1;
float height2 = (SAMPLE_UVMAPPING_TEXTURE2D(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2).r - _HeightCenter2) * _HeightAmplitude2;

// HACK: use height0 to avoid compiler error for unused sampler - To remove when we can have a sampler without a textures
#if !defined(_PIXEL_DISPLACEMENT)
// We don't use height 0 for the height blend based mode
heights.y += (heights.x * 0.0001);
#endif
#endif
// If no heightmap is set on any layer, we don't need to try and blend them based on height...
#endif
ComputeMaskWeights(blendMasks, outWeights);

正在加载...
取消
保存