Expand Up @@ -65,7 +65,13 @@ public virtual void Override(VolumeComponent state, float interpFactor)
var toParam = parameters[i];

// Keep track of the override state for debugging purpose
stateParam.overrideState = toParam.overrideState;
//custom-begin: malte: allow partial overrides from many volumes in priority order
if (toParam.overrideState)
{
stateParam.overrideState = toParam.overrideState;
stateParam.Interp(stateParam, toParam, interpFactor);
}
//custom-end

if (toParam.overrideState)
stateParam.Interp(stateParam, toParam, interpFactor);
Expand Down
Expand Up @@ -288,14 +288,18 @@ public void Update(VolumeStack stack, Transform trigger, LayerMask layerMask)
float interpFactor = 1f;

if (blendDistSqr > 0f)
interpFactor = 1f - (closestDistanceSqr / blendDistSqr);
//custom-begin: malte: smoothstep blend
interpFactor = Mathf.SmoothStep(1f, 0f, closestDistanceSqr / blendDistSqr);
//custom-end

// No need to clamp01 the interpolation factor as it'll always be in [0;1[ range
OverrideData(stack, volume.profileRef.components, interpFactor * Mathf.Clamp01(volume.weight));
}
}

List<Volume> GrabVolumes(LayerMask mask)
//custom-begin: malte: debugging/visualizing volumes
public List<Volume> GrabVolumes(LayerMask mask)
//custom-end
{
List<Volume> list;

Expand Down
Expand Up @@ -286,7 +286,9 @@ public void Update(FrameSettings currentFrameSettings, PostProcessLayer postProc
m_ActualHeight = camera.pixelHeight;
var screenWidth = m_ActualWidth;
var screenHeight = m_ActualHeight;
#if !UNITY_SWITCH
//forest-begin: Added XboxOne to define around XR code
#if !UNITY_SWITCH && !UNITY_XBOXONE
//forest-end:
if (m_frameSettings.enableStereo)
{
screenWidth = XRSettings.eyeTextureWidth;
Expand Down
Expand Up @@ -15,6 +15,10 @@ sealed class Styles
public readonly GUIContent transmittancePreview2 = new GUIContent("Can be viewed as a cross section of a slab of material illuminated by white light from the left.");
public readonly GUIContent profileScatteringDistance = new GUIContent("Scattering Distance", "Determines the shape of the profile, and the blur radius of the filter per color channel. Alpha is ignored.");
public readonly GUIContent profileTransmissionTint = new GUIContent("Transmission tint", "Color which tints transmitted light. Alpha is ignored.");
//forest-begin: Tweakable transmission
public readonly GUIContent profileTransmissionDirectScale = new GUIContent("Direct Scale", "Tweak direct transmission contribution.");
public readonly GUIContent profileTransmissionIndirectScale = new GUIContent("Indirect Scale", "Tweak indirect transmission contribution.");
//forest-end:
public readonly GUIContent profileMaxRadius = new GUIContent("Max Radius", "Effective radius of the filter (in millimeters). The blur is energy-preserving, so a wide filter results in a large area with small contributions of individual samples. Reducing the distance increases the sharpness of the result.");
public readonly GUIContent texturingMode = new GUIContent("Texturing Mode", "Specifies when the diffuse texture should be applied.");
public readonly GUIContent[] texturingModeOptions = new GUIContent[2]
Expand Down
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
Expand All @@ -17,6 +17,10 @@ sealed class Profile

internal SerializedProperty scatteringDistance;
internal SerializedProperty transmissionTint;
//forest-begin: Tweakable transmission
internal SerializedProperty transmissionDirectScale;
internal SerializedProperty transmissionIndirectScale;
//forest-end:
internal SerializedProperty texturingMode;
internal SerializedProperty transmissionMode;
internal SerializedProperty thicknessRemap;
Expand Down Expand Up @@ -78,6 +82,10 @@ protected override void OnEnable()

scatteringDistance = rp.Find(x => x.scatteringDistance),
transmissionTint = rp.Find(x => x.transmissionTint),
//forest-begin: Tweakable transmission
transmissionDirectScale = rp.Find(x => x.transmissionDirectScale),
transmissionIndirectScale = rp.Find(x => x.transmissionIndirectScale),
//forest-end:
texturingMode = rp.Find(x => x.texturingMode),
transmissionMode = rp.Find(x => x.transmissionMode),
thicknessRemap = rp.Find(x => x.thicknessRemap),
Expand Down Expand Up @@ -169,6 +177,10 @@ public override void OnInspectorGUI()
var thicknessRemap = profile.thicknessRemap.vector2Value;
EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f);
profile.thicknessRemap.vector2Value = thicknessRemap;
//forest-begin: Tweakable transmission
EditorGUILayout.Slider(profile.transmissionDirectScale, 0f, 8f, s_Styles.profileTransmissionDirectScale);
EditorGUILayout.Slider(profile.transmissionIndirectScale, 0f, 8f, s_Styles.profileTransmissionIndirectScale);
//forest-end:

EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);
Expand Down
Expand Up @@ -71,6 +71,10 @@ private class StylesLayer

public readonly GUIContent materialReferencesText = new GUIContent("Material References");

//forest-begin:
public readonly GUIContent enableTerrainModeText = new GUIContent("Enable Terrain Mode");
//forest-end:

public StylesLayer()
{
layerLabelColors[0].normal.textColor = layerColors[0];
Expand Down Expand Up @@ -147,6 +151,10 @@ public LayeredLitGUI()
MaterialProperty[] showLayer = new MaterialProperty[kMaxLayerCount];
const string kShowLayer = "_ShowLayer";

//forest-begin:
MaterialProperty enableTerrainMode = null;
const string kEnableTerrainMode = "_EnableTerrainMode";
//forest-end:
bool m_UseHeightBasedBlend;

protected override void FindMaterialProperties(MaterialProperty[] props)
Expand Down Expand Up @@ -183,6 +191,10 @@ protected override void FindMaterialProperties(MaterialProperty[] props)
inheritBaseColor[i - 1] = FindProperty(string.Format("{0}{1}", kInheritBaseColor, i), props);
}
}

//forest-begin:
enableTerrainMode = FindProperty(kEnableTerrainMode, props, false);
//forest-end:
}

int numLayer
Expand Down Expand Up @@ -364,6 +376,7 @@ bool DoLayerGUI(AssetImporter materialImporter, int layerIndex)
return result;
}


