Skip to content

Implement Constant Buffers for HDRP (part 2) #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 118 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
dc5f783
Fixed execution error without raytracing
JulienIgnace-Unity Nov 26, 2019
3d86f9e
Prepare Prepass refacto
JulienIgnace-Unity Nov 26, 2019
e91a1f0
Another round of preparation
JulienIgnace-Unity Nov 27, 2019
6f16b8a
Renamed XRPassScope to XRSinglePassScope
JulienIgnace-Unity Nov 27, 2019
13617b1
RenderAfterPostProcess is now static
JulienIgnace-Unity Nov 27, 2019
53e4a0e
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Nov 27, 2019
5b13043
Merge branch 'HDRP/rendergraph-update' of https://github.com/Unity-Te…
JulienIgnace-Unity Nov 27, 2019
0e7152c
Add AfterPostProcess to RenderGraph (WIP)
JulienIgnace-Unity Nov 27, 2019
f81dd5b
AfterPostProcess implementation
JulienIgnace-Unity Nov 28, 2019
d36bccf
Fixed wrong RTHandle allocation
JulienIgnace-Unity Nov 28, 2019
dd614e6
Fixed light layers texture binding during deferred lighting pass
JulienIgnace-Unity Nov 28, 2019
7bcda45
Implemented Post Process Final Pass with RenderGraph
JulienIgnace-Unity Nov 28, 2019
ee57823
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Feb 3, 2020
9b45bac
Post merge fixes
JulienIgnace-Unity Feb 10, 2020
6676461
Fixed some issues with missing buffers in SSS and deferred lighting c…
JulienIgnace-Unity Feb 11, 2020
5c7becf
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Feb 11, 2020
40d7d37
Fixed alpha in post processes
JulienIgnace-Unity Feb 11, 2020
3fc77fa
Removed RenderGraphResource and RenderGraphMutableResource in favor o…
JulienIgnace-Unity Feb 13, 2020
b2de439
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Feb 24, 2020
9f1d7c3
Merge branch 'HDRP/rendergraph-postprocess' of https://github.com/Uni…
JulienIgnace-Unity Feb 25, 2020
d5696ff
Fixed decal normal patch pass
JulienIgnace-Unity Feb 25, 2020
6a15b4b
Fixed stencil resolve render pass
JulienIgnace-Unity Feb 25, 2020
45ce8c0
Fixed RenderDBuffer render pass function capturing variables.
JulienIgnace-Unity Feb 25, 2020
346618c
Fixed wrong variable capture and restored ClearLightList to the rende…
JulienIgnace-Unity Feb 25, 2020
34240cd
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Feb 27, 2020
e7461e6
Various fixes of things that diverged compared to regular path.
JulienIgnace-Unity Mar 3, 2020
639ac4b
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 3, 2020
54171b8
Merge branch 'HDRP/rendergraph-postprocess' of https://github.com/Uni…
JulienIgnace-Unity Mar 3, 2020
9960b20
Unified renderer list and texture invalid handle error.
JulienIgnace-Unity Mar 3, 2020
ea729c3
Revert wrong change
JulienIgnace-Unity Mar 4, 2020
afa9870
Added constant buffer hlsl generation
JulienIgnace-Unity Mar 4, 2020
7410584
Changed UnityGlobal constant buffers to ShaderVariablesGlobals and ge…
JulienIgnace-Unity Mar 4, 2020
238b7ab
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 5, 2020
7129c81
post merge fix
JulienIgnace-Unity Mar 5, 2020
502b3a7
Removed useless comment.
JulienIgnace-Unity Mar 5, 2020
49fd96f
Missing doc
JulienIgnace-Unity Mar 5, 2020
33683f3
Merge branch 'HDRP/rendergraph-cleanup' of https://github.com/Unity-T…
JulienIgnace-Unity Mar 5, 2020
4aec3b9
Started moving cmd.SetGlobalXXX to update the global CB (WIP)
JulienIgnace-Unity Mar 5, 2020
8006917
Implemented Volumetrics global CB and various fixes.
JulienIgnace-Unity Mar 6, 2020
b88911c
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 6, 2020
8939e9f
Implemented shadow global CB update.
JulienIgnace-Unity Mar 6, 2020
ef1c880
Finished up Global Constant Buffer setup
JulienIgnace-Unity Mar 6, 2020
8f78984
Fix null ref
JulienIgnace-Unity Mar 6, 2020
e5f1e0a
Fixed global constant buffer alignment issues.
JulienIgnace-Unity Mar 9, 2020
3e83e64
Fixed shadows and SSS
JulienIgnace-Unity Mar 10, 2020
e30a677
Small ConstantBuffer API refacto
JulienIgnace-Unity Mar 10, 2020
770039e
Small fix
JulienIgnace-Unity Mar 10, 2020
7bfafa8
Volumetric Constant Buffer implementation + Fix
JulienIgnace-Unity Mar 10, 2020
d542112
Fix ambient occlusion
JulienIgnace-Unity Mar 10, 2020
89fe0b6
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 11, 2020
5a75d00
Removed redundant SetGlobalXXX
JulienIgnace-Unity Mar 11, 2020
5f79288
Light list build global CB implementation
JulienIgnace-Unity Mar 12, 2020
f6a8ab6
Fixed path tracing frame index constant
JulienIgnace-Unity Mar 13, 2020
1a36c4c
Fixed ao constant w/ raytracing
JulienIgnace-Unity Mar 13, 2020
6bbeaa1
Better path tracing fix.
JulienIgnace-Unity Mar 13, 2020
3d427b8
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 13, 2020
11fd3d4
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 19, 2020
75c2096
Refactored CB API to comply with Render Graph specificities
JulienIgnace-Unity Mar 19, 2020
c7d1732
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 20, 2020
1a00f9a
Update test screenshot
JulienIgnace-Unity Mar 20, 2020
235415e
Fixed constant buffer generation to use macros.
JulienIgnace-Unity Mar 20, 2020
f839e59
Implemented XR global constant buffer.
JulienIgnace-Unity Mar 20, 2020
165ebba
Removed useless global constant
JulienIgnace-Unity Mar 20, 2020
c228d3f
Fixed XR global constant name
JulienIgnace-Unity Mar 20, 2020
3d4d4a5
Converted SSR to constant buffer.
JulienIgnace-Unity Mar 23, 2020
b9b08a6
Converted AO to constant buffers.
JulienIgnace-Unity Mar 23, 2020
0a6be8a
Fixed warning
JulienIgnace-Unity Mar 23, 2020
233d32c
Removed some useless SetGlobalXXX in Light Cookie Manager
JulienIgnace-Unity Mar 23, 2020
049a421
Converted debug display to use constant buffer.
JulienIgnace-Unity Mar 23, 2020
e963cd7
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 23, 2020
21600ed
Fixed color/depth pyramid debug
JulienIgnace-Unity Mar 23, 2020
3a9dcf1
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Mar 23, 2020
5535110
Cleanup
JulienIgnace-Unity Mar 23, 2020
d7bc0b3
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Mar 23, 2020
e1ab625
Implemented constant buffer for PBR sky global variables.
JulienIgnace-Unity Mar 23, 2020
264e67f
Warning fix
JulienIgnace-Unity Mar 23, 2020
9887cf5
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 24, 2020
8cf7863
Small fix
JulienIgnace-Unity Mar 24, 2020
ede11d2
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Mar 24, 2020
4c761a4
Cleanup of global setup happening before rendering (render graph path…
JulienIgnace-Unity Mar 24, 2020
736b03a
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 24, 2020
6b6e588
Post merge fix
JulienIgnace-Unity Mar 24, 2020
33f3c72
Added global constant buffer hlsl generation.
JulienIgnace-Unity Mar 25, 2020
48708eb
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Mar 25, 2020
5499ad1
Post merge fix
JulienIgnace-Unity Mar 25, 2020
eac25c5
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Mar 26, 2020
fdca802
Post merge fix
JulienIgnace-Unity Mar 26, 2020
50cacc9
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Mar 26, 2020
5c14fdd
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Apr 2, 2020
bca3833
Post merge fix
JulienIgnace-Unity Apr 2, 2020
3b10157
Post merge fix 2
JulienIgnace-Unity Apr 2, 2020
9cf925e
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Apr 2, 2020
6cf20d8
Double inclusion fix.
JulienIgnace-Unity Apr 2, 2020
e1d0fe8
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Apr 2, 2020
dfb7015
Fixed CB visibility
JulienIgnace-Unity Apr 3, 2020
1d5e3e3
Fixed compilation after the merge
JulienIgnace-Unity Apr 3, 2020
0f14fe9
Indentation fix
JulienIgnace-Unity Apr 3, 2020
1c0fae5
Removed temporary comments.
JulienIgnace-Unity Apr 3, 2020
56200ca
Moved some constants around.
JulienIgnace-Unity Apr 3, 2020
277ee40
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Apr 6, 2020
195eefb
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Apr 6, 2020
98d7b06
Post merge fix + Port ProbeVolume global variables to constant buffers.
JulienIgnace-Unity Apr 6, 2020
7852ca9
Fixed deallocation of constant buffers
JulienIgnace-Unity Apr 7, 2020
8fcb2cc
Properly release Volumetric constant buffers.
JulienIgnace-Unity Apr 7, 2020
b8b58a9
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Apr 7, 2020
f47fcfc
Another update to CB API
JulienIgnace-Unity Apr 8, 2020
bdc853f
Updated documentation.
JulienIgnace-Unity Apr 8, 2020
3a7bcc6
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Apr 8, 2020
7931d30
Missing generated file
JulienIgnace-Unity Apr 8, 2020
ff4557a
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Apr 8, 2020
6ccddfe
Merge branch 'HDRP/constant-buffers' of https://github.com/Unity-Tech…
JulienIgnace-Unity Apr 8, 2020
1b1a370
Fixed various issues with light probe volumes.
JulienIgnace-Unity Apr 9, 2020
d76efb0
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Apr 9, 2020
cccf44e
Fixed light list build parameters and a nullref exception when probe …
JulienIgnace-Unity Apr 9, 2020
7510e08
Final fix for probe volumes
JulienIgnace-Unity Apr 9, 2020
f6cddbe
Fixed a warning in shader compilation
JulienIgnace-Unity Apr 10, 2020
224a718
Changes from review feedback
JulienIgnace-Unity Apr 10, 2020
2963ec6
Compilation fix.
JulienIgnace-Unity Apr 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,45 @@

namespace UnityEngine.Rendering.HighDefinition
{
[GenerateHLSL(needAccessors = false, generateCBuffer = true)]
unsafe struct ShaderVariablesDebugDisplay
{
[HLSLArray(32, typeof(Vector4))]
public fixed float _DebugRenderingLayersColors[32 * 4];
[HLSLArray(11, typeof(ShaderGenUInt4))]
public fixed uint _DebugViewMaterialArray[11 * 4]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display

public int _DebugLightingMode; // Match enum DebugLightingMode
public int _DebugLightLayersMask;
public int _DebugShadowMapMode;
public int _DebugMipMapMode; // Match enum DebugMipMapMode

public int _DebugFullScreenMode;
public float _DebugTransparencyOverdrawWeight;
public int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
public int _ColorPickerMode; // Match enum ColorPickerDebugMode

public Vector4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
public Vector4 _DebugLightingSmoothness; // x == bool override, y == override value
public Vector4 _DebugLightingNormal; // x == bool override
public Vector4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
public Vector4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
public Vector4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
public Vector4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
public Vector4 _DebugLightingMaterialValidateLowColor;
public Vector4 _DebugLightingMaterialValidatePureMetalColor;
public Vector4 _MousePixelCoord; // xy unorm, zw norm
public Vector4 _MouseClickPixelCoord; // xy unorm, zw norm

public float _DebugExposure;
public int _MatcapMixAlbedo;
public float _MatcapViewScale;
public int _DebugSingleShadowIndex;

public int _DebugProbeVolumeMode;
public Vector3 _DebugDisplayPad0;
}

/// <summary>
/// Full Screen Debug Mode.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,37 @@
#define FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR (25)
#define FULLSCREENDEBUGMODE_MAX_MATERIAL_FULL_SCREEN_DEBUG (26)

// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesDebugDisplay
// PackingRules = Exact
CBUFFER_START(ShaderVariablesDebugDisplay)
float4 _DebugRenderingLayersColors[32];
uint4 _DebugViewMaterialArray[11];
int _DebugLightingMode;
int _DebugLightLayersMask;
int _DebugShadowMapMode;
int _DebugMipMapMode;
int _DebugFullScreenMode;
float _DebugTransparencyOverdrawWeight;
int _DebugMipMapModeTerrainTexture;
int _ColorPickerMode;
float4 _DebugLightingAlbedo;
float4 _DebugLightingSmoothness;
float4 _DebugLightingNormal;
float4 _DebugLightingAmbientOcclusion;
float4 _DebugLightingSpecularColor;
float4 _DebugLightingEmissiveColor;
float4 _DebugLightingMaterialValidateHighColor;
float4 _DebugLightingMaterialValidateLowColor;
float4 _DebugLightingMaterialValidatePureMetalColor;
float4 _MousePixelCoord;
float4 _MouseClickPixelCoord;
float _DebugExposure;
int _MatcapMixAlbedo;
float _MatcapViewScale;
int _DebugSingleShadowIndex;
int _DebugProbeVolumeMode;
float3 _DebugDisplayPad0;
CBUFFER_END


#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,6 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MipMapDebug.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/ColorPickerDebug.cs.hlsl"

CBUFFER_START(UnityDebugDisplay)
// Set of parameters available when switching to debug shader mode
int _DebugLightingMode; // Match enum DebugLightingMode
int _DebugLightLayersMask;
float4 _DebugRenderingLayersColors[32];
int _DebugShadowMapMode;
float _DebugViewMaterialArray[11]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
int _DebugMipMapMode; // Match enum DebugMipMapMode
int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
int _ColorPickerMode; // Match enum ColorPickerDebugMode
int _DebugProbeVolumeMode; // Match enum ProbeVolumeDebugMode
int _DebugStep;
int _DebugDepthPyramidMip;
int _DebugFullScreenMode;
float _DebugTransparencyOverdrawWeight;
float4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
float4 _DebugLightingSmoothness; // x == bool override, y == override value
float4 _DebugLightingNormal; // x == bool override
float4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
float4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
float4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
float4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
float4 _DebugLightingMaterialValidateLowColor;
float4 _DebugLightingMaterialValidatePureMetalColor;
float4 _MousePixelCoord; // xy unorm, zw norm
float4 _MouseClickPixelCoord; // xy unorm, zw norm
float _DebugExposure;
int _MatcapMixAlbedo;
int _MatcapViewScale;
uint _DebugContactShadowLightIndex;
int _DebugSingleShadowIndex;
CBUFFER_END

// Local shader variables
static DirectionalShadowType g_DebugShadowAttenuation = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Shader "Hidden/HDRP/DebugFullScreen"
CBUFFER_START (UnityDebug)
float _FullScreenDebugMode;
float _TransparencyOverdrawMaxPixelCost;
uint _DebugContactShadowLightIndex;
int _DebugDepthPyramidMip;
CBUFFER_END

TEXTURE2D_X(_DebugFullScreenTexture);
Expand Down Expand Up @@ -304,14 +306,14 @@ Shader "Hidden/HDRP/DebugFullScreen"
float linearDepth = frac(posInput.linearDepth * 0.1);
return float4(linearDepth.xxx, 1.0);
}

if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW)
{
float4 color = (float4)0;

float pixelCost = SAMPLE_TEXTURE2D_X(_DebugFullScreenTexture, s_point_clamp_sampler, input.texcoord).r;
if ((pixelCost > 0.001))
color.rgb = HsvToRgb(float3(0.66 * saturate(1.0 - (1.0 / _TransparencyOverdrawMaxPixelCost) * pixelCost), 1.0, 1.0));//
color.rgb = HsvToRgb(float3(0.66 * saturate(1.0 - (1.0 / _TransparencyOverdrawMaxPixelCost) * pixelCost), 1.0, 1.0));//
return color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Shader "Hidden/HDRP/DebugViewMaterialGBuffer"
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
// So here if the buffer is of size zero, it is the same as if we give in a 0 buffer index.
int bufferIndex = int(_DebugViewMaterialArray[0]) >= 1 ? int(_DebugViewMaterialArray[1]) : 0;
int bufferIndex = _DebugViewMaterialArray[0].x >= 1 ? _DebugViewMaterialArray[1].x : 0;
if (bufferIndex == DEBUGVIEWGBUFFER_DEPTH)
{
float linearDepth = frac(posInput.linearDepth * 0.1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LightCookieManager
internal const int k_MinCookieSize = 2;

readonly Material m_MaterialFilterAreaLights;
MaterialPropertyBlock m_MPBFilterAreaLights;
MaterialPropertyBlock m_MPBFilterAreaLights = new MaterialPropertyBlock();

readonly Material m_CubeToPanoMaterial;

Expand Down Expand Up @@ -159,11 +159,12 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)

// Start by copying the source texture to the array slice's mip 0
{
cmd.SetGlobalTexture(s_texSource, source);
cmd.SetGlobalInt(s_sourceMipLevel, 0);
m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, 0);
m_MPBFilterAreaLights.SetTexture(s_texSource, source);

cmd.SetRenderTarget(m_TempRenderTexture0, 0);
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 0, MeshTopology.Triangles, 3, 1);
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 0, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}

