浏览代码

Merge branch 'Unity-2017.3' of https://github.com/Unity-Technologies/ScriptableRenderLoop into Branch_DepthPrepass

/main
Julien Ignace 7 年前
当前提交
61fc8ab8
共有 4 个文件被更改,包括 19 次插入17 次删除
  1. 5
      ScriptableRenderPipeline/Core/TextureCache.cs
  2. 19
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  3. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  4. 1
      TestbedPipelines/Fptl/FptlLighting.cs

5
ScriptableRenderPipeline/Core/TextureCache.cs


var bFoundAvailOrExistingSlice = false;
// search for existing copy
if (m_LocatorInSliceArray.ContainsKey(texId))
int cachedSlice;
if (m_LocatorInSliceArray.TryGetValue(texId, out cachedSlice))
sliceIndex = m_LocatorInSliceArray[texId];
sliceIndex = cachedSlice;
bFoundAvailOrExistingSlice = true;
Debug.Assert(m_SliceArray[sliceIndex].texId == texId);
}

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


{
float maxDisplacement = 0.0;
#if defined(_HEIGHTMAP)
maxDisplacement = _HeightAmplitude;
maxDisplacement = abs(_HeightAmplitude); // _HeightAmplitude can be negative if min and max are inverted, but the max displacement must be positive
#endif
return maxDisplacement;
}

{
float maxDisplacement = 0.0;
// _HeightAmplitudeX can be negative if min and max are inverted, but the max displacement must be positive, take abs()
maxDisplacement = _HeightAmplitude0;
maxDisplacement = abs(_HeightAmplitude0);
maxDisplacement = max( _HeightAmplitude1
maxDisplacement = max( abs(_HeightAmplitude1)
+_HeightAmplitude0 * _InheritBaseHeight1
+ abs(_HeightAmplitude0) * _InheritBaseHeight1
#endif
, maxDisplacement);
#endif

maxDisplacement = max( _HeightAmplitude2
maxDisplacement = max( abs(_HeightAmplitude2)
+_HeightAmplitude0 * _InheritBaseHeight2
+ abs(_HeightAmplitude0) * _InheritBaseHeight2
#endif
, maxDisplacement);
#endif

#if defined(_HEIGHTMAP3)
maxDisplacement = max( _HeightAmplitude3
maxDisplacement = max( abs(_HeightAmplitude3)
+_HeightAmplitude0 * _InheritBaseHeight3
+ abs(_HeightAmplitude0) * _InheritBaseHeight3
#endif
, maxDisplacement);
#endif

// (baseColor - meanColor) + lerp(meanColor, baseColor0, inheritBaseColor) simplify to
// saturate(influenceFactor * (baseColor0 - meanColor) + baseColor);
// There is a special case when baseColor < meanColor to avoid getting negative values.
float3 factor = baseColor > meanColor ? (baseColor0 - meanColor) : (baseColor0 * baseColor / meanColor - baseColor);
float3 factor = baseColor > meanColor ? (baseColor0 - meanColor) : (baseColor0 * baseColor / max(meanColor, 0.001) - baseColor); // max(to avoid divide by 0)
return influenceFactor * factor + baseColor;
}

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


// Apply tiling options
ADD_IDX(layerTexCoord.base).uv = TRANSFORM_TEX(uvBase, ADD_IDX(_BaseColorMap));
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(uvDetails, ADD_IDX(_DetailMap));
// Detail map tiling option inherit from the tiling of the base
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(TRANSFORM_TEX(uvDetails, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXZ = TRANSFORM_TEX(uvXZ, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(uvXY, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZY = TRANSFORM_TEX(uvZY, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXZ = TRANSFORM_TEX(TRANSFORM_TEX(uvXZ, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(TRANSFORM_TEX(uvXY, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZY = TRANSFORM_TEX(TRANSFORM_TEX(uvZY, ADD_IDX(_BaseColorMap)), ADD_IDX(_DetailMap));
#ifdef SURFACE_GRADIENT
// This part is only relevant for normal mapping with UV_MAPPING_UVSET

1
TestbedPipelines/Fptl/FptlLighting.cs


var lightData = new SFiniteLightData[numVolumes];
var boundData = new SFiniteLightBound[numVolumes];
var worldToView = WorldToCamera(camera);
bool isNegDeterminant = Vector3.Dot(worldToView.GetColumn(0), Vector3.Cross(worldToView.GetColumn(1), worldToView.GetColumn(2))) < 0.0f; // 3x3 Determinant.
uint shadowLightIndex = 0;
foreach (var cl in inputs.visibleLights)

正在加载...
取消
保存