浏览代码

[PlanarReflection] Fixed sampling on invalid direction

/main
Frédéric Vauchelles 7 年前
当前提交
3811cdc8
共有 7 个文件被更改,包括 160 次插入21 次删除
  1. 157
      SampleScenes/HDTest/PlanarReflectionTests.unity
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs
  3. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs.hlsl
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  5. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  6. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtilities.hlsl
  7. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

157
SampleScenes/HDTest/PlanarReflectionTests.unity


m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
m_IsActive: 0
--- !u!4 &547467866
Transform:
m_ObjectHideFlags: 0

m_Mode: 1
m_RefreshMode: 1
m_TimeSlicingMode: 0
m_Resolution: 512
m_Resolution: 128
m_UpdateFrequency: 0
m_BoxSize: {x: 20.1, y: 10.1, z: 20.1}
m_BoxOffset: {x: 0, y: 2, z: 0}

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 556113917}
m_LocalRotation: {x: -0, y: 0.7071066, z: -0, w: -0.70710707}
m_LocalPosition: {x: 0.853, y: 2.603, z: -0.037}
m_LocalScale: {x: 2.826485, y: 3, z: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.49763617, z: 0.016519075}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Father: {fileID: 1233674353}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 270, z: 0}
m_Father: {fileID: 1006218567}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -0.634, y: 270, z: 0}
--- !u!23 &556113919
MeshRenderer:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 599505012}
m_LocalRotation: {x: -0, y: 0.7071066, z: -0, w: -0.70710707}
m_LocalPosition: {x: 0.564, y: 2.603, z: -0.037}
m_LocalScale: {x: 1.95, y: 2.73, z: 1.0000005}
m_LocalPosition: {x: 0.943, y: 2.603, z: -0.037}
m_LocalScale: {x: 1.81, y: 1.93, z: 1.6271425}
m_Children: []
m_Father: {fileID: 1233674353}
m_RootOrder: 4

m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &713763938
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 713763939}
- component: {fileID: 713763942}
- component: {fileID: 713763941}
- component: {fileID: 713763940}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &713763939
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 713763938}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.635, y: 1.064, z: 3.75}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1306845494}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &713763940
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 713763938}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &713763941
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 713763938}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &713763942
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 713763938}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &743933947
GameObject:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 971539802}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1006218566
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1006218567}
m_Layer: 8
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1006218567
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1006218566}
m_LocalRotation: {x: 0, y: 0.7071068, z: -0, w: -0.7071068}
m_LocalPosition: {x: 0.776, y: 1.11, z: -0.037}
m_LocalScale: {x: 2.826485, y: 3, z: 1}
m_Children:
- {fileID: 556113918}
m_Father: {fileID: 1233674353}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 270, z: 0}
--- !u!1 &1046252900
GameObject:
m_ObjectHideFlags: 0

- {fileID: 605786283}
- {fileID: 2037444866}
- {fileID: 1927838485}
- {fileID: 556113918}
- {fileID: 1006218567}
- {fileID: 599505013}
- {fileID: 1250450217}
- {fileID: 1561776758}

- {fileID: 1192322822}
- {fileID: 1179256903}
- {fileID: 1596124444}
- {fileID: 713763939}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1561776757}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.8410001, y: 2.751, z: -0.10100007}
m_LocalPosition: {x: -0.238, y: 2.751, z: -0.10100007}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1233674353}

m_ProxyVolumeReference: {fileID: 1654939277}
m_InfluenceVolume:
m_ShapeType: 0
m_BoxBaseSize: {x: 0.93428564, y: 3.2606697, z: 3.1991441}
m_BoxBaseOffset: {x: 0.15518641, y: -0.14608002, z: 0.078737855}
m_BoxBaseSize: {x: 3.1368604, y: 3.2606697, z: 3.1991441}
m_BoxBaseOffset: {x: 1.2564738, y: -0.14608002, z: 0.078737855}
m_BoxInfluenceNormalNegativeFade: {x: 0, y: 0, z: 0}
m_BoxInfluenceNormalNegativeFade: {x: 0.378016, y: 0, z: 0}
m_BoxPositiveFaceFade: {x: 1, y: 1, z: 1}
m_BoxNegativeFaceFade: {x: 1, y: 1, z: 1}
m_SphereBaseRadius: 1.0270488