void DoLayeringInputGUI()
{
EditorGUI.indentLevel++;
Expand Down Expand Up @@ -751,6 +764,10 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
EditorGUI.indentLevel++;
m_MaterialEditor.EnableInstancingField();
m_MaterialEditor.ShaderProperty(enableSpecularOcclusion, Styles.enableSpecularOcclusionText);
//forest-begin:
if(enableTerrainMode != null)
m_MaterialEditor.ShaderProperty(enableTerrainMode, styles.enableTerrainModeText);
//forest-end:
EditorGUI.indentLevel--;

if (layerChanged || optionsChanged)
Expand Down
Expand Up @@ -50,7 +50,9 @@ protected static class StylesBaseLit
public static string vertexAnimation = "Vertex animation";

// Wind
public static GUIContent windText = new GUIContent("Enable Wind");
//forest-begin: Added vertex animation
public static GUIContent windText = new GUIContent("Wind Mode");
//forest-end:
public static GUIContent windInitialBendText = new GUIContent("Initial Bend");
public static GUIContent windStiffnessText = new GUIContent("Stiffness");
public static GUIContent windDragText = new GUIContent("Drag");
Expand Down Expand Up @@ -138,6 +140,18 @@ public enum HeightmapParametrization
protected const string kPpdPrimitiveWidth = "_PPDPrimitiveWidth";
protected MaterialProperty invPrimScale = null;
protected const string kInvPrimScale = "_InvPrimScale";
//forest-begin: Tree occlusion
protected MaterialProperty treeOcclusion;
protected MaterialProperty treeAO;
protected MaterialProperty treeAOBias;
protected MaterialProperty treeAO2;
protected MaterialProperty treeAOBias2;
protected MaterialProperty treeDO;
protected MaterialProperty treeDOBias;
protected MaterialProperty treeDO2;
protected MaterialProperty treeDOBias2;
protected MaterialProperty tree12Width;
//forest-end:

// Wind
protected MaterialProperty windEnable = null;
Expand All @@ -152,6 +166,48 @@ public enum HeightmapParametrization
protected const string kWindShiverDrag = "_ShiverDrag";
protected MaterialProperty windShiverDirectionality = null;
protected const string kWindShiverDirectionality = "_ShiverDirectionality";
//forest-begin: Added vertex animation
protected MaterialProperty windHeightScale;
protected const string kWindHeightScale = "_WindHeightScale";
protected MaterialProperty windHeightIntensity;
protected const string kWindHeightIntensity = "_WindHeightIntensity";
protected MaterialProperty windHeightSpeedScale;
protected const string kWindHeightSpeedScale = "_WindHeightSpeed";
protected MaterialProperty windInnerRadius;
protected const string kWindInnerRadius = "_WindInnerRadius";
protected MaterialProperty windRangeRadius;
protected const string kWindRangeRadius = "_WindRangeRadius";
protected MaterialProperty windRadiusIntensity;
protected const string kWindRadiusIntensity = "_WindRadiusIntensity";
protected MaterialProperty windRadiusSpeedScale;
protected const string kWindRadiusSpeedScale = "_WindRadiusSpeed";
protected MaterialProperty windElasticityLvlB;
protected const string kWindElasticityLvlB = "_WindElasticityLvlB";
protected MaterialProperty windElasticityLvl0;
protected const string kWindElasticityLvl0 = "_WindElasticityLvl0";
protected MaterialProperty windElasticityLvl1;
protected const string kWindElasticityLvl1 = "_WindElasticityLvl1";
protected MaterialProperty windRangeLvlB;
protected const string kWindRangeLvlB = "_WindRangeLvlB";
protected MaterialProperty windRangeLvl0;
protected const string kWindRangeLvl0 = "_WindRangeLvl0";
protected MaterialProperty windRangeLvl1;
protected const string kWindRangeLvl1 = "_WindRangeLvl1";
protected MaterialProperty windFakeSingleObjectPivot;
protected const string kWindFakeSingleObjectPivot= "_WindFakeSingleObjectPivot";
protected MaterialProperty windFlutterElasticity;
protected const string kWindFlutterElasticity = "_WindFlutterElasticity";
protected MaterialProperty windFlutterScale;
protected const string kWindFlutterScale = "_WindFlutterScale";
protected MaterialProperty windFlutterPeriodScale;
protected const string kWindFlutterPeriodScale = "_WindFlutterPeriodScale";
protected MaterialProperty windFlutterPhase;
protected const string kWindFlutterPhase = "_WindFlutterPhase";
//forest-end:
//forest-begin: Wind flutter map
protected MaterialProperty windFlutterMap = null;
protected const string kWindFlutterMap = "_WindFlutterMap";
//forest-end:

// tessellation params
protected MaterialProperty tessellationMode = null;
Expand Down Expand Up @@ -211,6 +267,19 @@ protected override void FindBaseMaterialProperties(MaterialProperty[] props)
tessellationShapeFactor = FindProperty(kTessellationShapeFactor, props, false);
tessellationBackFaceCullEpsilon = FindProperty(kTessellationBackFaceCullEpsilon, props, false);

//forest-begin: Tree occlusion
treeOcclusion = FindProperty("_UseTreeOcclusion", props, false);
treeAO = FindProperty("_TreeAO", props, false);
treeAOBias = FindProperty("_TreeAOBias", props, false);
treeAO2 = FindProperty("_TreeAO2", props, false);
treeAOBias2 = FindProperty("_TreeAOBias2", props, false);
treeDO = FindProperty("_TreeDO", props, false);
treeDOBias = FindProperty("_TreeDOBias", props, false);
treeDO2 = FindProperty("_TreeDO2", props, false);
treeDOBias2 = FindProperty("_TreeDOBias2", props, false);
tree12Width = FindProperty("_Tree12Width", props, false);
//forest-end:

// Wind
windEnable = FindProperty(kWindEnabled, props);
windInitialBend = FindProperty(kWindInitialBend, props);
Expand All @@ -219,6 +288,30 @@ protected override void FindBaseMaterialProperties(MaterialProperty[] props)
windShiverDrag = FindProperty(kWindShiverDrag, props);
windShiverDirectionality = FindProperty(kWindShiverDirectionality, props);

//forest-begin: Added vertex animation
windHeightScale = FindProperty(kWindHeightScale, props, false);
windHeightIntensity = FindProperty(kWindHeightIntensity, props, false);
windHeightSpeedScale = FindProperty(kWindHeightSpeedScale, props, false);
windInnerRadius = FindProperty(kWindInnerRadius, props, false);
windRangeRadius = FindProperty(kWindRangeRadius, props, false);
windRadiusIntensity = FindProperty(kWindRadiusIntensity, props, false);
windRadiusSpeedScale = FindProperty(kWindRadiusSpeedScale, props, false);
windElasticityLvlB = FindProperty(kWindElasticityLvlB, props, false);
windElasticityLvl0 = FindProperty(kWindElasticityLvl0, props, false);
windElasticityLvl1 = FindProperty(kWindElasticityLvl1, props, false);
windRangeLvlB = FindProperty(kWindRangeLvlB, props, false);
windRangeLvl0 = FindProperty(kWindRangeLvl0, props, false);
windRangeLvl1 = FindProperty(kWindRangeLvl1, props, false);
windFakeSingleObjectPivot= FindProperty(kWindFakeSingleObjectPivot,props, false);
windFlutterElasticity = FindProperty(kWindFlutterElasticity, props, false);
windFlutterScale = FindProperty(kWindFlutterScale, props, false);
windFlutterPeriodScale = FindProperty(kWindFlutterPeriodScale, props, false);
windFlutterPhase = FindProperty(kWindFlutterPhase, props, false);
//forest-end:
//forest-begin: Wind flutter map
windFlutterMap = FindProperty(kWindFlutterMap, props, false);
//forest-end:

// Decal
supportDBuffer = FindProperty(kSupportDBuffer, props);

Expand Down Expand Up @@ -352,13 +445,75 @@ protected override void VertexAnimationPropertiesGUI()
if (!windEnable.hasMixedValue && windEnable.floatValue > 0.0f)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(windInitialBend, StylesBaseLit.windInitialBendText);
m_MaterialEditor.ShaderProperty(windStiffness, StylesBaseLit.windStiffnessText);
m_MaterialEditor.ShaderProperty(windDrag, StylesBaseLit.windDragText);
m_MaterialEditor.ShaderProperty(windShiverDrag, StylesBaseLit.windShiverDragText);
m_MaterialEditor.ShaderProperty(windShiverDirectionality, StylesBaseLit.windShiverDirectionalityText);
//forest-begin: Added vertex animation
if(windEnable.floatValue < 1.5f) {
m_MaterialEditor.ShaderProperty(windInitialBend, StylesBaseLit.windInitialBendText);
m_MaterialEditor.ShaderProperty(windStiffness, StylesBaseLit.windStiffnessText);
m_MaterialEditor.ShaderProperty(windDrag, StylesBaseLit.windDragText);
m_MaterialEditor.ShaderProperty(windShiverDrag, StylesBaseLit.windShiverDragText);
m_MaterialEditor.ShaderProperty(windShiverDirectionality, StylesBaseLit.windShiverDirectionalityText);
} else if(windHeightScale != null) {
if(windEnable.floatValue > 1.5f && windEnable.floatValue < 4.5f) {
EditorGUILayout.Space();
m_MaterialEditor.ShaderProperty(windElasticityLvlB, windElasticityLvlB.displayName);
m_MaterialEditor.ShaderProperty(windRangeLvlB, windRangeLvlB.displayName);
}

if(windEnable.floatValue == 4f) {
m_MaterialEditor.ShaderProperty(windElasticityLvl0, windElasticityLvl0.displayName);
m_MaterialEditor.ShaderProperty(windRangeLvl0, windRangeLvl0.displayName);
m_MaterialEditor.ShaderProperty(windElasticityLvl1, windElasticityLvl1.displayName);
m_MaterialEditor.ShaderProperty(windRangeLvl1, windRangeLvl1.displayName);
}

if(windEnable.floatValue == 6f)
m_MaterialEditor.ShaderProperty(windFakeSingleObjectPivot, windFakeSingleObjectPivot.displayName);

if(windInnerRadius != null && windEnable.floatValue > 5.5f) {
EditorGUILayout.Space();
m_MaterialEditor.ShaderProperty(windElasticityLvlB, windElasticityLvlB.displayName);
m_MaterialEditor.ShaderProperty(windRangeLvlB, windRangeLvlB.displayName);
}

EditorGUILayout.Space();
m_MaterialEditor.ShaderProperty(windFlutterElasticity, windFlutterElasticity.displayName);
m_MaterialEditor.ShaderProperty(windFlutterPhase, windFlutterPhase.displayName);
m_MaterialEditor.ShaderProperty(windFlutterScale, windFlutterScale.displayName);
m_MaterialEditor.ShaderProperty(windFlutterPeriodScale, windFlutterPeriodScale.displayName);
}
//forest-end:

//forest-begin: Tree occlusion
if(windEnable.floatValue > 1.5f && windEnable.floatValue < 4.5f) {
if(treeOcclusion != null) {
EditorGUILayout.Space();
var useTreeOcclusion = treeOcclusion.floatValue > 0.5f;
var newUseTreeOcclusion = EditorGUILayout.Toggle("Tree Occlusion", useTreeOcclusion);
if(newUseTreeOcclusion != useTreeOcclusion)
treeOcclusion.floatValue = newUseTreeOcclusion ? 1f : 0f;

if(useTreeOcclusion) {
++EditorGUI.indentLevel;
m_MaterialEditor.ShaderProperty(treeAO, treeAO.displayName);
m_MaterialEditor.ShaderProperty(treeAOBias, treeAOBias.displayName);
m_MaterialEditor.ShaderProperty(treeAO2, treeAO2.displayName);
m_MaterialEditor.ShaderProperty(treeAOBias2, treeAOBias2.displayName);
m_MaterialEditor.ShaderProperty(treeDO, treeDO.displayName);
m_MaterialEditor.ShaderProperty(treeDOBias, treeDOBias.displayName);
m_MaterialEditor.ShaderProperty(treeDO2, treeDO2.displayName);
m_MaterialEditor.ShaderProperty(treeDOBias2, treeDOBias2.displayName);
m_MaterialEditor.ShaderProperty(tree12Width, tree12Width.displayName);
--EditorGUI.indentLevel;
}
}
}
//forest-end:
EditorGUI.indentLevel--;
}
//forest-begin: Wind flutter map
if(windFlutterMap != null)
m_MaterialEditor.TexturePropertySingleLine(new GUIContent(windFlutterMap.displayName), windFlutterMap);
//forest-end:

EditorGUI.indentLevel--;
}
Expand Down Expand Up @@ -418,8 +573,26 @@ static public void SetupBaseLitKeywords(Material material)
CoreUtils.SetKeyword(material, "_PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE", displacementLockObjectScale && enablePixelDisplacement);
CoreUtils.SetKeyword(material, "_DISPLACEMENT_LOCK_TILING_SCALE", displacementLockTilingScale && enableDisplacement);

