浏览代码

Make POM match tessellation with details map (if same UVSet)

/stochastic_alpha_test
Sebastien Lagarde 7 年前
当前提交
86a73f40
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

11
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


float2 minUvSize = ADD_IDX(GetMinUvSize)(layerTexCoord);
float lod = ComputeTextureLOD(minUvSize);
// TODO: Here we calculate the scale transform from world to UV space , which is what we have done in GetLayerTexCoord but without the texBias.
// Mean we must also apply the same "additionalTiling", currently not apply Also precompute all this!
float2 scaleOffsetDetails = MERGE_NAME(ADD_IDX(_DetailMap), _ST.xy);
PerPixelHeightDisplacementParam ppdParam;
ppdParam.heightmap = ADD_IDX(_HeightMap);

// Apply offset to all triplanar UVSet
ADD_IDX(layerTexCoord.base).uvZY += offset;
ADD_IDX(layerTexCoord.details).uvZY += offset;
ADD_IDX(layerTexCoord.details).uvZY += offset * scaleOffsetDetails;
height += layerTexCoord.triplanarWeights.x * planeHeight;
NdotV += layerTexCoord.triplanarWeights.x * viewDirTS.z;
}

float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirUV, 1, ppdParam, planeHeight);
ADD_IDX(layerTexCoord.base).uvXZ += offset;
ADD_IDX(layerTexCoord.details).uvXZ += offset;
ADD_IDX(layerTexCoord.details).uvXZ += offset * scaleOffsetDetails;
height += layerTexCoord.triplanarWeights.y * planeHeight;
NdotV += layerTexCoord.triplanarWeights.y * viewDirTS.z;
}

float2 offset = ParallaxOcclusionMapping(lod, _PPDLodThreshold, numSteps, viewDirUV, 1, ppdParam, planeHeight);
ADD_IDX(layerTexCoord.base).uvXY += offset;
ADD_IDX(layerTexCoord.details).uvXY += offset;
ADD_IDX(layerTexCoord.details).uvXY += offset * scaleOffsetDetails;
height += layerTexCoord.triplanarWeights.z * planeHeight;
NdotV += layerTexCoord.triplanarWeights.z * viewDirTS.z;
}

// Apply offset to all UVSet0 / planar
ADD_IDX(layerTexCoord.base).uv += offset;
// Note: Applying offset on detail uv is only correct if it use the same UVSet or is planar or triplanar. It is up to the user to do the correct thing.
ADD_IDX(layerTexCoord.details).uv += offset;
ADD_IDX(layerTexCoord.details).uv += offset * scaleOffsetDetails;
}
// Since POM "pushes" geometry inwards (rather than extrude it), { height = height - 1 }.

正在加载...
取消
保存