浏览代码

Working individual layer

/stochastic_alpha_test
Sebastien Lagarde 7 年前
当前提交
1007f823
共有 2 个文件被更改,包括 17 次插入11 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  2. 26
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


if (!match)
{
EditorGUILayout.HelpBox(s_Styles.perPixelDisplacementLayersWarning.text, MessageType.Warning);
EditorGUILayout.HelpBox(styles.perPixelDisplacementLayersWarning.text, MessageType.Warning);
}
}

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


// See function ComputePerVertexDisplacement() for comment about the weights/influenceMask/BlendMask
// Note: Amplitude is handled in uvSpaceScale, no need to multiply by it here.
float height0 = SAMPLE_TEXTURE2D_LOD(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, param.uv[0] + texOffsetCurrent/* * param.uvSpaceScale[0]*/, lod).r;
float height1 = SAMPLE_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, param.uv[1] + texOffsetCurrent/* * param.uvSpaceScale[1]*/, lod).r;
float height2 = SAMPLE_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, param.uv[2] + texOffsetCurrent/* * param.uvSpaceScale[2]*/, lod).r;
float height3 = SAMPLE_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, param.uv[3] + texOffsetCurrent/* * param.uvSpaceScale[3]*/, lod).r;
float height0 = SAMPLE_TEXTURE2D_LOD(_HeightMap0, SAMPLER_HEIGHTMAP_IDX, param.uv[0] + texOffsetCurrent * param.uvSpaceScale[0], lod).r;
float height1 = SAMPLE_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, param.uv[1] + texOffsetCurrent * param.uvSpaceScale[1], lod).r;
float height2 = SAMPLE_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, param.uv[2] + texOffsetCurrent * param.uvSpaceScale[2], lod).r;
float height3 = SAMPLE_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, param.uv[3] + texOffsetCurrent * param.uvSpaceScale[3], lod).r;
SetEnabledHeightByLayer(height0, height1, height2, height3);

NdotV = viewDirTS.z;
// Transform the view vector into the UV space.
float3 viewDirUV = normalize(float3(viewDirTS.xy * ppdParam.uvSpaceScale[0], viewDirTS.z));
float3 viewDirUV = float3(viewDirTS.xy, viewDirTS.z);
layerTexCoord.base0.uv += offset;// *ppdParam.uvSpaceScale[0];
layerTexCoord.base1.uv += offset; //*ppdParam.uvSpaceScale[1];
layerTexCoord.base2.uv += offset;// *ppdParam.uvSpaceScale[2];
layerTexCoord.base3.uv += offset; //*ppdParam.uvSpaceScale[3];
layerTexCoord.base0.uv += offset * ppdParam.uvSpaceScale[0];
layerTexCoord.base1.uv += offset * ppdParam.uvSpaceScale[1];
layerTexCoord.base2.uv += offset * ppdParam.uvSpaceScale[2];
layerTexCoord.base3.uv += offset * ppdParam.uvSpaceScale[3];
layerTexCoord.details0.uv += offset * scaleOffsetDetails0;
layerTexCoord.details1.uv += offset * scaleOffsetDetails1;

// Since POM "pushes" geometry inwards (rather than extrude it), { height = height - 1 }.
// Since the result is used as a 'depthOffsetVS', it needs to be positive, so we flip the sign. { height = -height + 1 }.
float verticalDisplacement = maxHeight0 - height * maxHeight0;
float weights[_MAX_LAYER];
ComputeMaskWeights(ppdParam.blendMasks, weights);
float maxHeight = BlendLayeredScalar(maxHeight0, maxHeight1, maxHeight2, maxHeight3, weights);
// TODO: handle height based blend
float verticalDisplacement = maxHeight - height * maxHeight;
return verticalDisplacement / max(NdotV, 0.001);
#else
return 0.0;

正在加载...
取消
保存