bool windEnabled = material.GetFloat(kWindEnabled) > 0.0f;
CoreUtils.SetKeyword(material, "_VERTEX_WIND", windEnabled);
//forest-begin: Added vertex animation
if (material.HasProperty(kWindEnabled))
{
var windMode = material.GetFloat(kWindEnabled);
CoreUtils.SetKeyword(material, "_ANIM_SINGLE_PIVOT_COLOR", windMode > 2.5f && windMode < 3.5f);
CoreUtils.SetKeyword(material, "_ANIM_HIERARCHY_PIVOT", windMode > 3.5f && windMode < 4.5f);
CoreUtils.SetKeyword(material, "_ANIM_PROCEDURAL_BRANCH", windMode > 5.5f && windMode < 6.5f);

//forest-begin: G-Buffer motion vectors
if(windMode > 2.5f) {
var hdrpa = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
if(hdrpa && hdrpa.GetFrameSettings().enableGBufferMotionVectors) {
material.SetInt(kStencilRef, stencilRef | (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
material.SetInt(kStencilWriteMask, (int)HDRenderPipeline.StencilBitMask.LightingMask | (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
}
}
//forest-end:
}
//forest-end:


// Depth offset is only enabled if per pixel displacement is
bool depthOffsetEnable = (material.GetFloat(kDepthOffsetEnable) > 0.0f) && enablePixelDisplacement;
Expand All @@ -433,6 +606,7 @@ static public void SetupBaseLitKeywords(Material material)

SetupMainTexForAlphaTestGI("_BaseColorMap", "_BaseColor", material);


// Use negation so we don't create keyword by default
CoreUtils.SetKeyword(material, "_DISABLE_DBUFFER", material.GetFloat(kSupportDBuffer) == 0.0);

Expand Down
Expand Up @@ -46,6 +46,24 @@ bool LitShaderStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSni
}
}

//forest-begin: G-Buffer motion vectors
if(inputData.shaderCompilerPlatform != ShaderCompilerPlatform.PS4 && inputData.shaderCompilerPlatform != ShaderCompilerPlatform.XboxOneD3D11 && inputData.shaderCompilerPlatform != ShaderCompilerPlatform.XboxOneD3D12)
{
if(shader.name == "HDRenderPipeline/Lit" || shader.name == "HDRenderPipeline/LitTessellation") {
var gBufferMotionVectors = new UnityEngine.Rendering.ShaderKeyword("GBUFFER_MOTION_VECTORS");
var isGBufferMotionVectors = inputData.shaderKeywordSet.IsEnabled(gBufferMotionVectors);

if(hdrpAsset.GetFrameSettings().enableGBufferMotionVectors) {
if(isGBufferPass && !isGBufferMotionVectors)
return true;
} else {
if(isGBufferMotionVectors)
return true;
}
}
}
//forest-end:

// TODO: Tests for later
// We need to find a way to strip useless shader features for passes/shader stages that don't need them (example, vertex shaders won't ever need SSS Feature flag)
// This causes several problems:
Expand Down
Expand Up @@ -48,6 +48,9 @@ protected static class Styles
public static string detailText = "Detail Inputs";
public static GUIContent UVDetailMappingText = new GUIContent("Detail UV mapping", "");
public static GUIContent detailMapNormalText = new GUIContent("Detail Map A(R) Ny(G) S(B) Nx(A)", "Detail Map");
//forest-begin: Procedural bark peel
public static GUIContent detailMaskText = new GUIContent("Peel Mask (RG)", "Mask for peel detail map");
//forest-end:
public static GUIContent detailAlbedoScaleText = new GUIContent("Detail AlbedoScale", "Detail Albedo Scale factor");
public static GUIContent detailNormalScaleText = new GUIContent("Detail NormalScale", "Normal Scale factor");
public static GUIContent detailSmoothnessScaleText = new GUIContent("Detail SmoothnessScale", "Smoothness Scale factor");
Expand Down Expand Up @@ -156,6 +159,10 @@ public enum UVDetailMapping
protected const string kSmoothnessRemapMin = "_SmoothnessRemapMin";
protected MaterialProperty[] smoothnessRemapMax = new MaterialProperty[kMaxLayerCount];
protected const string kSmoothnessRemapMax = "_SmoothnessRemapMax";
//forest-begin: View angle dependent smoothness tweak
protected MaterialProperty smoothnessViewAngleOffset = null;
protected const string kSmoothnessViewAngleOffset = "_SmoothnessViewAngleOffset";
//forest-end:
protected MaterialProperty[] aoRemapMin = new MaterialProperty[kMaxLayerCount];
protected const string kAORemapMin = "_AORemapMin";
protected MaterialProperty[] aoRemapMax = new MaterialProperty[kMaxLayerCount];
Expand Down Expand Up @@ -230,6 +237,18 @@ public enum UVDetailMapping
protected const string kSpecularColor = "_SpecularColor";
protected MaterialProperty specularColorMap = null;
protected const string kSpecularColorMap = "_SpecularColorMap";
//forest-begin: Procedural bark peel
protected MaterialProperty detailMode = null;
protected const string kDetailMode = "_DetailMode";
protected MaterialProperty detailMask = null;
protected const string kDetailMask = "_DetailMask";
protected MaterialProperty peeledBarkColor = null;
protected const string kPeeledBarkColor = "_PeeledBarkColor";
protected MaterialProperty peeledBarkColorAlt = null;
protected const string kPeeledBarkColorAlt = "_PeeledBarkColorAlt";
protected MaterialProperty peeledBarkUVRangeScale = null;
protected const string kPeeledBarkUVRangeScale = "_PeeledBarkUVRangeScale";
//forest-end:

protected MaterialProperty tangentMap = null;
protected const string kTangentMap = "_TangentMap";
Expand Down Expand Up @@ -370,6 +389,9 @@ protected override void FindMaterialProperties(MaterialProperty[] props)
FindMaterialLayerProperties(props);
FindMaterialEmissiveProperties(props);

//forest-begin: View angle dependent smoothness tweak
smoothnessViewAngleOffset = FindProperty(kSmoothnessViewAngleOffset, props, false);
//forest-end:
// The next properties are only supported for regular Lit shader (not layered ones) because it's complicated to blend those parameters if they are different on a per layer basis.

// Specular Color
Expand All @@ -383,6 +405,13 @@ protected override void FindMaterialProperties(MaterialProperty[] props)
anisotropy = FindProperty(kAnisotropy, props);
anisotropyMap = FindProperty(kAnisotropyMap, props);

//forest-begin: Procedural bark peel
detailMode = FindProperty(kDetailMode, props, false);
detailMask = FindProperty(kDetailMask, props, false);
peeledBarkColor = FindProperty(kPeeledBarkColor, props, false);
peeledBarkColorAlt = FindProperty(kPeeledBarkColorAlt, props, false);
peeledBarkUVRangeScale = FindProperty(kPeeledBarkUVRangeScale, props, false);
//forest-end:
// Iridescence
iridescenceMask = FindProperty(kIridescenceMask, props);
iridescenceMaskMap = FindProperty(kIridescenceMaskMap, props);
Expand Down Expand Up @@ -612,6 +641,11 @@ protected void DoLayerGUI(Material material, int layerIndex, bool isLayeredLit,
}
}

//forest-begin: View angle dependent smoothness tweak
if(smoothnessViewAngleOffset != null)
m_MaterialEditor.ShaderProperty(smoothnessViewAngleOffset, smoothnessViewAngleOffset.displayName);
//forest-end:

m_MaterialEditor.TexturePropertySingleLine(((BaseLitGUI.MaterialId)materialID.floatValue == BaseLitGUI.MaterialId.LitSpecular) ? Styles.maskMapSpecularText : Styles.maskMapSText, maskMap[layerIndex]);

m_MaterialEditor.ShaderProperty(normalMapSpace[layerIndex], Styles.normalMapSpaceText);
Expand Down Expand Up @@ -744,7 +778,22 @@ protected void DoLayerGUI(Material material, int layerIndex, bool isLayeredLit,
EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.detailText, EditorStyles.boldLabel);


EditorGUI.indentLevel++;

//forest-begin: Procedural bark peel
if(detailMode != null) {
m_MaterialEditor.ShaderProperty(detailMode, detailMode.displayName);

if(Mathf.Approximately(detailMode.floatValue, 4f)) {
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
m_MaterialEditor.ShaderProperty(peeledBarkColor, peeledBarkColor.displayName);
m_MaterialEditor.ShaderProperty(peeledBarkColorAlt, peeledBarkColorAlt.displayName);
m_MaterialEditor.ShaderProperty(peeledBarkUVRangeScale, peeledBarkUVRangeScale.displayName);
}
}
//forest-end:

m_MaterialEditor.TexturePropertySingleLine(Styles.detailMapNormalText, detailMap[layerIndex]);

if (material.GetTexture(isLayeredLit ? kDetailMap + layerIndex : kDetailMap))
Expand Down Expand Up @@ -933,7 +982,16 @@ static public void SetupMaterialKeywordsAndPass(Material material)
CoreUtils.SetKeyword(material, "_ENABLESPECULAROCCLUSION", material.GetFloat(kEnableSpecularOcclusion) > 0.0f);
CoreUtils.SetKeyword(material, "_HEIGHTMAP", material.GetTexture(kHeightMap));
CoreUtils.SetKeyword(material, "_ANISOTROPYMAP", material.GetTexture(kAnisotropyMap));
CoreUtils.SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap));
//forest-begin: Detail alternatives
var detailMode = material.HasProperty(kDetailMode) ? Mathf.RoundToInt(material.GetFloat(kDetailMode)) : 0;
if(detailMode == 4) {
CoreUtils.SetKeyword(material, "_DETAIL_MAP", false);
CoreUtils.SetKeyword(material, "_DETAIL_MAP_PEEL", material.GetTexture(kDetailMap));
} else {
CoreUtils.SetKeyword(material, "_DETAIL_MAP_PEEL", false);
CoreUtils.SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap));
}
//forest-end:
CoreUtils.SetKeyword(material, "_SUBSURFACE_MASK_MAP", material.GetTexture(kSubsurfaceMaskMap));
CoreUtils.SetKeyword(material, "_THICKNESSMAP", material.GetTexture(kThicknessMap));
CoreUtils.SetKeyword(material, "_IRIDESCENCE_THICKNESSMAP", material.GetTexture(kIridescenceThicknessMap));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -381,8 +381,8 @@ static public void SetupBaseUnlitKeywords(Material material)
material.SetOverrideTag("RenderType", alphaTestEnable ? "TransparentCutout" : "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.renderQueue = alphaTestEnable ? (int)HDRenderQueue.Priority.OpaqueAlphaTest : (int)HDRenderQueue.Priority.Opaque;
material.SetInt("_ZWrite", 1);
material.renderQueue = alphaTestEnable ? (int)HDRenderQueue.Priority.OpaqueAlphaTest : (int)HDRenderQueue.Priority.Opaque;
}
else
{
Expand Down
Expand Up @@ -9,6 +9,9 @@ static class HDIncludePaths
[ShaderIncludePath]
public static string[] GetPaths()
{
//forest-begin:
return new[] { "Assets/_LocalPackages/botd.com.unity.render-pipelines.high-definition" };
#if false
var srpMarker = Directory.GetFiles(Application.dataPath, "SRPMARKER", SearchOption.AllDirectories).FirstOrDefault();
var paths = new string[srpMarker == null ? 1 : 2];
var index = 0;
Expand All @@ -20,6 +23,8 @@ public static string[] GetPaths()
}
paths[index] = Path.GetFullPath("Packages/com.unity.render-pipelines.high-definition");
return paths;
#endif
//forest-end:
}
}
}
Expand Up @@ -95,6 +95,9 @@ static void Drawer_SectionRenderingPasses(FrameSettingsUI s, SerializedFrameSett
EditorGUILayout.PropertyField(p.enableTransparentPostpass, _.GetContent("Enable Transparent Postpass"));
EditorGUILayout.PropertyField(p.enableMotionVectors, _.GetContent("Enable Motion Vectors"));
EditorGUILayout.PropertyField(p.enableObjectMotionVectors, _.GetContent("Enable Object Motion Vectors"));
//forest-begin: G-Buffer motion vectors
EditorGUILayout.PropertyField(p.enableGBufferMotionVectors, _.GetContent("Enable G-Buffer Motion Vectors"));
//forest-end:
EditorGUILayout.PropertyField(p.enableDBuffer, _.GetContent("Enable DBuffer"));
EditorGUILayout.PropertyField(p.enableRoughRefraction, _.GetContent("Enable Rough Refraction"));
EditorGUILayout.PropertyField(p.enableDistortion, _.GetContent("Enable Distortion"));
Expand Down Expand Up @@ -137,6 +140,9 @@ static void Drawer_SectionLightingSettings(FrameSettingsUI s, SerializedFrameSet
EditorGUILayout.PropertyField(p.enableShadow, _.GetContent("Enable Shadow"));
EditorGUILayout.PropertyField(p.enableContactShadow, _.GetContent("Enable Contact Shadows"));
EditorGUILayout.PropertyField(p.enableShadowMask, _.GetContent("Enable Shadow Masks"));
//forest-begin: Explicit reflection probe tracking
EditorGUILayout.PropertyField(p.disableReflectionProbeCulling, _.GetContent("Disable ReflectionProbe Culling"));
//forest-end:
}
}
}
Expand Up @@ -24,6 +24,9 @@ public class SerializedFrameSettings
public SerializedProperty enableTransparentPrepass;
public SerializedProperty enableMotionVectors;
public SerializedProperty enableObjectMotionVectors;
//forest-begin: G-Buffer motion vectors
public SerializedProperty enableGBufferMotionVectors;
//forest-end:
public SerializedProperty enableDBuffer;
public SerializedProperty enableRoughRefraction;
public SerializedProperty enableTransparentPostpass;
Expand All @@ -39,6 +42,9 @@ public class SerializedFrameSettings
public SerializedProperty enableMSAA;