// Then operate on all the remaining mip levels
Expand All @@ -177,13 +178,14 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
viewportWidth = Mathf.Max(1, viewportWidth >> 1);
targetWidth = Mathf.Max(1, targetWidth >> 1);

m_MPBFilterAreaLights.SetTexture(s_texSource, m_TempRenderTexture0);
m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, mipIndex - 1);
m_MPBFilterAreaLights.SetVector(s_sourceSize, sourceSize);
m_MPBFilterAreaLights.SetVector(s_uvLimits, uvLimits);

cmd.SetRenderTarget(m_TempRenderTexture1, mipIndex-1); // Temp texture is already 1 mip lower than source
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
cmd.SetGlobalTexture(s_texSource, m_TempRenderTexture0);
cmd.SetGlobalInt(s_sourceMipLevel, mipIndex-1); // Use previous mip as source
cmd.SetGlobalVector(s_sourceSize, sourceSize);
cmd.SetGlobalVector(s_uvLimits, uvLimits);
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 1, MeshTopology.Triangles, 3, 1);
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 1, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}

sourceWidth = targetWidth;
Expand All @@ -195,13 +197,14 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
viewportHeight = Mathf.Max(1, viewportHeight >> 1);
targetHeight = Mathf.Max(1, targetHeight >> 1);

m_MPBFilterAreaLights.SetTexture(s_texSource, m_TempRenderTexture1);
m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, mipIndex - 1);
m_MPBFilterAreaLights.SetVector(s_sourceSize, sourceSize);
m_MPBFilterAreaLights.SetVector(s_uvLimits, uvLimits);

cmd.SetRenderTarget(m_TempRenderTexture0, mipIndex);
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
cmd.SetGlobalTexture(s_texSource, m_TempRenderTexture1);
cmd.SetGlobalInt(s_sourceMipLevel, mipIndex-1);
cmd.SetGlobalVector(s_sourceSize, sourceSize);
cmd.SetGlobalVector(s_uvLimits, uvLimits);
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 2, MeshTopology.Triangles, 3, 1);
cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 2, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}

sourceHeight = targetHeight;
Expand Down
Loading