浏览代码

Merge pull request #107 from Unity-Technologies/Add-POM-and-Tesselation-Test-Level

fix pom issue
/main
GitHub 8 年前
当前提交
32b2a51e
共有 3 个文件被更改,包括 51 次插入18 次删除
  1. 59
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  2. 6
      Assets/TestScenes/HDTest/GraphicTest/Parallax Occlusion Mapping/Material/POM - Wood.mat
  3. 4
      Assets/TestScenes/HDTest/GraphicTest/Tessellation/Material/Tessellation - Wood.mat

59
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


float lod = CALCULATE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv);
// Do a first step before the loop to init all value correctly
float2 texOffsetCurrent = uv;
float2 texOffsetCurrent = 0;
float prevHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + texOffsetCurrent, lod).r;
texOffsetCurrent += texOffsetPerStep;
float currHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + texOffsetCurrent, lod).r;

// Found below and above points, now perform line interesection (ray) with piecewise linear heightfield approximation
// Refine the search by adding few extra intersection
#define POM_REFINE 1
#if POM_REFINE
#define POM_REFINE 0
#if POM_REFINE
float pt0 = rayHeight + stepSize;
float pt1 = rayHeight;
float delta0 = pt0 - prevHeight;
float delta1 = pt1 - currHeight;
float2 offset = float2(0.0, 0.0);
float threshold = 1.0;
for (int i = 0; i < 5; ++i)
{
float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
offset = (1 - t) * texOffsetPerStep * numSteps;
currHeight = SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), uv + offset, lod).r;
threshold = t - currHeight;
if (abs(threshold) <= 0.01)
break;
if (threshold < 0.0)
{
delta1 = threshold;
pt1 = t;
}
else
{
delta0 = threshold;
pt0 = t;
}
}
/*
float t0 = rayHeight + stepSize;
float t1 = rayHeight;
float delta0 = t0 - prevHeight;
float delta1 = t1 - currHeight;
float t = (t0 * delta1 - t1 * delta0) / (delta1 - delta0);
float2 offset = uv + (1 - t) * texOffsetPerStep * numSteps;
*/
//float pt0 = rayHeight + stepSize;
//float pt1 = rayHeight;
//float delta0 = pt0 - prevHeight;
//float delta1 = pt1 - currHeight;
//float t = (pt0 * delta1 - pt1 * delta0) / (delta1 - delta0);
//float2 offset = (1 - t) * texOffsetPerStep * numSteps;
// A bit more optimize
float2 offset = (ratio) * (texOffsetCurrent - texOffsetPerStep) + (1.0 - ratio) * texOffsetCurrent;
float2 offset = texOffsetCurrent - ratio * texOffsetPerStep;
#endif

6
Assets/TestScenes/HDTest/GraphicTest/Parallax Occlusion Mapping/Material/POM - Wood.mat


m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: 0353c00d9bc99f14780836a6a51a6d97, type: 3}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 2, y: 2}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude: 0.09
- _HeightAmplitude: 0.17
- _HeightCenter: 0.5
- _MaterialId: 0
- _Metallic: 0

- _OcclusionStrength: 1
- _PPDMaxSamples: 64
- _PPDMaxSamples: 15
- _PPDMinSamples: 1
- _Parallax: 0.02
- _Smoothness: 0.5

4
Assets/TestScenes/HDTest/GraphicTest/Tessellation/Material/Tessellation - Wood.mat


m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: 0353c00d9bc99f14780836a6a51a6d97, type: 3}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 2, y: 2}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}

- _SubSurfaceRadius: 0
- _SurfaceType: 0
- _TessellationBackFaceCullEpsilon: -0.25
- _TessellationFactor: 10
- _TessellationFactor: 15
- _TessellationFactorMaxDistance: 50
- _TessellationFactorMinDistance: 20
- _TessellationFactorTriangleSize: 100

正在加载...
取消
保存