public SerializedProperty enableShadowMask;
//forest-begin: Explicit reflection probe tracking
public SerializedProperty disableReflectionProbeCulling;
//forest-end:

public SerializedLightLoopSettings lightLoopSettings;

Expand All @@ -62,6 +68,9 @@ public SerializedFrameSettings(SerializedProperty root)
enableTransparentPrepass = root.Find((FrameSettings d) => d.enableTransparentPrepass);
enableMotionVectors = root.Find((FrameSettings d) => d.enableMotionVectors);
enableObjectMotionVectors = root.Find((FrameSettings d) => d.enableObjectMotionVectors);
//forest-begin: G-Buffer motion vectors
enableGBufferMotionVectors = root.Find((FrameSettings d) => d.enableGBufferMotionVectors);
//forest-end:
enableDBuffer = root.Find((FrameSettings d) => d.enableDBuffer);
enableRoughRefraction = root.Find((FrameSettings d) => d.enableRoughRefraction);
enableTransparentPostpass = root.Find((FrameSettings d) => d.enableTransparentPostpass);
Expand All @@ -73,6 +82,9 @@ public SerializedFrameSettings(SerializedProperty root)
enableTransparentObjects = root.Find((FrameSettings d) => d.enableTransparentObjects);
enableMSAA = root.Find((FrameSettings d) => d.enableMSAA);
enableShadowMask = root.Find((FrameSettings d) => d.enableShadowMask);
//forest-begin: Explicit reflection probe tracking
disableReflectionProbeCulling = root.Find((FrameSettings d) => d.disableReflectionProbeCulling);
//forest-end:

lightLoopSettings = new SerializedLightLoopSettings(root.Find((FrameSettings d) => d.lightLoopSettings));
}
Expand Down
Expand Up @@ -8,13 +8,19 @@ class SerializedShadowInitParameters

public SerializedProperty shadowAtlasWidth;
public SerializedProperty shadowAtlasHeight;
//forest-begin: 16-bit shadows option
public SerializedProperty shadowMap16Bit;
//forest-end:

