浏览代码

Fix depth values produced by POM

/Branch_Batching2
Evgenii Golubev 7 年前
当前提交
4dcd086c
共有 1 个文件被更改,包括 13 次插入12 次删除
  1. 25
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

25
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


{
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP)
// TEMP: achieve parity between tessellation and POM w.r.t. height for a single tile.
// TODO: for tiling, the max. height of the tessellated height map should be reduced by NumTiles.
maxDisplacement = 0.1 * _HeightAmplitude;
maxDisplacement = _HeightAmplitude;
#endif
return maxDisplacement;
}

float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, worldToTangent);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
float2 offset;
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam, offset, height);
// TEMP: 0.1 to achieve parity between tessellation and POM w.r.t. height for a single tile.
// TODO: for tiling, the max. height of the tessellated height map should be reduced by NumTiles.
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, 0.1 * maxHeight, ppdParam, offset, height);
// Apply offset to all UVSet
layerTexCoord.base.uv += offset;

return height * maxHeight;
// Since POM "pushes" geometry inwards (rather than extrude it), { height = height - 1 }.
return height * maxHeight - maxHeight;
}
return 0.0;

float depthOffset = ApplyPerPixelDisplacement(input, V, layerTexCoord);
// TODO: remove the scale once the bug is fixed.
depthOffset = depthOffset * 6.0;
#ifdef _DEPTHOFFSET_ON
ApplyDepthOffsetPositionInput(V, depthOffset, _ViewProjMatrix, posInput);

float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, worldToTangent);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
float2 offset;
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam, offset, height);
// TEMP: 0.1 to achieve parity between tessellation and POM w.r.t. height for a single tile.
// TODO: for tiling, the max. height of the tessellated height map should be reduced by NumTiles.
ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, 0.1 * maxHeight, ppdParam, offset, height);
float4 planarWeight = float4( layerTexCoord.base0.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
float4 planarWeight = float4( layerTexCoord.base0.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base1.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base2.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,
layerTexCoord.base3.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0);

layerTexCoord.base0.uv += offsetWeights.x * offset;
layerTexCoord.base1.uv += offsetWeights.y * offset;
layerTexCoord.base2.uv += offsetWeights.z * offset;

layerTexCoord.details3.uv += offsetWeights.w * offset;
}
return height * maxHeight;
// Since POM "pushes" geometry inwards (rather than extrude it), { height = height - 1 }.
return height * maxHeight - maxHeight;
}
return 0.0;

正在加载...
取消
保存