m_CaptureLocalPosition: {x: 0.30307975, y: 0.18300438, z: 4.7699223}
m_CaptureLocalPosition: {x: -6.6053805, y: 0.18300438, z: 0.5463939}
m_Dimmer: 1
m_Mode: 1
m_RefreshMode: 1

enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
m_CaptureNearPlane: 4.25
m_CaptureFarPlane: 98.64
m_CaptureNearPlane: 1.3
m_CaptureFarPlane: 27.85
m_CaptureMirrorPlaneLocalPosition: {x: 0, y: 0, z: 0}
m_CaptureMirrorPlaneLocalPosition: {x: 1.0212841, y: 0, z: 0}
m_FieldOfViewOverride: 90
m_FieldOfViewOverride: 132.2
--- !u!1 &1562837666
GameObject:
m_ObjectHideFlags: 0

stationaryBlending: 0.95
motionBlending: 0.85
fastApproximateAntialiasing:
mobileOptimized: 0
fastMode: 0
keepAlpha: 0
fog:
enabled: 1

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs


public float unused6;
public Vector3 boxSideFadeNegative; //-X,-Y,-Z
public float unused7;
public Vector3 sampleDirectionDiscardWS;
public float unused9;
};
[GenerateHLSL]

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs.hlsl


float unused6;
float3 boxSideFadeNegative;
float unused7;
float3 sampleDirectionDiscardWS;
float unused9;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.EnvProxyData

float GetUnused7(EnvLightData value)
{
return value.unused7;
}
float3 GetSampleDirectionDiscardWS(EnvLightData value)
{
return value.sampleDirectionDiscardWS;
}
float GetUnused9(EnvLightData value)
{
return value.unused9;
}
//

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


var capturePosition = Vector3.zero;
var influenceToWorld = probe.influenceToWorld;
var sampleDirectionDiscardWS = Vector3.zero;
// 31 bits index, 1 bit cache type
var envIndex = -1;
switch (probe.texture.dimension)

// We transform it to object space by translating the capturePosition
var vp = gpuProj * gpuView * Matrix4x4.Translate(capturePosition);
m_Env2DCaptureVP.Add(vp);
sampleDirectionDiscardWS = captureRotation * Vector3.forward;
break;
}
case TextureDimension.Cube:

envLightData.blendDistanceNegative = probe.blendDistanceNegative;
envLightData.boxSideFadePositive = probe.boxSideFadePositive;
envLightData.boxSideFadeNegative = probe.boxSideFadeNegative;
envLightData.sampleDirectionDiscardWS = sampleDirectionDiscardWS;
envLightData.right = influenceToWorld.GetColumn(0).normalized;
envLightData.up = influenceToWorld.GetColumn(1).normalized;

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


if (_DebugLightingMode == DEBUGLIGHTINGMODE_ENVIRONMENT_PROXY_VOLUME)
return ApplyDebugProjectionVolume(color, texCoord, _DebugEnvironmentProxyDepthScale);
#endif
/*return float4(
(ndc.xyz > 0.5) * 0.5 + color.rgb * 0.5,
color.a);*/
return color;
}
else if (cacheType == ENVCACHETYPE_CUBEMAP)

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtilities.hlsl


output.boxSideFadePositive = float3(0.0, 0.0, 0.0);
output.boxSideFadeNegative = float3(0.0, 0.0, 0.0);
output.dimmer = 1.0;
output.sampleDirectionDiscardWS = float3(0.0, 0.0, 0.0);
return output;
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


float roughness = PerceptualRoughnessToRoughness(preLightData.iblPerceptualRoughness);
R = lerp(R, preLightData.iblR, saturate(smoothstep(0, 1, roughness * roughness)));
if (dot(lightData.sampleDirectionDiscardWS, R) < 0)
return lighting;
float3 F = preLightData.specularFGD;
float iblMipLevel = PerceptualRoughnessToMipmapLevel(preLightData.iblPerceptualRoughness);

正在加载...
取消
保存