Skip to content
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Optimizations for the physically based depth of field.
- Converted most TGA textures files to TIF to reduce the size of HDRP material samples.
- Changed sample scene in HDRP material samples: add shadow transparency (raster, ray-traced, path-traced).
- Support for encoded HDR cubemaps, configurable via the HDR Cubemap Encoding project setting.

## [13.1.1] - 2021-10-04

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Shader "Hidden/Debug/ReflectionProbePreview"
#pragma fragment frag

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

struct appdata
Expand All @@ -45,6 +46,7 @@ Shader "Hidden/Debug/ReflectionProbePreview"

TEXTURECUBE(_Cubemap);
SAMPLER(sampler_Cubemap);
float4 _Cubemap_HDR;

float3 _CameraWorldPosition;
float _MipLevel;
Expand All @@ -67,6 +69,7 @@ Shader "Hidden/Debug/ReflectionProbePreview"
float3 V = normalize(i.positionWS - GetPrimaryCameraPosition());
float3 R = reflect(V, i.normalWS);
float4 color = SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, R, _MipLevel).rgba;
color.rgb = DecodeHDREnvironment(color, _Cubemap_HDR);
color = color * exp2(_Exposure) * GetCurrentExposureMultiplier();

return float4(color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ Shader "Hidden/SRP/BlitCubeTextureFace"
#pragma editor_sync_compilation
#pragma prefer_hlslcc gles
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"

#pragma vertex vert
#pragma fragment frag
#pragma target 3.0

TEXTURECUBE(_InputTex);
SAMPLER(sampler_InputTex);
float4 _InputTex_HDR;

float _FaceIndex;
float _LoD;
Expand Down Expand Up @@ -59,7 +61,9 @@ Shader "Hidden/SRP/BlitCubeTextureFace"

float4 frag (Varyings input) : SV_Target
{
return SAMPLE_TEXTURECUBE_LOD(_InputTex, sampler_InputTex, input.texcoord, _LoD);
float4 color = SAMPLE_TEXTURECUBE_LOD(_InputTex, sampler_InputTex, input.texcoord, _LoD);
color.rgb = DecodeHDREnvironment(color, _InputTex_HDR);
return color;
}

ENDHLSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,21 @@ Texture[] ConvolveProbeTexture(CommandBuffer cmd, Texture texture)
// 2) to the proper reflection probe cache size
bool sizeMismatch = cubeTexture.width != m_ProbeSize || cubeTexture.height != m_ProbeSize;
bool formatMismatch = (GraphicsFormatUtility.GetGraphicsFormat(cubeTexture.format, false) != m_TempRenderTexture.graphicsFormat);
if (formatMismatch || sizeMismatch)

// We comment the following warning as they have no impact on the result but spam the console, it is just that we waste offline time and a bit of quality for nothing.
if (sizeMismatch)
{
// We comment the following warning as they have no impact on the result but spam the console, it is just that we waste offline time and a bit of quality for nothing.
if (sizeMismatch)
{
// Debug.LogWarningFormat("Baked Reflection Probe {0} does not match HDRP Reflection Probe Cache size of {1}. Consider baking it at the same size for better loading performance.", texture.name, m_ProbeSize);
}
else if (cubeTexture.graphicsFormat == GraphicsFormat.RGB_BC6H_UFloat || cubeTexture.graphicsFormat == GraphicsFormat.RGB_BC6H_SFloat)
{
// Debug.LogWarningFormat("Baked Reflection Probe {0} is compressed but the HDRP Reflection Probe Cache is not. Consider removing compression from the input texture for better quality.", texture.name);
}
ConvertTexture(cmd, cubeTexture, m_TempRenderTexture);
// Debug.LogWarningFormat("Baked Reflection Probe {0} does not match HDRP Reflection Probe Cache size of {1}. Consider baking it at the same size for better loading performance.", texture.name, m_ProbeSize);
}
else
else if (formatMismatch && (cubeTexture.graphicsFormat == GraphicsFormat.RGB_BC6H_UFloat || cubeTexture.graphicsFormat == GraphicsFormat.RGB_BC6H_SFloat))
{
for (int f = 0; f < 6; f++)
{
cmd.CopyTexture(cubeTexture, f, 0, m_TempRenderTexture, f, 0);
}
// Debug.LogWarningFormat("Baked Reflection Probe {0} is compressed but the HDRP Reflection Probe Cache is not. Consider removing compression from the input texture for better quality.", texture.name);
}

// Convert the cubemap to match the size and texture format used for the cache
// This will also take care of decoding manually encoded HDR cubemaps (RGBM, dLDR)
ConvertTexture(cmd, cubeTexture, m_TempRenderTexture);

// Ideally if input is not compressed and has mipmaps, don't do anything here. Problem is, we can't know if mips have been already convolved offline...
cmd.GenerateMips(m_TempRenderTexture);
convolutionSourceTexture = m_TempRenderTexture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Shader "Hidden/HDRP/Sky/HDRISky"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SDF2D.hlsl"
Expand All @@ -49,6 +50,7 @@ Shader "Hidden/HDRP/Sky/HDRISky"

TEXTURECUBE(_Cubemap);
SAMPLER(sampler_Cubemap);
float4 _Cubemap_HDR;

TEXTURE2D(_Flowmap);
SAMPLER(sampler_Flowmap);
Expand Down Expand Up @@ -203,16 +205,16 @@ Shader "Hidden/HDRP/Sky/HDRISky"
#endif

// Sample twice
float3 color1 = SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir + alpha.x*dd, 0).rgb;
float3 color2 = SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir + alpha.y*dd, 0).rgb;
float3 color1 = DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir + alpha.x * dd, 0), _Cubemap_HDR);
float3 color2 = DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir + alpha.y * dd, 0), _Cubemap_HDR);

// Blend color samples
return lerp(color1, color2, abs(2.0 * alpha.x));
}
else
#endif

return SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir, 0).rgb;
return DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir, 0), _Cubemap_HDR);
}

float4 GetColorWithRotation(float3 dir, float exposure, float2 cos_sin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Shader "Hidden/HDRP/IntegrateHDRI"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

struct Attributes
Expand All @@ -37,6 +38,7 @@ Shader "Hidden/HDRP/IntegrateHDRI"
};

TextureCube<float4> _Cubemap;
float4 _Cubemap_HDR;

Varyings Vert(Attributes input)
{
Expand Down Expand Up @@ -65,7 +67,7 @@ Shader "Hidden/HDRP/IntegrateHDRI"
{
// SphericalToCartesian function is for Z up, lets move to Y up with TransformGLtoDX
float3 L = TransformGLtoDX(SphericalToCartesian(phi, cos(theta)));
real3 val = SAMPLE_TEXTURECUBE_LOD(skybox, sampler_skybox, L, 0).rgb;
real3 val = DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(skybox, sampler_skybox, L, 0), _Cubemap_HDR).rgb;
sum += (cos(theta)*sin(theta)*coef)*val;
}
}
Expand Down