浏览代码
Merge pull request #1225 from EvgeniiG/master
Merge pull request #1225 from EvgeniiG/master
Port global density volumes to the interpolation volume framework (+ misc improvements)/main
GitHub
7 年前
当前提交
3a0290a2
共有 24 个文件被更改,包括 548 次插入 和 333 次删除
-
7ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/GeometricTools.hlsl
-
7ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
-
22ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Sampling/Sampling.hlsl
-
6ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/SpaceFillingCurves.hlsl
-
11ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/VolumeRendering.hlsl
-
21ScriptableRenderPipeline/Core/CoreRP/Volume/VolumeComponent.cs
-
16ScriptableRenderPipeline/Core/CoreRP/Volume/VolumeManager.cs
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Sky/AtmosphericScattering/ExponentialFogEditor.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
-
37ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs
-
187ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VBuffer.hlsl
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute
-
160ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.compute
-
167ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.compute
-
27ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/AtmosphericScattering.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/AtmosphericScattering.cs.hlsl
-
59ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/AtmosphericScattering.hlsl
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/OpaqueAtmosphericScattering.shader
-
14ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/VisualEnvironment.cs
-
34ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Sky/AtmosphericScattering/VolumetricFogEditor.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Sky/AtmosphericScattering/VolumetricFogEditor.cs.meta
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/VolumetricFog.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/VolumetricFog.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEditor.Experimental.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[VolumeComponentEditor(typeof(VolumetricFog))] |
|||
public class VolumetricFogEditor : AtmosphericScatteringEditor |
|||
{ |
|||
private SerializedDataParameter m_Albedo; |
|||
private SerializedDataParameter m_MeanFreePath; |
|||
private SerializedDataParameter m_Asymmetry; |
|||
|
|||
public override void OnEnable() |
|||
{ |
|||
base.OnEnable(); |
|||
var o = new PropertyFetcher<VolumetricFog>(serializedObject); |
|||
|
|||
m_Albedo = Unpack(o.Find(x => x.albedo)); |
|||
m_MeanFreePath = Unpack(o.Find(x => x.meanFreePath)); |
|||
m_Asymmetry = Unpack(o.Find(x => x.asymmetry)); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
PropertyField(m_Albedo); |
|||
PropertyField(m_MeanFreePath); |
|||
PropertyField(m_Asymmetry); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a530ef8d0c07494409d34294d8e04a89 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class VolumetricFog : AtmosphericScattering |
|||
{ |
|||
public ColorParameter albedo = new ColorParameter(new Color(0.5f, 0.5f, 0.5f)); |
|||
public MinFloatParameter meanFreePath = new MinFloatParameter(float.MaxValue, 1.0f); |
|||
public ClampedFloatParameter asymmetry = new ClampedFloatParameter(0.0f, -1.0f, 1.0f); |
|||
|
|||
// Override the volume blending function.
|
|||
public override void Override(VolumeComponent state, float interpFactor) |
|||
{ |
|||
VolumetricFog other = state as VolumetricFog; |
|||
|
|||
float thisExtinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(meanFreePath); |
|||
Vector3 thisScattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(thisExtinction, (Vector3)(Vector4)albedo.value); |
|||
|
|||
float otherExtinction = VolumeRenderingUtils.ExtinctionFromMeanFreePath(other.meanFreePath); |
|||
Vector3 otherScattering = VolumeRenderingUtils.ScatteringFromExtinctionAndAlbedo(otherExtinction, (Vector3)(Vector4)other.albedo.value); |
|||
|
|||
float blendExtinction = Mathf.Lerp(otherExtinction, thisExtinction, interpFactor); |
|||
Vector3 blendScattering = Vector3.Lerp(otherScattering, thisScattering, interpFactor); |
|||
float blendAsymmetry = Mathf.Lerp(other.asymmetry, asymmetry, interpFactor); |
|||
|
|||
float blendMeanFreePath = VolumeRenderingUtils.MeanFreePathFromExtinction(blendExtinction); |
|||
Color blendAlbedo = (Color)(Vector4)VolumeRenderingUtils.AlbedoFromMeanFreePathAndScattering(blendMeanFreePath, blendScattering); |
|||
blendAlbedo.a = 1.0f; |
|||
|
|||
if (meanFreePath.overrideState) |
|||
{ |
|||
other.meanFreePath.value = blendMeanFreePath; |
|||
} |
|||
|
|||
if (albedo.overrideState) |
|||
{ |
|||
other.albedo.value = blendAlbedo; |
|||
} |
|||
|
|||
if (asymmetry.overrideState) |
|||
{ |
|||
other.asymmetry.value = blendAsymmetry; |
|||
} |
|||
} |
|||
|
|||
public override void PushShaderParameters(CommandBuffer cmd, FrameSettings frameSettings) |
|||
{ |
|||
DensityVolumeParameters param; |
|||
|
|||
param.albedo = albedo; |
|||
param.meanFreePath = meanFreePath; |
|||
param.asymmetry = asymmetry; |
|||
|
|||
DensityVolumeData data = param.GetData(); |
|||
|
|||
cmd.SetGlobalInt(HDShaderIDs._AtmosphericScatteringType, (int)FogType.Volumetric); |
|||
|
|||
cmd.SetGlobalVector(HDShaderIDs._GlobalScattering, data.scattering); |
|||
cmd.SetGlobalFloat( HDShaderIDs._GlobalExtinction, data.extinction); |
|||
cmd.SetGlobalFloat( HDShaderIDs._GlobalAsymmetry, asymmetry); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 29b00527f85bb3346a4d2cb710971587 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue