浏览代码

Move the POM height fix into ParallaxOcclusionMapping()

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
ef8b38a6
共有 2 个文件被更改,包括 6 次插入6 次删除
  1. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  2. 4
      Assets/ScriptableRenderPipeline/ShaderLibrary/PerPixelDisplacement.hlsl

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


float3 viewDirTS = isPlanar ? float3(uvXZ, V.y) : TransformWorldToTangent(V, worldToTangent);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
// 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.
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, 0.1 * maxHeight, ppdParam, height);
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam, height);
// Apply offset to all UVSet0 / planar
layerTexCoord.base.uv += offset;

float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, worldToTangent);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
// 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.
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, 0.1 * maxHeight, ppdParam, height);
float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirTS, maxHeight, ppdParam, height);
// Apply offset to all planar UV if applicable
float4 planarWeight = float4( layerTexCoord.base0.mappingType == UV_MAPPING_PLANAR ? 1.0 : 0.0,

4
Assets/ScriptableRenderPipeline/ShaderLibrary/PerPixelDisplacement.hlsl


// ref: https://www.gamedev.net/resources/_/technical/graphics-programming-and-theory/a-closer-look-at-parallax-occlusion-mapping-r3262
float2 ParallaxOcclusionMapping(float lod, float lodThreshold, int numSteps, float3 viewDirTS, float maxHeight, PerPixelHeightDisplacementParam ppdParam, out float outHeight)
{
// 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.
maxHeight *= 0.1;
// Convention: 1.0 is top, 0.0 is bottom - POM is always inward, no extrusion
float stepSize = 1.0 / (float)numSteps;

正在加载...
取消
保存