public SerializedShadowInitParameters(SerializedProperty root)
{
this.root = root;

shadowAtlasWidth = root.Find((ShadowInitParameters s) => s.shadowAtlasWidth);
shadowAtlasHeight = root.Find((ShadowInitParameters s) => s.shadowAtlasHeight);
//forest-begin: 16-bit shadows option
shadowMap16Bit = root.Find((ShadowInitParameters s) => s.shadowMap16Bit);
//forest-end:
}
}
}
Expand Up @@ -22,6 +22,9 @@ static void Drawer_FieldShadowSize(ShadowInitParametersUI s, SerializedShadowIni
++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(d.shadowAtlasWidth, _.GetContent("Atlas Width"));
EditorGUILayout.PropertyField(d.shadowAtlasHeight, _.GetContent("Atlas Height"));
//forest-begin: 16-bit shadows option
EditorGUILayout.PropertyField(d.shadowMap16Bit, _.GetContent("16-bit Shadow Maps"));
//forest-end:
--EditorGUI.indentLevel;
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -13,7 +13,6 @@ public class HDRPVersion
static public int GetCurrentHDRPProjectVersion()
{
string[] version = new string[1];
version[0] = "0"; // Note: When we don't know what a project is, assume worst case 0

try
{
Expand All @@ -23,6 +22,9 @@ static public int GetCurrentHDRPProjectVersion()
{
// Don't display warning
//Debug.LogWarning("Unable to read from ProjectSettings/HDRPProjectVersion.txt - Assign default version value");

// When we don't find HDRPProjectVersion file we return the current value. Because this happen when you create new project.
return hdrpVersion;
}

return int.Parse(version[0]);
Expand Down
Expand Up @@ -5,8 +5,7 @@
"com.unity.render-pipelines.core.Editor",
"com.unity.render-pipelines.high-definition.Runtime",
"com.unity.postprocessing.Runtime",
"com.unity.postprocessing.Editor",
"Unity.ShaderGraph.Editor"
"com.unity.postprocessing.Editor"
],
"optionalUnityReferences": [],
"includePlatforms": [
Expand Down
@@ -0,0 +1,33 @@
//forest-begin:

using UnityEngine.Scripting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

[AttributeUsage(AttributeTargets.Class)]
public class HDRPCallbackAttribute : PreserveAttribute {
static public void ConfigureCallbacks(Type type) {
var methodInfo = type.GetMethods(BindingFlags.Static|BindingFlags.NonPublic|BindingFlags.Public)
.Where(mi => mi.GetCustomAttributes(typeof(HDRPCallbackMethodAttribute), false).Length > 0).FirstOrDefault();

if(methodInfo != null)
methodInfo.Invoke(null, null);
}

static public void ConfigureCallbacks(IEnumerable<Type> types) {
foreach(var type in types)
ConfigureCallbacks(type);
}

static public void ConfigureAllLoadedCallbacks() {
foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies())
ConfigureCallbacks(assembly.GetTypes());
}
}

[AttributeUsage(AttributeTargets.Method)]
public class HDRPCallbackMethodAttribute : PreserveAttribute {}

//forest-end:
Expand Up @@ -3,42 +3,46 @@
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRenderPipelineAsset
m_Name: HDRenderPipelineAsset_Base
m_EditorClassIdentifier:
version: 1
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 1
enableSSR: 0
enableSSAO: 1
enableSubsurfaceScattering: 1
enableSubsurfaceScattering: 0
enableTransmission: 1
enableAtmosphericScattering: 0
enableVolumetric: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 0
enableTransparentPrepass: 1
enableDepthPrepassWithDeferredRendering: 1
enableTransparentPrepass: 0
enableMotionVectors: 1
enableObjectMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostpass: 1
enableDistortion: 1
enableObjectMotionVectors: 0
enableGBufferMotionVectors: 0
enableDBuffer: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 1
enableStereo: 1
enableAsyncCompute: 0
enableStereo: 0
enableAsyncCompute: 1
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 0
disableReflectionProbeCulling: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
Expand All @@ -49,37 +53,41 @@ MonoBehaviour:
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 0
supportSSR: 1
supportSSR: 0
supportSSAO: 1
supportSubsurfaceScattering: 1
supportForwardOnly: 0
supportSubsurfaceScattering: 0
supportOnlyForward: 0
enableUltraQualitySSS: 0
supportDBuffer: 1
supportVolumetric: 1
supportRuntimeDebugDisplay: 1
supportDBuffer: 0
supportMSAA: 0
msaaSampleCount: 1
supportMotionVectors: 1
supportStereo: 0
lightLoopSettings:
cookieSize: 128
cookieTexArraySize: 16
pointCookieSize: 512
cubeCookieTexArraySize: 16
reflectionProbeCacheSize: 128
planarReflectionProbeCacheSize: 4
cookieSize: 4
cookieTexArraySize: 1
pointCookieSize: 4
cubeCookieTexArraySize: 1
planarReflectionProbeCacheSize: 1
planarReflectionTextureSize: 4
reflectionProbeCacheSize: 32
reflectionCubemapSize: 128
planarReflectionTextureSize: 1024
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
maxPlanarReflectionProbes: 128
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 256
m_Bits: 512
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
shadowAtlasWidth: 1440
shadowAtlasHeight: 1440
shadowMap16Bit: 1
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 404820c4cf36ad944862fa59c56064f0,
drawDistance: 0
atlasWidth: 4096
atlasHeight: 4096
allowShaderVariantStripping: 1
diffusionProfileSettings: {fileID: 11400000, guid: e0168213b82c7964093d1d6f662fe219,
type: 2}
@@ -0,0 +1,93 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRenderPipelineAsset_Desktop
m_EditorClassIdentifier:
version: 1
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 0
enableSSAO: 1
enableSubsurfaceScattering: 0
enableTransmission: 1
enableAtmosphericScattering: 0
enableVolumetric: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 1
enableTransparentPrepass: 0
enableMotionVectors: 1
enableObjectMotionVectors: 0
enableGBufferMotionVectors: 1
enableDBuffer: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 1
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 0
disableReflectionProbeCulling: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 0
supportSSR: 0
supportSSAO: 1
supportSubsurfaceScattering: 0
supportOnlyForward: 0
enableUltraQualitySSS: 0
supportVolumetric: 1
supportRuntimeDebugDisplay: 1
supportDBuffer: 0
supportMSAA: 0
msaaSampleCount: 1
supportMotionVectors: 1
supportStereo: 0
lightLoopSettings:
cookieSize: 4
cookieTexArraySize: 1
pointCookieSize: 4
cubeCookieTexArraySize: 1
planarReflectionProbeCacheSize: 1
planarReflectionTextureSize: 4
reflectionProbeCacheSize: 32
reflectionCubemapSize: 128
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 512
shadowInitParams:
shadowAtlasWidth: 3072
shadowAtlasHeight: 3072
shadowMap16Bit: 1
decalSettings:
drawDistance: 0
atlasWidth: 4096
atlasHeight: 4096
allowShaderVariantStripping: 1
diffusionProfileSettings: {fileID: 11400000, guid: e0168213b82c7964093d1d6f662fe219,
type: 2}
@@ -0,0 +1,93 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRenderPipelineAsset_Enhanced
m_EditorClassIdentifier:
version: 1
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 0
enableSSAO: 1
enableSubsurfaceScattering: 0
enableTransmission: 1
enableAtmosphericScattering: 0
enableVolumetric: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 1
enableTransparentPrepass: 0
enableMotionVectors: 1
enableObjectMotionVectors: 0
enableGBufferMotionVectors: 1
enableDBuffer: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 1
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 0
disableReflectionProbeCulling: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 0
supportSSR: 0
supportSSAO: 1
supportSubsurfaceScattering: 0
supportOnlyForward: 0
enableUltraQualitySSS: 0
supportVolumetric: 1
supportRuntimeDebugDisplay: 1
supportDBuffer: 0
supportMSAA: 0
msaaSampleCount: 1
supportMotionVectors: 1
supportStereo: 0
lightLoopSettings:
cookieSize: 4
cookieTexArraySize: 1
pointCookieSize: 4
cubeCookieTexArraySize: 1
planarReflectionProbeCacheSize: 1
planarReflectionTextureSize: 4
reflectionProbeCacheSize: 32
reflectionCubemapSize: 128
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 512
shadowInitParams:
shadowAtlasWidth: 2480
shadowAtlasHeight: 2480
shadowMap16Bit: 1
decalSettings:
drawDistance: 0
atlasWidth: 4096
atlasHeight: 4096
allowShaderVariantStripping: 1
diffusionProfileSettings: {fileID: 11400000, guid: e0168213b82c7964093d1d6f662fe219,
type: 2}
@@ -1,4 +1,4 @@
// Each #kernel tells which function to compile; you can have many kernels
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel DeferredDirectionalShadow DEFERRED_DIRECTIONAL=DeferredDirectionalShadow
#pragma kernel DeferredDirectionalShadow_Contact DEFERRED_DIRECTIONAL=DeferredDirectionalShadow_Contact ENABLE_CONTACT_SHADOWS
#pragma kernel DeferredDirectionalShadow_Normals DEFERRED_DIRECTIONAL=DeferredDirectionalShadow_Normals ENABLE_NORMALS
Expand Down Expand Up @@ -137,15 +137,16 @@ void DEFERRED_DIRECTIONAL(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId
ShadowContext shadowContext = InitShadowContext();
float shadow = GetDirectionalShadowAttenuation(shadowContext, posInput.positionWS, nrm, _DirectionalShadowIndex, _LightDirection);

//forest-begin: Separate contact shadows for transmission fixes
float contactShadow = 1.0f;
#ifdef ENABLE_CONTACT_SHADOWS
float contactShadow = 1.0f;
if (_ContactShadowLength > 0.0f)
{
float4 result = ScreenSpaceShadowRayCast(posInput.positionWS, normalize(_LightDirection), _ContactShadowLength * max(0.5, posInput.linearDepth * _ContactShadowDistanceScaleFactor));
contactShadow = 1.0 - result.x * saturate((_ContactShadowFadeEnd - posInput.linearDepth) * _ContactShadowFadeOneOverRange);
shadow *= contactShadow;
}
if (_ContactShadowLength > 0.0f)
{
float4 result = ScreenSpaceShadowRayCast(posInput.positionWS, normalize(_LightDirection), _ContactShadowLength * max(0.5, posInput.linearDepth * _ContactShadowDistanceScaleFactor));
contactShadow = 1.0 - result.x * saturate((_ContactShadowFadeEnd - posInput.linearDepth) * _ContactShadowFadeOneOverRange);
}
#endif

_DeferredShadowTextureUAV[pixelCoord] = float4(shadow, 0.0, 0.0, 0.0);
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow, contactShadow, 0.0, 0.0);
//forest-end:
}
Expand Up @@ -29,6 +29,9 @@ float3 EvaluateCookie_Directional(LightLoopContext lightLoopContext, Directional
void EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInputs posInput,
DirectionalLightData lightData, BakeLightingData bakeLightingData,
float3 N, float3 L,
//forest-begin: Separate contact shadows for transmission fixes
bool litTransmission,
//forest-end:
out float3 color, out float attenuation)
{
float3 positionWS = posInput.positionWS;
Expand All @@ -55,7 +58,10 @@ void EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInputs
UNITY_BRANCH if (lightData.shadowIndex >= 0)
{
#ifdef USE_DEFERRED_DIRECTIONAL_SHADOWS
shadow = LOAD_TEXTURE2D(_DeferredShadowTexture, posInput.positionSS).x;
//forest-begin: Separate contact shadows for transmission fixes
float2 shadowData = LOAD_TEXTURE2D(_DeferredShadowTexture, posInput.positionSS).xy;
shadow = shadowData.x * (litTransmission ? 1.0 : shadowData.y);
//forest-end:
#else
shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, positionWS, N, lightData.shadowIndex, L, posInput.positionSS);
#endif
Expand Down
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering.HDPipeline.Internal;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -48,7 +48,9 @@ public ShadowSetup(RenderPipelineResources resources, ShadowInitParameters shado
atlasInit.baseInit.width = (uint)shadowInit.shadowAtlasWidth;
atlasInit.baseInit.height = (uint)shadowInit.shadowAtlasHeight;
atlasInit.baseInit.slices = 1;
//forest-begin: 16-bit shadows option
atlasInit.baseInit.shadowmapBits = 32;
//forest-end:
atlasInit.baseInit.shadowmapFormat = RenderTextureFormat.Shadowmap;
atlasInit.baseInit.samplerState = SamplerState.Default();
atlasInit.baseInit.comparisonSamplerState = ComparisonSamplerState.Default();
Expand Down Expand Up @@ -243,6 +245,48 @@ public struct LightVolumeData
public float unused2;
};

//forest-begin: Explicit reflection probe tracking
public struct VisibleReflectionProbe {
public Bounds bounds;
public Matrix4x4 localToWorld;
public Vector4 hdr;
public Vector3 center;
public float blendDistance;
public int importance;
public int boxProjection;

public Texture texture;
public ReflectionProbe probe;

public static implicit operator VisibleReflectionProbe(UnityEngine.Experimental.Rendering.VisibleReflectionProbe other) {
return new VisibleReflectionProbe {
blendDistance = other.blendDistance,
bounds = other.bounds,
boxProjection = other.boxProjection,
center = other.center,
hdr = other.hdr,
importance = other.importance,
localToWorld = other.localToWorld,
probe = other.probe,
texture = other.texture
};
}

public static implicit operator VisibleReflectionProbe(ReflectionProbe other) {
return new VisibleReflectionProbe {
blendDistance = other.blendDistance,
bounds = other.bounds,
boxProjection = other.boxProjection ? 1 : 0,
center = other.center,
hdr = other.textureHDRDecodeValues,
importance = other.importance,
localToWorld = Matrix4x4.TRS(other.transform.position, other.transform.rotation, Vector3.one),
probe = other,
texture = other.texture
};
}
}
//forest-end:
public class LightLoop
{
public enum TileClusterDebug : int
Expand Down Expand Up @@ -443,6 +487,10 @@ public enum ClusterDepthSource : int
List<int> m_ShadowRequests = new List<int>();
Dictionary<int, int> m_ShadowIndices = new Dictionary<int, int>();

//forest-begin: Explicit reflection probe tracking
List<VisibleReflectionProbe> m_VisibleReflectionProbes = new List<VisibleReflectionProbe>();
//forest-end:

void InitShadowSystem(HDRenderPipelineAsset hdAsset, ShadowSettings shadowSettings)
{
m_ShadowSetup = new ShadowSetup(hdAsset.renderPipelineResources, hdAsset.GetRenderPipelineSettings().shadowInitParams, shadowSettings, out m_ShadowMgr);
Expand Down Expand Up @@ -852,6 +900,7 @@ public bool GetDirectionalLightData(CommandBuffer cmd, ShadowSettings shadowSett
if (IsBakedShadowMaskLight(light.light))
{
directionalLightData.shadowMaskSelector[light.light.bakingOutput.occlusionMaskChannel] = 1.0f;
// TODO: make this option per light, not global
directionalLightData.nonLightmappedOnly = light.light.lightShadowCasterMode == LightShadowCasterMode.NonLightmappedOnly ? 1 : 0;
}
else
Expand Down Expand Up @@ -1231,6 +1280,7 @@ float ComputeLinearDistanceFade(float distanceToCamera, float fadeDistance)
}
}


public bool GetEnvLightData(CommandBuffer cmd, Camera camera, ProbeWrapper probe)
{
// For now we won't display real time probe when rendering one.
Expand Down Expand Up @@ -1482,8 +1532,18 @@ public bool IsBakedShadowMaskLight(Light light)
rightEyeWorldToView = WorldToViewStereo(camera, Camera.StereoscopicEye.Right);
}


//forest-begin: Explicit reflection probe tracking
m_VisibleReflectionProbes.Clear();

if(m_FrameSettings.disableReflectionProbeCulling)
foreach(var probe in HDAdditionalReflectionData.s_ActiveReflectionProbes)
m_VisibleReflectionProbes.Add(probe);

var visibleReflectionProbesCount = m_FrameSettings.disableReflectionProbeCulling ? m_VisibleReflectionProbes.Count : cullResults.visibleReflectionProbes.Count;
// Note: Light with null intensity/Color are culled by the C++, no need to test it here
if (cullResults.visibleLights.Count != 0 || cullResults.visibleReflectionProbes.Count != 0)
if (cullResults.visibleLights.Count != 0 || visibleReflectionProbesCount != 0)
//forest-end:
{
// 0. deal with shadows
{
Expand Down Expand Up @@ -1668,6 +1728,10 @@ public bool IsBakedShadowMaskLight(Light light)
{
if (GetDirectionalLightData(cmd, shadowSettings, gpuLightType, light, additionalLightData, additionalShadowData, lightIndex))
{
//forest-begin: Horrible hack for passing sun shadow index to scattering.. (TODO: cleanup, there's now an official 'sun index' tracked for deferred directional shadows)
if(directionalLightcount == 0)
Shader.SetGlobalInt("g_AtmosphericScatteringSunShadowIndex", m_lightList.directionalLights[0].shadowIndex);
//forest-end:
directionalLightcount++;

// We make the light position camera-relative as late as possible in order
Expand Down Expand Up @@ -1730,16 +1794,22 @@ public bool IsBakedShadowMaskLight(Light light)
// Redo everything but this time with envLights
int envLightCount = 0;

var totalProbes = cullResults.visibleReflectionProbes.Count + reflectionProbeCullResults.visiblePlanarReflectionProbeCount;
//forest-begin: Explicit reflection probe tracking
var totalProbes = visibleReflectionProbesCount + reflectionProbeCullResults.visiblePlanarReflectionProbeCount;
//forest-end:
int probeCount = Math.Min(totalProbes, k_MaxEnvLightsOnScreen);
sortKeys = new uint[probeCount];
sortCount = 0;

for (int probeIndex = 0, numProbes = totalProbes; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
{
if (probeIndex < cullResults.visibleReflectionProbes.Count)
//forest-begin: Explicit reflection probe tracking
if (probeIndex < visibleReflectionProbesCount)
//forest-end:
{
VisibleReflectionProbe probe = cullResults.visibleReflectionProbes[probeIndex];
//forest-begin: Explicit reflection probe tracking
VisibleReflectionProbe probe = m_FrameSettings.disableReflectionProbeCulling ? m_VisibleReflectionProbes[probeIndex] : cullResults.visibleReflectionProbes[probeIndex];
//forest-end:
HDAdditionalReflectionData additional = probe.probe.GetComponent<HDAdditionalReflectionData>();

// probe.texture can be null when we are adding a reflection probe in the editor
Expand Down Expand Up @@ -1801,7 +1871,9 @@ public bool IsBakedShadowMaskLight(Light light)
PlanarReflectionProbe planarProbe = null;
VisibleReflectionProbe probe = default(VisibleReflectionProbe);
if (listType == 0)
probe = cullResults.visibleReflectionProbes[probeIndex];
//forest-begin: Explicit reflection probe tracking
probe = m_FrameSettings.disableReflectionProbeCulling ? m_VisibleReflectionProbes[probeIndex] : cullResults.visibleReflectionProbes[probeIndex];
//forest-end:
else
planarProbe = reflectionProbeCullResults.visiblePlanarReflectionProbes[probeIndex];

Expand All @@ -1827,6 +1899,7 @@ public bool IsBakedShadowMaskLight(Light light)
}
}
}

}

int decalDatasCount = Math.Min(DecalSystem.m_DecalDatasCount, k_MaxDecalsOnScreen);
Expand Down Expand Up @@ -2510,6 +2583,7 @@ public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, DebugDispla
{
if (lightingDebug.tileClusterDebug != LightLoop.TileClusterDebug.None)
{

int w = hdCamera.actualWidth;
int h = hdCamera.actualHeight;
int numTilesX = (w + 15) / 16;
Expand Down
@@ -1,9 +1,12 @@
using UnityEngine.Serialization;
using UnityEngine.Serialization;
using UnityEngine.Experimental.Rendering.HDPipeline;

namespace UnityEngine.Experimental.Rendering
{
[RequireComponent(typeof(ReflectionProbe), typeof(MeshFilter), typeof(MeshRenderer))]
//forest-begin: Explicit reflection probe tracking
[ExecuteInEditMode]
//forest-end:
public class HDAdditionalReflectionData : MonoBehaviour
{
[HideInInspector]
Expand Down Expand Up @@ -38,5 +41,17 @@ public class HDAdditionalReflectionData : MonoBehaviour

public float sphereBlendRadiusOffset { get { return -blendDistancePositive.x; } }
public float sphereBlendNormalRadiusOffset { get { return -blendNormalDistancePositive.x; } }

//forest-begin: Explicit reflection probe tracking
static public System.Collections.Generic.List<ReflectionProbe> s_ActiveReflectionProbes = new System.Collections.Generic.List<ReflectionProbe>();

void OnEnable() {
s_ActiveReflectionProbes.Add(GetComponent<ReflectionProbe>());
}

void OnDisable() {
s_ActiveReflectionProbes.Remove(GetComponent<ReflectionProbe>());
}
//forest-end:
}
}
Expand Up @@ -141,6 +141,10 @@ VoxelLighting EvaluateVoxelLighting(LightLoopContext context, uint featureFlags,

float3 color; float attenuation;
EvaluateLight_Directional(context, posInput, light, unused, 0, L,
//forest-begin: Separate contact shadows for transmission fixes
//TODO: Should we actually care about transmissive here?
false,
//forest-end:
color, attenuation);

// Important:
Expand Down
Expand Up @@ -37,6 +37,10 @@ public enum TransmissionMode : uint
public Color scatteringDistance; // Per color channel (no meaningful units)
[ColorUsage(false, true)]
public Color transmissionTint; // HDR color
//forest-begin: Tweakable transmission
public float transmissionDirectScale;
public float transmissionIndirectScale;
//forest-end:
public TexturingMode texturingMode;
public TransmissionMode transmissionMode;
public Vector2 thicknessRemap; // X = min, Y = max (in millimeters)
Expand Down Expand Up @@ -65,6 +69,11 @@ public DiffusionProfile(string name)

scatteringDistance = Color.grey;
transmissionTint = Color.white;
//forest-begin: Tweakable transmission
transmissionDirectScale = 1f;
transmissionIndirectScale = 1f;
//forest-end:

texturingMode = TexturingMode.PreAndPostScatter;
transmissionMode = TransmissionMode.ThinObject;
thicknessRemap = new Vector2(0f, 5f);
Expand Down Expand Up @@ -366,6 +375,9 @@ public sealed class DiffusionProfileSettings : ScriptableObject
[NonSerialized] public Vector4[] worldScales; // X = meters per world unit; Y = world units per meter
[NonSerialized] public Vector4[] shapeParams; // RGB = S = 1 / D, A = filter radius
[NonSerialized] public Vector4[] transmissionTintsAndFresnel0; // RGB = color, A = fresnel0
//forest-begin: Tweakable transmission
[NonSerialized] public Vector4[] transmissionDirectAndIndirectScales; // R=transmissionDirectScale, G=transmissionIndirectScale, BA=0;
//forest-end:
[NonSerialized] public Vector4[] disabledTransmissionTintsAndFresnel0; // RGB = black, A = fresnel0 - For debug to remove the transmission
[NonSerialized] public Vector4[] filterKernels; // XY = near field, ZW = far field; 0 = radius, 1 = reciprocal of the PDF

Expand Down Expand Up @@ -409,6 +421,9 @@ void OnEnable()
ValidateArray(ref worldScales, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT);
ValidateArray(ref shapeParams, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT);
ValidateArray(ref transmissionTintsAndFresnel0, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT);
//forest-begin: Tweakable transmission
ValidateArray(ref transmissionDirectAndIndirectScales, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT);
//forest-end:
ValidateArray(ref disabledTransmissionTintsAndFresnel0, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT);
ValidateArray(ref filterKernels, DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT * DiffusionProfileConstants.SSS_N_SAMPLES_NEAR_FIELD);

Expand Down Expand Up @@ -483,6 +498,10 @@ public void UpdateCache(int p)
float fresnel0 = (profiles[p].ior - 1.0f) / (profiles[p].ior + 1.0f);
fresnel0 *= fresnel0; // square
transmissionTintsAndFresnel0[i] = new Vector4(profiles[p].transmissionTint.r * 0.25f, profiles[p].transmissionTint.g * 0.25f, profiles[p].transmissionTint.b * 0.25f, fresnel0); // Premultiplied
//forest-begin: Tweakable transmission
transmissionDirectAndIndirectScales[i] = new Vector4(profiles[p].transmissionDirectScale, profiles[p].transmissionIndirectScale, 0f, 0f);
//forest-end:

disabledTransmissionTintsAndFresnel0[i] = new Vector4(0.0f, 0.0f, 0.0f, fresnel0);

for (int j = 0, n = DiffusionProfileConstants.SSS_N_SAMPLES_NEAR_FIELD; j < n; j++)
Expand Down
Expand Up @@ -59,7 +59,15 @@ public void Initialize(CommandBuffer cmd)

if (!m_GgxIblSampleData)
{
m_GgxIblSampleData = new RenderTexture(m_GgxIblMaxSampleCount, k_GgxIblMipCountMinusOne, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
//forest-begin: XboxOne won't UAV write to a 128-bit target, so use Half instead
#if UNITY_XBOXONE
RenderTextureFormat sampleDataFormat = RenderTextureFormat.ARGBHalf;
#else
RenderTextureFormat sampleDataFormat = RenderTextureFormat.ARGBFloat;
#endif

m_GgxIblSampleData = new RenderTexture(m_GgxIblMaxSampleCount, k_GgxIblMipCountMinusOne, 0, sampleDataFormat, RenderTextureReadWrite.Linear);
//forest-end:
m_GgxIblSampleData.useMipMap = false;
m_GgxIblSampleData.autoGenerateMips = false;
m_GgxIblSampleData.enableRandomWrite = true;
Expand Down
Expand Up @@ -66,10 +66,12 @@ Shader "HDRenderPipeline/LayeredLit"
_NormalMapOS2("NormalMapOS2", 2D) = "white" {}
_NormalMapOS3("NormalMapOS3", 2D) = "white" {}

_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1
//forest-begin: More sharpness needed for scanned vegetation
_NormalScale0("_NormalScale0", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 8.0/*2.0*/)) = 1
//forest-end:

_BentNormalMap0("BentNormalMap0", 2D) = "bump" {}
_BentNormalMap1("BentNormalMap1", 2D) = "bump" {}
Expand Down Expand Up @@ -352,6 +354,10 @@ Shader "HDRenderPipeline/LayeredLit"
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

[ToggleUI] _SupportDBuffer("Support DBuffer", Float) = 1.0

//forest-begin:
[Toggle(_ENABLE_TERRAIN_MODE)] _EnableTerrainMode("Enable Terrain Mode", Float) = 0.0
//forest-end:
}

HLSLINCLUDE
Expand Down Expand Up @@ -432,6 +438,10 @@ Shader "HDRenderPipeline/LayeredLit"
#pragma shader_feature _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
#pragma shader_feature _MATERIAL_FEATURE_TRANSMISSION

//forest-begin:
#pragma shader_feature _ENABLE_TERRAIN_MODE
//forest-end:

// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE

Expand Down Expand Up @@ -530,6 +540,9 @@ Shader "HDRenderPipeline/LayeredLit"

Cull [_CullMode]
ZTest[_ZTestGBuffer]
//forest-begin: As we always use a full depth pre-pass, ZWrite is not needed here.
ZWrite [_ZWrite]
//forest-end:

Stencil
{
Expand All @@ -543,9 +556,12 @@ Shader "HDRenderPipeline/LayeredLit"

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#ifdef LIGHTMAP_ON
#define DIRLIGHTMAP_COMBINED
#endif
//#pragma multi_compile _ DIRLIGHTMAP_COMBINED
//#pragma multi_compile _ DYNAMICLIGHTMAP_ON
//#pragma multi_compile _ SHADOWS_SHADOWMASK

#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer
Expand Down Expand Up @@ -692,9 +708,12 @@ Shader "HDRenderPipeline/LayeredLit"

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#ifdef LIGHTMAP_ON
#define DIRLIGHTMAP_COMBINED
#endif
//#pragma multi_compile _ DIRLIGHTMAP_COMBINED
//#pragma multi_compile _ DYNAMICLIGHTMAP_ON
//#pragma multi_compile _ SHADOWS_SHADOWMASK
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#define LIGHTLOOP_TILE_PASS
Expand All @@ -718,5 +737,9 @@ Shader "HDRenderPipeline/LayeredLit"
}
}

//forest-begin:
Dependency "BaseMapShader" = "Hidden/Forest/Standard_Terrain_BaseMap_DeferredShading_HDRenderLoop"
//forest-end:

CustomEditor "UnityEditor.Experimental.Rendering.HDPipeline.LayeredLitGUI"
}
Expand Up @@ -488,6 +488,12 @@ float4 GetBlendMask(LayerTexCoord layerTexCoord, float4 vertexColor, bool useLod
// Value for main layer is not use for blending itself but for alternate weighting like density.
// Settings this specific Main layer blend mask in alpha allow to be transparent in case we don't use it and 1 is provide by default.
float4 blendMasks = useLodSampling ? SAMPLE_UVMAPPING_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask, lod) : SAMPLE_UVMAPPING_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask);
//forest-begin:
#ifdef _ENABLE_TERRAIN_MODE
// Terrain channels are R,G,B,A vs Layered channels A,R,G,B
blendMasks.argb = blendMasks;
#endif
//forest-end:

// Wind uses vertex alpha as an intensity parameter.
// So in case Layered shader uses wind, we need to hardcode the alpha here so that the main layer can be visible without affecting wind intensity.
Expand Down Expand Up @@ -755,6 +761,26 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.specularOcclusion = 1.0;
#endif

//forest-begin: lightmap occlusion
surfaceData.specularOcclusion = min(surfaceData.specularOcclusion, GetSpecularOcclusionFromLightmapLuminance(V, surfaceData.normalWS, input.texCoord1, input.texCoord2));
//forest-end

//forest-begin: occlusion probes
float grassOcclusion;
#ifdef _ENABLE_TERRAIN_MODE
// If it's a terrain, use the cheaper grass occlusion sampling method. It also has a separate intensity slider.
surfaceData.skyOcclusion = SampleSkyOcclusion(input.positionWS, layerTexCoord.blendMask.uv, grassOcclusion);
#else
surfaceData.skyOcclusion = SampleSkyOcclusion(input.positionWS, grassOcclusion);
#endif
//forest-end

//forest-begin: Tree Occlusion
float4 treeOcclusionInput = float4(input.texCoord2.xy, input.texCoord3.xy);
surfaceData.treeOcclusion = GetTreeOcclusion(GetAbsolutePositionWS(input.positionWS), treeOcclusionInput);
surfaceData.specularOcclusion = min(surfaceData.specularOcclusion, surfaceData.treeOcclusion);
//forest-end:

#ifndef _DISABLE_DBUFFER
AddDecalContribution(posInput, surfaceData, alpha);
#endif
Expand All @@ -772,7 +798,9 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
surfaceData.perceptualSmoothness = GeometricNormalFiltering(surfaceData.perceptualSmoothness, input.worldToTangent[2], _SpecularAAScreenSpaceVariance, _SpecularAAThreshold);
#endif

GetBuiltinData(input, surfaceData, alpha, bentNormalWS, depthOffset, builtinData);
//forest-begin: occlusion probes
GetBuiltinData(input, surfaceData, alpha, bentNormalWS, depthOffset, grassOcclusion, builtinData);
//forest-end:
}

#include "../Lit/LitDataMeshModification.hlsl"
Expand Up @@ -66,10 +66,12 @@ Shader "HDRenderPipeline/LayeredLitTessellation"
_NormalMapOS2("NormalMapOS2", 2D) = "white" {}
_NormalMapOS3("NormalMapOS3", 2D) = "white" {}

_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1
//forest-begin: More sharpness needed for scanned vegetation
_NormalScale0("_NormalScale0", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 8.0/*2.0*/)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 8.0/*2.0*/)) = 1
//forest-end:

_BentNormalMap0("BentNormalMap0", 2D) = "bump" {}
_BentNormalMap1("BentNormalMap1", 2D) = "bump" {}
Expand Down Expand Up @@ -362,6 +364,10 @@ Shader "HDRenderPipeline/LayeredLitTessellation"
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

[ToggleUI] _SupportDBuffer("Support DBuffer", Float) = 1.0

//forest-begin:
[Toggle(_ENABLE_TERRAIN_MODE)] _EnableTerrainMode("Enable Terrain Mode", Float) = 0.0
//forest-end:
}

HLSLINCLUDE
Expand Down Expand Up @@ -443,6 +449,10 @@ Shader "HDRenderPipeline/LayeredLitTessellation"
#pragma shader_feature _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
#pragma shader_feature _MATERIAL_FEATURE_TRANSMISSION

//forest-begin:
#pragma shader_feature _ENABLE_TERRAIN_MODE
//forest-end:

// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE

Expand Down Expand Up @@ -564,9 +574,12 @@ Shader "HDRenderPipeline/LayeredLitTessellation"

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#ifdef LIGHTMAP_ON
#define DIRLIGHTMAP_COMBINED
#endif
//#pragma multi_compile _ DIRLIGHTMAP_COMBINED
//#pragma multi_compile _ DYNAMICLIGHTMAP_ON
//#pragma multi_compile _ SHADOWS_SHADOWMASK

#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer
Expand Down Expand Up @@ -729,9 +742,12 @@ Shader "HDRenderPipeline/LayeredLitTessellation"

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#ifdef LIGHTMAP_ON
#define DIRLIGHTMAP_COMBINED
#endif
//#pragma multi_compile _ DIRLIGHTMAP_COMBINED
//#pragma multi_compile _ DYNAMICLIGHTMAP_ON
//#pragma multi_compile _ SHADOWS_SHADOWMASK
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
#define LIGHTLOOP_TILE_PASS
Expand All @@ -755,5 +771,9 @@ Shader "HDRenderPipeline/LayeredLitTessellation"
}
}

