浏览代码

intermediate commit, switching to another branch

/main
Paul Melamed 6 年前
当前提交
cf795cc1
共有 5 个文件被更改,包括 40 次插入30 次删除
  1. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  2. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  3. 43
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl
  5. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalUtilities.hlsl

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


cmd.ClearRandomWriteTargets();
}
public void SetHTileTexture(CommandBuffer cmd)
{
cmd.SetGlobalTexture(HDShaderIDs._DecalHTileTexture, m_HTileRT);
}
public void Resize(HDCamera camera)
{
CoreUtils.ResizeHTile(ref m_HTile, ref m_HTileRT, camera.renderTextureDesc);

RenderDBuffer(hdCamera, renderContext, cmd);
m_LightLoop.UpdateDataBuffers();
RenderGBuffer(m_CullResults, hdCamera, renderContext, cmd);
// In both forward and deferred, everything opaque should have been rendered at this point so we can safely copy the depth buffer for later processing.

{
// setup GBuffer for rendering
CoreUtils.SetRenderTarget(cmd, m_GbufferManager.GetGBuffers(), m_CameraDepthStencilBufferRT);
if (m_FrameSettings.enableDBuffer)
{
m_DbufferManager.SetHTile(m_GbufferManager.gbufferCount, cmd);
}
// Render opaque objects into GBuffer
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled())

// No depth prepass, use regular depth test - Note that we will render opaque then opaque alpha tested (based on the RenderQueue system)
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.s_GBufferName, m_currentRendererConfigurationBakedLighting, HDRenderQueue.k_RenderQueue_AllOpaque, m_DepthStateOpaque);
}
}
if (m_FrameSettings.enableDBuffer)
{
m_DbufferManager.UnSetHTile(cmd);
}
}
}

m_DbufferManager.SetHTile(m_DbufferManager.dbufferCount, cmd);
DecalSystem.instance.Render(renderContext, camera, cmd, m_LightLoop);
m_DbufferManager.UnSetHTile(cmd);
m_DbufferManager.SetHTileTexture(cmd);
}
}

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _HTile = Shader.PropertyToID("_HTile");
public static readonly int _SSSHTile = Shader.PropertyToID("_SSSHTile");
public static readonly int _DecalHTileTexture = Shader.PropertyToID("_DecalHTileTexture");
public static readonly int _StencilTexture = Shader.PropertyToID("_StencilTexture");
public static readonly int _ViewMatrix = Shader.PropertyToID("_ViewMatrix");

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


public List<SFiniteLightBound> bounds;
public List<LightVolumeData> lightVolumes;
public int decalCount;
public void Clear()
{

shadows.Clear();
decalCount = 0;
bounds.Clear();
lightVolumes.Clear();

lights = new List<LightData>();
envLights = new List<EnvLightData>();
shadows = new List<ShadowData>();
decalCount = 0;
bounds = new List<SFiniteLightBound>();
lightVolumes = new List<LightVolumeData>();

envLightData.proxyPositionWS = proxyToWorld.GetColumn(3);
m_lightList.envLights.Add(envLightData);
return true;
}

var lightVolumeData = new LightVolumeData();
var yExtent = decalToWorld.GetColumn(1) * 0.5f; // because of how decal mesh is defined Y is not centered, but rather covers a full extent
var influenceX = decalToWorld.GetColumn(0) * 0.5f;
var influenceY = decalToWorld.GetColumn(1) * 0.5f;
var influenceZ = decalToWorld.GetColumn(2) * 0.5f;
var pos = decalToWorld.GetColumn(3) - influenceY; // decal cube mesh pivot is at 0,0,0, with bottom face at -1 on the y plane
Vector3 influenceExtents = new Vector3();
influenceExtents.x = influenceX.magnitude;
influenceExtents.y = influenceY.magnitude;
influenceExtents.z = influenceZ.magnitude;
var influenceRightVS = worldToView.MultiplyVector(decalToWorld.GetColumn(0));
var influenceUpVS = worldToView.MultiplyVector(yExtent);
var influenceForwardVS = worldToView.MultiplyVector(decalToWorld.GetColumn(2));
var influencePositionVS = worldToView.MultiplyPoint(decalToWorld.GetColumn(3) + yExtent); // place the mesh pivot in the center
var influenceExtents = influenceRightVS + influenceUpVS + influenceForwardVS;
influenceExtents.x = Mathf.Abs(influenceExtents.x);
influenceExtents.y = Mathf.Abs(influenceExtents.y);
influenceExtents.z = Mathf.Abs(influenceExtents.z);
var influenceRightVS = worldToView.MultiplyVector(influenceX / influenceExtents.x);
var influenceUpVS = worldToView.MultiplyVector(influenceY / influenceExtents.y);
var influenceForwardVS = worldToView.MultiplyVector(influenceZ / influenceExtents.z);
var influencePositionVS = worldToView.MultiplyPoint(pos); // place the mesh pivot in the center
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Area;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Env;
bound.boxAxisX = influenceRightVS;
bound.boxAxisY = influenceUpVS;
bound.boxAxisZ = influenceForwardVS;
bound.boxAxisX = influenceRightVS * influenceExtents.x;
bound.boxAxisY = influenceUpVS * influenceExtents.y;
bound.boxAxisZ = influenceForwardVS * influenceExtents.z;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = influenceExtents.magnitude;

lightVolumeData.lightAxisZ = influenceForwardVS;
lightVolumeData.boxInnerDist = influenceExtents - k_BoxCullingExtentThreshold;
lightVolumeData.boxInvRange.Set(1.0f / k_BoxCullingExtentThreshold.x, 1.0f / k_BoxCullingExtentThreshold.y, 1.0f / k_BoxCullingExtentThreshold.z);
m_lightList.lightVolumes.Add(lightVolumeData);
m_lightList.lightVolumes.Add(lightVolumeData);
m_lightCount++;
}
public void GetEnvLightVolumeDataAndBound(ProbeWrapper probe, LightVolumeType lightVolumeType, Matrix4x4 worldToView)

Debug.Assert(m_lightList.bounds.Count == m_lightCount);
Debug.Assert(m_lightList.lightVolumes.Count == m_lightCount);
UpdateDataBuffers();
// UpdateDataBuffers();
m_maxShadowDistance = shadowSettings.maxShadowDistance;

PushGlobalParams(camera, cmd);
}
private void UpdateDataBuffers()
public void UpdateDataBuffers()
{
s_DirectionalLightDatas.SetData(m_lightList.directionalLights);
s_LightDatas.SetData(m_lightList.lights);

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl


UNITY_INSTANCING_BUFFER_END(matrix)
RW_TEXTURE2D(float, _DecalHTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
TEXTURE2D(_DecalHTileTexture);
// Must be in sync with RT declared in HDRenderPipeline.cs ::Rebuild
void EncodeIntoDBuffer( DecalSurfaceData surfaceData,

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalUtilities.hlsl


// the code in the macros, gets moved inside the conditionals by the compiler
FETCH_DBUFFER(DBuffer, _DBufferTexture, unPositionSS);
DecalSurfaceData decalSurfaceData;
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
uint mask = UnpackByte(_DecalHTile[unPositionSS / 8]);
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
//uint mask = UnpackByte(_DecalHTile[unPositionSS / 8]);
uint mask = UnpackByte(LOAD_TEXTURE2D(_DecalHTileTexture, unPositionSS / 8));
// using alpha compositing https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch23.html
if(mask & DBUFFERHTILEBIT_DIFFUSE)

正在加载...
取消
保存