//forest-begin:
Dependency "BaseMapShader" = "Hidden/Forest/Standard_Terrain_BaseMap_DeferredShading_HDRenderLoop"
//forest-end:

CustomEditor "UnityEditor.Experimental.Rendering.HDPipeline.LayeredLitGUI"
}
@@ -0,0 +1,149 @@
Shader "Hidden/Forest/Standard_Terrain_BaseMap_DeferredShading_HDRenderLoop"
{
Properties
{
// Unity Terrain expects these properties:
_MainTex ("Base (RGB) Smoothness (A)", 2D) = "white" {}
_MetallicTex ("Metallic (R)", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)

// Deps
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilBits.Standard
}

HLSLINCLUDE

#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal vulkan // TEMP: until we go futher in dev
// #pragma enable_d3d11_debug_symbols

#pragma fragment TerrainSharedFrag

// Need to be define before including Material.hlsl
#define UNITY_MATERIAL_LIT

//#pragma multi_compile _ OVERRIDE_TERRAIN_PROPERTIES

//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------

#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "CoreRP/ShaderLibrary/Wind.hlsl"
#include "../../ShaderPass/FragInputs.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"

//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------

#include "../../Material/Lit/LitProperties.hlsl"
ENDHLSL

SubShader
{
Tags{
"Queue" = "Geometry-100"
"RenderType" = "Opaque"
"PerformanceChecks" = "False"
}

Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index

//Cull [_CullMode]
Stencil{ Ref[_StencilRef] Comp Always Pass Replace }

HLSLPROGRAM
#pragma vertex TerrainSharedVert

#define SHADERPASS SHADERPASS_GBUFFER

#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
//#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON

#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"

#define TERRAIN_BASEPASS 1
#include "Forest_Terrain_Shared.hlsl"

ENDHLSL
}

Pass
{
Name "GBufferDebugDisplay" // Name is not used
Tags { "LightMode" = "GBufferDebugDisplay" } // This will be only for opaque object based on the RenderQueue index

//Cull [_CullMode]
Stencil{ Ref[_StencilRef] Comp Always Pass Replace }

HLSLPROGRAM
#pragma vertex TerrainSharedVert

#define DEBUG_DISPLAY
#define SHADERPASS SHADERPASS_GBUFFER

#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
//#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON

#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugDisplay.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"

#define TERRAIN_BASEPASS 1
#include "Forest_Terrain_Shared.hlsl"

ENDHLSL
}

// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags { "LightMode" = "Meta" }

Cull Off

HLSLPROGRAM

// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.

// Use specialized vertex function
#pragma vertex Vert
//TerrainMetaVert

// Need UV2 for enlighten UVs
#define _REQUIRE_UV2

#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

#define TERRAIN_BASEPASS 1
#include "Forest_Terrain_Shared.hlsl"

ENDHLSL
}
}

//Fallback "Hidden/TerrainEngine/Splatmap/Standard-Base"
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -118,6 +118,16 @@ public struct SurfaceData
public float atDistance;
[SurfaceDataAttributes("Transmittance mask")]
public float transmittanceMask;

//forest-begin: sky occlusion
[SurfaceDataAttributes("Sky Occlusion")]
public float skyOcclusion;
//forest-end:

//forest-begin: Tree occlusion
[SurfaceDataAttributes("Tree Occlusion")]
public float treeOcclusion;
//forest-end:
};

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -178,6 +188,9 @@ public struct BSDFData
// Reuse thickness from SSS
public Vector3 absorptionCoefficient;
public float transmittanceMask;
//forest-begin: sky occlusion
public float skyOcclusion;
//forest-end:
};

//-----------------------------------------------------------------------------
Expand Down
Expand Up @@ -54,6 +54,8 @@
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_COLOR (1018)
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_ABSORPTION_DISTANCE (1019)
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_MASK (1020)
#define DEBUGVIEW_LIT_SURFACEDATA_SKY_OCCLUSION (1021)
#define DEBUGVIEW_LIT_SURFACEDATA_TREE_OCCLUSION (1022)

//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData: static fields
Expand Down Expand Up @@ -82,6 +84,7 @@
#define DEBUGVIEW_LIT_BSDFDATA_IOR (1051)
#define DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT (1052)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK (1053)
#define DEBUGVIEW_LIT_BSDFDATA_SKY_OCCLUSION (1054)

//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields
Expand Down Expand Up @@ -112,6 +115,8 @@ struct SurfaceData
float3 transmittanceColor;
float atDistance;
float transmittanceMask;
float skyOcclusion;
float treeOcclusion;
};

// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData
Expand Down Expand Up @@ -141,6 +146,7 @@ struct BSDFData
float ior;
float3 absorptionCoefficient;
float transmittanceMask;
float skyOcclusion;
};

//
Expand Down Expand Up @@ -215,6 +221,12 @@ void GetGeneratedSurfaceDataDebug(uint paramId, SurfaceData surfacedata, inout f
case DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_MASK:
result = surfacedata.transmittanceMask.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_SKY_OCCLUSION:
result = surfacedata.skyOcclusion.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_TREE_OCCLUSION:
result = surfacedata.treeOcclusion.xxx;
break;
}
}

Expand Down Expand Up @@ -298,6 +310,9 @@ void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 res
case DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK:
result = bsdfdata.transmittanceMask.xxx;
break;
case DEBUGVIEW_LIT_BSDFDATA_SKY_OCCLUSION:
result = bsdfdata.skyOcclusion.xxx;
break;
}
}

Expand Down
@@ -1,4 +1,4 @@
// SurfaceData is define in Lit.cs which generate Lit.cs.hlsl
// SurfaceData is define in Lit.cs which generate Lit.cs.hlsl
#include "Lit.cs.hlsl"
#include "../SubsurfaceScattering/SubsurfaceScattering.hlsl"
#include "CoreRP/ShaderLibrary/VolumeRendering.hlsl"
Expand All @@ -16,6 +16,10 @@ TEXTURE2D(_GBufferTexture3);
#include "../LTCAreaLight/LTCAreaLight.hlsl"
#include "../PreIntegratedFGD/PreIntegratedFGD.hlsl"

//forest-begin: sky occlusion
float _OcclusionProbesReflectionOcclusionAmount;
//forest-end:

//-----------------------------------------------------------------------------
// Definition
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -174,6 +178,7 @@ uint TileVariantToFeatureFlags(uint variant, uint tileIndex)
#define REFRACTION_MODEL(V, posInputs, bsdfData) RefractionModelPlane(V, posInputs.positionWS, bsdfData.normalWS, bsdfData.ior, bsdfData.thickness)
#elif defined(_REFRACTION_SPHERE)
#define REFRACTION_MODEL(V, posInputs, bsdfData) RefractionModelSphere(V, posInputs.positionWS, bsdfData.normalWS, bsdfData.ior, bsdfData.thickness)

#endif
#endif

Expand Down Expand Up @@ -399,6 +404,10 @@ BSDFData ConvertSurfaceDataToBSDFData(SurfaceData surfaceData)
surfaceData.thickness, surfaceData.transmittanceMask, bsdfData);
#endif

//forest-begin:
bsdfData.skyOcclusion = surfaceData.skyOcclusion;
//forest-end:

ApplyDebugToBSDFData(bsdfData);

return bsdfData;
Expand Down Expand Up @@ -563,6 +572,10 @@ void EncodeIntoGBuffer( SurfaceData surfaceData,
// Note: no need to store MATERIALFEATUREFLAGS_LIT_STANDARD, always present
outGBuffer2.a = PackFloatInt8bit(coatMask, materialFeatureId, 8);

//forest-begin: sky occlusion
outGBuffer2.a = PackFloatInt8bit(surfaceData.skyOcclusion, materialFeatureId, 8);
//forest-end

// RT3 - 11f:11f:10f
outGBuffer3 = float4(bakeDiffuseLighting, 0.0);
}
Expand Down Expand Up @@ -592,6 +605,10 @@ uint DecodeFromGBuffer(uint2 positionSS, uint tileFeatureFlags, out BSDFData bsd
float coatMask;
uint materialFeatureId;
UnpackFloatInt8bit(inGBuffer2.a, 8, coatMask, materialFeatureId);
//forest-begin: sky occlusion
coatMask = 0;
UnpackFloatInt8bit(inGBuffer2.a, 8, bsdfData.skyOcclusion, materialFeatureId);
//forest-end:

uint pixelFeatureFlags = MATERIALFEATUREFLAGS_LIT_STANDARD; // Only sky/background do not have the Standard flag.
bool pixelHasSubsurface = materialFeatureId == GBUFFER_LIT_TRANSMISSION_SSS || materialFeatureId == GBUFFER_LIT_SSS;
Expand Down Expand Up @@ -1224,6 +1241,10 @@ void BSDF( float3 V, float3 L, float NdotL, float3 positionWS, PreLightData pre
// Very coarse attempt at doing energy conservation for the diffuse layer based on NdotL. No science.
diffuseLighting *= lerp(1, 1.0 - coatF, bsdfData.coatMask);
}

//forest-begin: lightmap occlusion
specularLighting *= lerp(1.f, bsdfData.specularOcclusion, _LightmapOcclusionScalePowerReflStrengthSpecStrength.w);
//forest-end:
}

// Currently, we only model diffuse transmission. Specular transmission is not yet supported.
Expand All @@ -1249,6 +1270,13 @@ float3 EvaluateTransmission(BSDFData bsdfData, float3 transmittance, float NdotL
#endif

float intensity = attenuation * wrappedNdotL;

//forest-begin: Tweakable transmission
//forest-begin: Specular occlusion on transmission (custom shader parity)
intensity *= _TransmissionDirectAndIndirectScales[bsdfData.diffusionProfile].r * bsdfData.specularOcclusion;
//forest-end:
//forest-end:

return intensity * transmittance;
}

Expand All @@ -1272,7 +1300,10 @@ DirectLighting EvaluateBSDF_Directional(LightLoopContext lightLoopContext,

float3 color;
float attenuation;
EvaluateLight_Directional(lightLoopContext, posInput, lightData, bakeLightingData, N, L, color, attenuation);
//forest-begin: Separate contact shadows for transmission fixes
bool isTransmissive = HasFeatureFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_TRANSMISSION) && any(bsdfData.transmittance > 0.0);
EvaluateLight_Directional(lightLoopContext, posInput, lightData, bakeLightingData, N, L, isTransmissive, color, attenuation);
//forest-end:

float intensity = max(0, attenuation * NdotL); // Warning: attenuation can be greater than 1 due to the inverse square attenuation (when position is close to light)

Expand Down Expand Up @@ -1780,7 +1811,9 @@ IndirectLighting EvaluateBSDF_SSLighting(LightLoopContext lightLoopContext,
float3 rayOriginWS = float3(0, 0, 0);
float3 rayDirWS = float3(0, 0, 0);
float mipLevel = 0;
#if DEBUG_DISPLAY
//forest-begin: ifdef instead of if
#ifdef DEBUG_DISPLAY
//forest-end:
int debugMode = 0;
#endif
float invScreenWeightDistance = 0;
Expand All @@ -1800,7 +1833,9 @@ IndirectLighting EvaluateBSDF_SSLighting(LightLoopContext lightLoopContext,
rayDirWS = preLightData.transparentRefractV;
mipLevel = preLightData.transparentSSMipLevel;
invScreenWeightDistance = _SSRefractionInvScreenWeightDistance;
#if DEBUG_DISPLAY
//forest-begin: ifdef instead of if
#ifdef DEBUG_DISPLAY
//forest-end:
debugMode = DEBUGLIGHTINGMODE_SCREEN_SPACE_TRACING_REFRACTION;
#endif
}
Expand All @@ -1812,12 +1847,16 @@ IndirectLighting EvaluateBSDF_SSLighting(LightLoopContext lightLoopContext,
rayDirWS = preLightData.iblR;
mipLevel = PositivePow(preLightData.iblPerceptualRoughness, 0.8) * uint(max(_ColorPyramidScale.z - 1, 0));
invScreenWeightDistance = _SSReflectionInvScreenWeightDistance;
#if DEBUG_DISPLAY
//forest-begin: ifdef instead of if
#ifdef DEBUG_DISPLAY
//forest-end:
debugMode = DEBUGLIGHTINGMODE_SCREEN_SPACE_TRACING_REFLECTION;
#endif
}

#if DEBUG_DISPLAY
//forest-begin: ifdef instead of if
#ifdef DEBUG_DISPLAY
//forest-end:
bool debug = _DebugLightingMode == debugMode
&& !any(int2(_MouseClickPixelCoord.xy) - int2(posInput.positionSS));
#endif
Expand Down Expand Up @@ -1865,7 +1904,9 @@ IndirectLighting EvaluateBSDF_SSLighting(LightLoopContext lightLoopContext,
// Jitter the ray origin to trade some noise instead of banding effect
ssRayInput.rayOriginWS = rayOriginWS + rayDirWS * SampleBayer4(posInput.positionSS + uint2(_FrameCount, uint(_FrameCount) / 4u)) * 0.1;
ssRayInput.rayDirWS = rayDirWS;
#if DEBUG_DISPLAY
//forest-begin: ifdef instead of if
#ifdef DEBUG_DISPLAY
//forest-end:
ssRayInput.debug = debug;
#endif

Expand Down Expand Up @@ -2072,24 +2113,35 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
EvaluateLight_EnvIntersection(positionWS, bsdfData.normalWS, lightData, influenceShapeType, coatR, unusedWeight);
}


float3 F = preLightData.specularFGD;

float iblMipLevel;
// TODO: We need to match the PerceptualRoughnessToMipmapLevel formula for planar, so we don't do this test (which is specific to our current lightloop)
// Specific case for Texture2Ds, their convolution is a gaussian one and not a GGX one - So we use another roughness mip mapping.
//forest-begin:
#if !defined(SHADER_API_METAL)
//forest-end:
if (IsEnvIndexTexture2D(lightData.envIndex))
{
// Empirical remapping
iblMipLevel = PositivePow(preLightData.iblPerceptualRoughness, 0.8) * uint(max(_ColorPyramidScale.z - 1, 0));
}
else
//forest-begin:
#endif
//forest-end:
{
iblMipLevel = PerceptualRoughnessToMipmapLevel(preLightData.iblPerceptualRoughness);
}

float4 preLD = SampleEnv(lightLoopContext, lightData.envIndex, R, iblMipLevel);
weight *= preLD.a; // Used by planar reflection to discard pixel

//forest-begin: sky occlusion
preLD *= lerp(1.0, bsdfData.skyOcclusion, _OcclusionProbesReflectionOcclusionAmount);
//forest-end:

if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION)
{
envLighting = F * preLD.rgb;
Expand Down