Evgenii Golubev 7 年前
当前提交
6be2053b
共有 38 个文件被更改,包括 1497 次插入233 次删除
  1. 14
      ImageTemplates/LightweightPipeline/Scenes/023_Lighting_Mixed.unity.png.meta
  2. 14
      ImageTemplates/LightweightPipeline/Scenes/027_PostProcessing.unity.png.meta
  3. 14
      ImageTemplates/LightweightPipeline/Scenes/036_Lighting_Scene_DirectionalBakedDirectional.unity.png.meta
  4. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl
  5. 57
      ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.hlsl
  6. 391
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  7. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  10. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  11. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  12. 8
      SampleScenes/Common/Materials.meta
  13. 91
      SampleScenes/Common/Scripts/CompressBC6HAndDisplay.cs
  14. 11
      SampleScenes/Common/Scripts/CompressBC6HAndDisplay.cs.meta
  15. 8
      SampleScenes/Common/Shaders.meta
  16. 77
      SampleScenes/Common/Textures/Alexs_Apt_2k.hdr.meta
  17. 139
      SampleScenes/Common/Textures/Alexs_Apt_2k_cube.hdr.meta
  18. 8
      SampleScenes/CoreTest.meta
  19. 122
      ScriptableRenderPipeline/Core/EncodeBC6H.cs
  20. 13
      ScriptableRenderPipeline/Core/EncodeBC6H.cs.meta
  21. 49
      ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute
  22. 10
      ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute.meta
  23. 176
      ScriptableRenderPipeline/Core/ShaderLibrary/BC6H.hlsl
  24. 10
      ScriptableRenderPipeline/Core/ShaderLibrary/BC6H.hlsl.meta
  25. 198
      SampleScenes/Common/Materials/Mat_Test_CubemapDebug.mat
  26. 8
      SampleScenes/Common/Materials/Mat_Test_CubemapDebug.mat.meta
  27. 194
      SampleScenes/Common/Materials/Mat_Test_Unlit.mat
  28. 8
      SampleScenes/Common/Materials/Mat_Test_Unlit.mat.meta
  29. 62
      SampleScenes/Common/Shaders/CubemapColorMap.shader
  30. 8
      SampleScenes/Common/Shaders/CubemapColorMap.shader.meta
  31. 7
      SampleScenes/CoreTest/Test_BC6HCompression.unity.meta
  32. 8
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/0xxx.meta

14
ImageTemplates/LightweightPipeline/Scenes/023_Lighting_Mixed.unity.png.meta


fileFormatVersion: 2
guid: fad56126d031e40ffa9d93733bead554
timeCreated: 1509374830
licenseType: Pro
serializedVersion: 4
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1

spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1

sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:

14
ImageTemplates/LightweightPipeline/Scenes/027_PostProcessing.unity.png.meta


fileFormatVersion: 2
guid: c40bd57fb760b4839a1ef80428356062
timeCreated: 1509377483
licenseType: Pro
serializedVersion: 4
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1

spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1

sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:

14
ImageTemplates/LightweightPipeline/Scenes/036_Lighting_Scene_DirectionalBakedDirectional.unity.png.meta


fileFormatVersion: 2
guid: f1b41e73e6cf549d4a74497132c3aa3a
timeCreated: 1509466261
licenseType: Pro
serializedVersion: 4
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1

spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1

sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:

2
ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl


NdotV = dot(N, V);
N = (NdotV >= 0) ? N : (N - 2 * NdotV * V);
N = (NdotV >= 0.0) ? N : (N - 2.0 * NdotV * V);
NdotV = abs(NdotV);
return N;

57
ScriptableRenderPipeline/Core/ShaderLibrary/Sampling.hlsl


return TransformGLtoDX(SphericalToCartesian(phi, cosTheta));
}
// Convert a texel position into normalized position [-1..1]x[-1..1]
float2 CubemapTexelToNVC(uint2 unPositionTXS, uint cubemapSize)
{
return 2.0 * float2(unPositionTXS) / float(max(cubemapSize - 1, 1)) - 1.0;
}
// Map cubemap face to world vector basis
static const float3 CUBEMAP_FACE_BASIS_MAPPING[6][3] =
{
//XPOS face
{
float3(0.0, 0.0, -1.0),
float3(0.0, -1.0, 0.0),
float3(1.0, 0.0, 0.0)
},
//XNEG face
{
float3(0.0, 0.0, 1.0),
float3(0.0, -1.0, 0.0),
float3(-1.0, 0.0, 0.0)
},
//YPOS face
{
float3(1.0, 0.0, 0.0),
float3(0.0, 0.0, 1.0),
float3(0.0, 1.0, 0.0)
},
//YNEG face
{
float3(1.0, 0.0, 0.0),
float3(0.0, 0.0, -1.0),
float3(0.0, -1.0, 0.0)
},
//ZPOS face
{
float3(1.0, 0.0, 0.0),
float3(0.0, -1.0, 0.0),
float3(0.0, 0.0, 1.0)
},
//ZNEG face
{
float3(-1.0, 0.0, 0.0),
float3(0.0, -1.0, 0.0),
float3(0.0, 0.0, -1.0)
}
};
// Convert a normalized cubemap face position into a direction
float3 CubemapTexelToDirection(float2 positionNVC, uint faceId)
{
float3 dir = CUBEMAP_FACE_BASIS_MAPPING[faceId][0] * positionNVC.x
+ CUBEMAP_FACE_BASIS_MAPPING[faceId][1] * positionNVC.y
+ CUBEMAP_FACE_BASIS_MAPPING[faceId][2];
return normalize(dir);
}
//-----------------------------------------------------------------------------
// Sampling function
// Reference : http://www.cs.virginia.edu/~jdl/bib/globillum/mis/shirley96.pdf + PBRT

391
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


ShaderPassName[] m_ForwardAndForwardOnlyPassNames = { new ShaderPassName(), new ShaderPassName(), HDShaderPassNames.s_SRPDefaultUnlitName};
ShaderPassName[] m_ForwardOnlyPassNames = { new ShaderPassName(), HDShaderPassNames.s_SRPDefaultUnlitName };
ShaderPassName[] m_AllTransparentPassNames = { HDShaderPassNames.s_TransparentDepthPrepassName,
HDShaderPassNames.s_TransparentBackfaceName,
ShaderPassName[] m_AllTransparentPassNames = { HDShaderPassNames.s_TransparentBackfaceName,
ShaderPassName[] m_AllTransparentDebugDisplayPassNames = { HDShaderPassNames.s_TransparentDepthPrepassName,
HDShaderPassNames.s_TransparentBackfaceDebugDisplayName,
ShaderPassName[] m_AllTransparentDebugDisplayPassNames = { HDShaderPassNames.s_TransparentBackfaceDebugDisplayName,
HDShaderPassNames.s_ForwardOnlyDebugDisplayName,
HDShaderPassNames.s_ForwardDebugDisplayName,
HDShaderPassNames.s_TransparentDepthPostpassName,

ShaderPassName[] m_DepthOnlyAndDepthForwardOnlyPassNames = { HDShaderPassNames.s_DepthForwardOnlyName, HDShaderPassNames.s_DepthOnlyName };
ShaderPassName[] m_DepthForwardOnlyPassNames = { HDShaderPassNames.s_DepthForwardOnlyName };
ShaderPassName[] m_DepthOnlyPassNames = { HDShaderPassNames.s_DepthOnlyName };
ShaderPassName[] m_TransparentDepthOnlyPassNames = { HDShaderPassNames.s_TransparentDepthPrepassName };
ShaderPassName[] m_ForwardErrorPassNames = { HDShaderPassNames.s_AlwaysName, HDShaderPassNames.s_ForwardBaseName, HDShaderPassNames.s_DeferredName, HDShaderPassNames.s_PrepassBaseName, HDShaderPassNames.s_VertexName, HDShaderPassNames.s_VertexLMRGBMName, HDShaderPassNames.s_VertexLMName };
ShaderPassName[] m_SinglePassName = new ShaderPassName[1];

base.Render(renderContext, cameras);
#if UNITY_EDITOR
SupportedRenderingFeatures.active = s_NeededFeatures;
SupportedRenderingFeatures.active = s_NeededFeatures;
// HD use specific GraphicsSettings. This is init here.
// TODO: This should not be set at each Frame but is there another place for these config setup ?
GraphicsSettings.lightsUseLinearIntensity = true;
GraphicsSettings.lightsUseColorTemperature = true;
// HD use specific GraphicsSettings. This is init here.
// TODO: This should not be set at each Frame but is there another place for these config setup ?
GraphicsSettings.lightsUseLinearIntensity = true;
GraphicsSettings.lightsUseColorTemperature = true;
if (m_FrameCount != Time.frameCount)
{
HDCamera.CleanUnused();
m_FrameCount = Time.frameCount;
}
if (m_FrameCount != Time.frameCount)
{
HDCamera.CleanUnused();
m_FrameCount = Time.frameCount;
}
foreach (var material in m_MaterialList)
material.RenderInit(cmd);
foreach (var material in m_MaterialList)
material.RenderInit(cmd);
// Do anything we need to do upon a new frame.
m_LightLoop.NewFrame();
// Do anything we need to do upon a new frame.
m_LightLoop.NewFrame();
// we only want to render one camera for now
// select the most main camera!
Camera camera = null;
foreach (var cam in cameras)
{
if (cam == Camera.main)
// we only want to render one camera for now
// select the most main camera!
Camera camera = null;
foreach (var cam in cameras)
camera = cam;
break;
if (cam == Camera.main)
{
camera = cam;
break;
}
}
if (camera == null && cameras.Length > 0)
camera = cameras[0];
if (camera == null && cameras.Length > 0)
camera = cameras[0];
if (camera == null)
{
renderContext.Submit();
return;
}
if (camera == null)
{
renderContext.Submit();
return;
}
// If we render a reflection view or a preview we should not display any debug information
// This need to be call before ApplyDebugDisplaySettings()
if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview)
{
// Neutral allow to disable all debug settings
m_CurrentDebugDisplaySettings = s_NeutralDebugDisplaySettings;
}
else
{
m_CurrentDebugDisplaySettings = m_DebugDisplaySettings;
}
// If we render a reflection view or a preview we should not display any debug information
// This need to be call before ApplyDebugDisplaySettings()
if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview)
{
// Neutral allow to disable all debug settings
m_CurrentDebugDisplaySettings = s_NeutralDebugDisplaySettings;
}
else
{
m_CurrentDebugDisplaySettings = m_DebugDisplaySettings;
}
ApplyDebugDisplaySettings(cmd);
UpdateCommonSettings();
ApplyDebugDisplaySettings(cmd);
UpdateCommonSettings();
ScriptableCullingParameters cullingParams;
if (!CullResults.GetCullingParameters(camera, out cullingParams))
{
renderContext.Submit();
return;
}
ScriptableCullingParameters cullingParams;
if (!CullResults.GetCullingParameters(camera, out cullingParams))
{
renderContext.Submit();
return;
}
m_LightLoop.UpdateCullingParameters( ref cullingParams );
m_LightLoop.UpdateCullingParameters( ref cullingParams );
// emit scene view UI
if (camera.cameraType == CameraType.SceneView)
{
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
}
// emit scene view UI
if (camera.cameraType == CameraType.SceneView)
{
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
}
using (new ProfilingSample(cmd, "CullResults.Cull", GetSampler(CustomSamplerId.CullResultsCull)))
{
CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);
}
using (new ProfilingSample(cmd, "CullResults.Cull", GetSampler(CustomSamplerId.CullResultsCull)))
{
CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);
}
Resize(camera);
Resize(camera);
renderContext.SetupCameraProperties(camera);
renderContext.SetupCameraProperties(camera);
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer);
PushGlobalParams(hdCamera, cmd, sssSettings);
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer);
PushGlobalParams(hdCamera, cmd, sssSettings);
// TODO: Find a correct place to bind these material textures
// We have to bind the material specific global parameters in this mode
m_MaterialList.ForEach(material => material.Bind());
// TODO: Find a correct place to bind these material textures
// We have to bind the material specific global parameters in this mode
m_MaterialList.ForEach(material => material.Bind());
var additionalCameraData = camera.GetComponent<HDAdditionalCameraData>();
if (additionalCameraData && additionalCameraData.renderingPath == RenderingPathHDRP.Unlit)
{
// TODO: Add another path dedicated to planar reflection / real time cubemap that implement simpler lighting
// It is up to the users to only send unlit object for this camera path
var additionalCameraData = camera.GetComponent<HDAdditionalCameraData>();
if (additionalCameraData && additionalCameraData.renderingPath == RenderingPathHDRP.Unlit)
{
// TODO: Add another path dedicated to planar reflection / real time cubemap that implement simpler lighting
// It is up to the users to only send unlit object for this camera path
using (new ProfilingSample(cmd, "Forward", GetSampler(CustomSamplerId.Forward)))
using (new ProfilingSample(cmd, "Forward", GetSampler(CustomSamplerId.Forward)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, ClearFlag.Color | ClearFlag.Depth);
RenderOpaqueRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName);
RenderTransparentRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName, false);
}
renderContext.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
renderContext.Submit();
return;
}
// Note: Legacy Unity behave like this for ShadowMask
// When you select ShadowMask in Lighting panel it recompile shaders on the fly with the SHADOW_MASK keyword.
// However there is no C# function that we can query to know what mode have been select in Lighting Panel and it will be wrong anyway. Lighting Panel setup what will be the next bake mode. But until light is bake, it is wrong.
// Currently to know if you need shadow mask you need to go through all visible lights (of CullResult), check the LightBakingOutput struct and look at lightmapBakeType/mixedLightingMode. If one light have shadow mask bake mode, then you need shadow mask features (i.e extra Gbuffer).
// It mean that when we build a standalone player, if we detect a light with bake shadow mask, we generate all shader variant (with and without shadow mask) and at runtime, when a bake shadow mask light is visible, we dynamically allocate an extra GBuffer and switch the shader.
// So the first thing to do is to go through all the light: PrepareLightsForGPU
bool enableBakeShadowMask;
using (new ProfilingSample(cmd, "TP_PrepareLightsForGPU", GetSampler(CustomSamplerId.TPPrepareLightsForGPU)))
CoreUtils.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, ClearFlag.Color | ClearFlag.Depth);
RenderOpaqueRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName);
RenderTransparentRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName);
enableBakeShadowMask = m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
ConfigureForShadowMask(enableBakeShadowMask, cmd);
renderContext.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
renderContext.Submit();
return;
}
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
// Note: Legacy Unity behave like this for ShadowMask
// When you select ShadowMask in Lighting panel it recompile shaders on the fly with the SHADOW_MASK keyword.
// However there is no C# function that we can query to know what mode have been select in Lighting Panel and it will be wrong anyway. Lighting Panel setup what will be the next bake mode. But until light is bake, it is wrong.
// Currently to know if you need shadow mask you need to go through all visible lights (of CullResult), check the LightBakingOutput struct and look at lightmapBakeType/mixedLightingMode. If one light have shadow mask bake mode, then you need shadow mask features (i.e extra Gbuffer).
// It mean that when we build a standalone player, if we detect a light with bake shadow mask, we generate all shader variant (with and without shadow mask) and at runtime, when a bake shadow mask light is visible, we dynamically allocate an extra GBuffer and switch the shader.
// So the first thing to do is to go through all the light: PrepareLightsForGPU
bool enableBakeShadowMask;
using (new ProfilingSample(cmd, "TP_PrepareLightsForGPU", GetSampler(CustomSamplerId.TPPrepareLightsForGPU)))
{
enableBakeShadowMask = m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
}
ConfigureForShadowMask(enableBakeShadowMask, cmd);
RenderDepthPrepass(m_CullResults, camera, renderContext, cmd);
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
RenderGBuffer(m_CullResults, camera, renderContext, cmd);
RenderDepthPrepass(m_CullResults, camera, 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.
CopyDepthBufferIfNeeded(cmd);
RenderGBuffer(m_CullResults, camera, renderContext, cmd);
RenderPyramidDepth(camera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
// 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.
CopyDepthBufferIfNeeded(cmd);
// Required for the SSS and the shader feature classification pass.
PrepareAndBindStencilTexture(cmd);
RenderPyramidDepth(camera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
// Required for the SSS and the shader feature classification pass.
PrepareAndBindStencilTexture(cmd);
if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled())
{
RenderDebugViewMaterial(m_CullResults, hdCamera, renderContext, cmd);
}
else
{
using (new ProfilingSample(cmd, "Render SSAO", GetSampler(CustomSamplerId.RenderSSAO)))
if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled())
// TODO: Everything here (SSAO, Shadow, Build light list, deferred shadow, material and light classification can be parallelize with Async compute)
RenderSSAO(cmd, camera, renderContext, postProcessLayer);
RenderDebugViewMaterial(m_CullResults, hdCamera, renderContext, cmd);
using (new ProfilingSample(cmd, "Render shadows", GetSampler(CustomSamplerId.RenderShadows)))
else
m_LightLoop.RenderShadows(renderContext, cmd, m_CullResults);
// TODO: check if statement below still apply
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after RenderShadows as it modify our view/proj matrix
}
using (new ProfilingSample(cmd, "Render SSAO", GetSampler(CustomSamplerId.RenderSSAO)))
{
// TODO: Everything here (SSAO, Shadow, Build light list, deferred shadow, material and light classification can be parallelize with Async compute)
RenderSSAO(cmd, camera, renderContext, postProcessLayer);
}
using (new ProfilingSample(cmd, "Deferred directional shadows", GetSampler(CustomSamplerId.RenderDeferredDirectionalShadow)))
{
cmd.GetTemporaryRT(m_DeferredShadowBuffer, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1, true);
m_LightLoop.RenderDeferredDirectionalShadow(hdCamera, m_DeferredShadowBufferRT, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(cmd, m_DeferredShadowBuffer, hdCamera.camera, renderContext, FullScreenDebugMode.DeferredShadows);
}
using (new ProfilingSample(cmd, "Render shadows", GetSampler(CustomSamplerId.RenderShadows)))
{
m_LightLoop.RenderShadows(renderContext, cmd, m_CullResults);
// TODO: check if statement below still apply
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after RenderShadows as it modify our view/proj matrix
}
using (new ProfilingSample(cmd, "Build Light list", GetSampler(CustomSamplerId.BuildLightList)))
{
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
}
using (new ProfilingSample(cmd, "Deferred directional shadows", GetSampler(CustomSamplerId.RenderDeferredDirectionalShadow)))
{
cmd.GetTemporaryRT(m_DeferredShadowBuffer, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1, true);
m_LightLoop.RenderDeferredDirectionalShadow(hdCamera, m_DeferredShadowBufferRT, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(cmd, m_DeferredShadowBuffer, hdCamera.camera, renderContext, FullScreenDebugMode.DeferredShadows);
}
using (new ProfilingSample(cmd, "Build Light list", GetSampler(CustomSamplerId.BuildLightList)))
{
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
}
// Don't update the sky environment if we are rendering a cubemap (it should be update already)
if (camera.cameraType != CameraType.Reflection)
{
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
}
// Don't update the sky environment if we are rendering a cubemap (it should be update already)
if (camera.cameraType != CameraType.Reflection)
{
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
}
RenderDeferredLighting(hdCamera, cmd);
RenderDeferredLighting(hdCamera, cmd);
// We compute subsurface scattering here. Therefore, no objects rendered afterwards will exhibit SSS.
// Currently, there is no efficient way to switch between SRT and MRT for the forward pass;
// therefore, forward-rendered objects do not output split lighting required for the SSS pass.
SubsurfaceScatteringPass(hdCamera, cmd, sssSettings);
// We compute subsurface scattering here. Therefore, no objects rendered afterwards will exhibit SSS.
// Currently, there is no efficient way to switch between SRT and MRT for the forward pass;
// therefore, forward-rendered objects do not output split lighting required for the SSS pass.
SubsurfaceScatteringPass(hdCamera, cmd, sssSettings);
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
RenderSky(hdCamera, cmd);
RenderSky(hdCamera, cmd);
// Render pre refraction objects
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
// Render pre refraction objects
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);
// Planar and real time cubemap doesn't need post process and render in FP16
if (camera.cameraType == CameraType.Reflection)
{
using (new ProfilingSample(cmd, "Blit to final RT", GetSampler(CustomSamplerId.BlitToFinalRT)))
// Planar and real time cubemap doesn't need post process and render in FP16
if (camera.cameraType == CameraType.Reflection)
// Simple blit
cmd.Blit(m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget);
using (new ProfilingSample(cmd, "Blit to final RT", GetSampler(CustomSamplerId.BlitToFinalRT)))
{
// Simple blit
cmd.Blit(m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget);
}
}
else
{
RenderVelocity(m_CullResults, hdCamera, renderContext, cmd); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
else
{
RenderVelocity(m_CullResults, hdCamera, renderContext, cmd); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);
// TODO: Check with VFX team.
// Rendering distortion here have off course lot of artifact.
// But resolving at each objects that write in distortion is not possible (need to sort transparent, render those that do not distort, then resolve, then etc...)
// Instead we chose to apply distortion at the end after we cumulate distortion vector and desired blurriness.
AccumulateDistortion(m_CullResults, camera, renderContext, cmd);
RenderDistortion(cmd, m_Asset.renderPipelineResources);
// TODO: Check with VFX team.
// Rendering distortion here have off course lot of artifact.
// But resolving at each objects that write in distortion is not possible (need to sort transparent, render those that do not distort, then resolve, then etc...)
// Instead we chose to apply distortion at the end after we cumulate distortion vector and desired blurriness.
AccumulateDistortion(m_CullResults, camera, renderContext, cmd);
RenderDistortion(cmd, m_Asset.renderPipelineResources);
RenderPostProcesses(camera, cmd, postProcessLayer);
RenderPostProcesses(camera, cmd, postProcessLayer);
}
}
RenderDebug(hdCamera, cmd);
RenderDebug(hdCamera, cmd);
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, m_CameraDepthStencilBufferRT);
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, m_CameraDepthStencilBufferRT);
renderContext.ExecuteCommandBuffer(cmd);
renderContext.ExecuteCommandBuffer(cmd);
}
}
}
void RenderOpaqueRenderList(CullResults cull,

ScriptableRenderContext renderContext,
CommandBuffer cmd,
ShaderPassName passName,
bool preRefractionQueue,
Material overrideMaterial = null,
bool preRefractionQueue = false)
Material overrideMaterial = null)
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_SinglePassName,
rendererConfiguration, stateBlock, overrideMaterial, preRefractionQueue);
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_SinglePassName, preRefractionQueue,
rendererConfiguration, stateBlock, overrideMaterial);
}
void RenderTransparentRenderList(CullResults cull,

ShaderPassName[] passNames,
bool preRefractionQueue,
Material overrideMaterial = null,
bool preRefractionQueue = false)
Material overrideMaterial = null
)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.displayTransparentObjects)
return;

cmd.ClearRenderTarget(false, true, Color.clear);
// Only transparent object can render distortion vectors
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue:true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, false);
}
}

RenderOpaqueRenderList(cull, camera, renderContext, cmd, m_DepthOnlyPassNames, 0, renderQueueRange);
}
}
// Render transparent depth prepass after opaque one
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_TransparentDepthOnlyPassNames, true);
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_TransparentDepthOnlyPassNames, false);
}
}

RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, cmd, m_AllForwardDebugDisplayPassNames, m_currentRendererConfigurationBakedLighting);
// Render forward transparent
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, m_AllForwardDebugDisplayPassNames, m_currentRendererConfigurationBakedLighting);
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, m_AllForwardDebugDisplayPassNames, true, m_currentRendererConfigurationBakedLighting);
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, m_AllForwardDebugDisplayPassNames, false, m_currentRendererConfigurationBakedLighting);
}
}

else
{
var passNames = m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() ? m_AllTransparentDebugDisplayPassNames : m_AllTransparentPassNames;
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, passNames, m_currentRendererConfigurationBakedLighting, preRefractionQueue: pass == ForwardPass.PreRefraction);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, passNames, pass == ForwardPass.PreRefraction, m_currentRendererConfigurationBakedLighting);
}
}
}

}
else
{
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardErrorPassNames, 0,
null, m_ErrorMaterial, pass == ForwardPass.PreRefraction);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardErrorPassNames, pass == ForwardPass.PreRefraction, 0, null, m_ErrorMaterial);
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


ZWrite On
ZTest LEqual
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

ZWrite On
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

2
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


ZWrite On
ZTest LEqual
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

ZWrite On
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


ZWrite On
ZTest LEqual
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

ZWrite On
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


ZWrite On
ZTest LEqual
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

ZWrite On
// When alpha test is enabled, we should not write into the color buffer
ColorMask 0
HLSLPROGRAM

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


Transparent
}
// Enum values are hardcoded for retrocompatibility. Don't change them.
// Enum values are hardcoded for retro-compatibility. Don't change them.
public enum BlendMode
{
Alpha = 0,

// This function must finish with double sided option (see LitUI.cs)
if (doubleSidedEnable != null)
{
// Grey the option is backface rendering is enabled
bool disabledScope = transparentBackfaceEnable != null && transparentBackfaceEnable.floatValue > 0.0f && ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent);
using (new EditorGUI.DisabledScope(disabledScope))
{
m_MaterialEditor.ShaderProperty(doubleSidedEnable, StylesBaseUnlit.doubleSidedEnableText);
}
m_MaterialEditor.ShaderProperty(doubleSidedEnable, StylesBaseUnlit.doubleSidedEnableText);
}
EditorGUI.indentLevel--;

}
}
// Can't enable double sided and backface rendering at the same time, give priority to backface rendering
bool doubleSidedEnable = material.HasProperty(kDoubleSidedEnable) && material.GetFloat(kDoubleSidedEnable) > 0.0f && !isBackFaceEnable;
bool doubleSidedEnable = material.HasProperty(kDoubleSidedEnable) && material.GetFloat(kDoubleSidedEnable) > 0.0f;
if (doubleSidedEnable)
if (doubleSidedEnable && !isBackFaceEnable) // When backface is enable no need to disable cullmode as we render both side.
{
material.SetInt("_CullMode", (int)UnityEngine.Rendering.CullMode.Off);
}

8
SampleScenes/Common/Materials.meta


fileFormatVersion: 2
guid: d6989f167ae4d07419315e04a2920061
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

91
SampleScenes/Common/Scripts/CompressBC6HAndDisplay.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
[ExecuteInEditMode]
public class CompressBC6HAndDisplay : MonoBehaviour
{
[SerializeField]
ComputeShader m_BC6HShader;
[SerializeField]
Texture m_SourceTexture;
[SerializeField]
Material m_SourceMaterial;
[SerializeField]
string m_TextureName = "_ColorMap";
int m_Hash = 0;
RenderTargetIdentifier m_SourceId;
Texture m_Target;
RenderTargetIdentifier m_TargetId;
int m_MipCount = 0;
Renderer m_Renderer;
Material m_Material;
EncodeBC6H m_EncodeBC6H;
void OnEnable()
{
if (m_Material != null)
DestroyImmediate(m_Material);
m_Material = Instantiate(m_SourceMaterial);
var renderer = m_Renderer ?? (m_Renderer = GetComponent<Renderer>());
renderer.material = m_Material;
m_EncodeBC6H = new EncodeBC6H(m_BC6HShader);
}
void OnPreRender(CommandBuffer cmb)
{
if (m_SourceTexture == null
|| m_SourceMaterial == null
|| m_BC6HShader == null)
{
enabled = false;
return;
}
using (new ProfilingSample(cmb, "EncodeBC6H Test"))
{
var hash = CalculateHash(m_SourceTexture);
if (m_Hash != hash)
{
m_Hash = hash;
m_SourceId = new RenderTargetIdentifier(m_SourceTexture);
CreateTargetInstance();
}
m_EncodeBC6H.EncodeFastCubemap(cmb, m_SourceId, m_SourceTexture.width, m_TargetId, 0, m_MipCount - 1);
}
m_Material.SetTexture(m_TextureName, m_Target);
}
void Update()
{
var cmd = new CommandBuffer { name = "EncodeBC6H Compress" };
OnPreRender(cmd);
Graphics.ExecuteCommandBuffer(cmd);
}
[ContextMenu("Create Target")]
void CreateTargetInstance()
{
if (m_Target is RenderTexture)
((RenderTexture)m_Target).Release();
var t = new Cubemap(m_SourceTexture.width, TextureFormat.BC6H, true);
m_Target = t;
m_Material.SetTexture(m_TextureName, m_Target);
m_SourceId = new RenderTargetIdentifier(m_SourceTexture);
m_TargetId = new RenderTargetIdentifier(m_Target);
m_MipCount = ((Cubemap)m_SourceTexture).mipmapCount;
}
static int CalculateHash(Texture texture)
{
return texture.width ^ texture.height ^ texture.GetInstanceID();
}
}

11
SampleScenes/Common/Scripts/CompressBC6HAndDisplay.cs.meta


fileFormatVersion: 2
guid: 73fbe8f92db5fb3408250f4bdc5b42cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
SampleScenes/Common/Shaders.meta


fileFormatVersion: 2
guid: 3ac57b45e32d4e742b7ee5f0e5ad1cda
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

77
SampleScenes/Common/Textures/Alexs_Apt_2k.hdr.meta


fileFormatVersion: 2
guid: 7ab4e79cadc728f41bb8678cad593a13
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

139
SampleScenes/Common/Textures/Alexs_Apt_2k_cube.hdr.meta


fileFormatVersion: 2
guid: 8714eafe2130af14b835106673e808d1
TextureImporter:
fileIDToRecycleName:
8900000: generatedCubemap
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 2
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 2
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: tvOS
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Windows Store Apps
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: PS4
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

8
SampleScenes/CoreTest.meta


fileFormatVersion: 2
guid: 35e65ef485d9f994d9d6519b4b27fc7a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

122
ScriptableRenderPipeline/Core/EncodeBC6H.cs


using UnityEngine.Assertions;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering
{
public class EncodeBC6H
{
public static EncodeBC6H DefaultInstance;
static readonly int _Source = Shader.PropertyToID("_Source");
static readonly int _Target = Shader.PropertyToID("_Target");
static readonly int _MipIndex = Shader.PropertyToID("_MipIndex");
static readonly int[] __Tmp_RT =
{
Shader.PropertyToID("__Tmp_RT0"),
Shader.PropertyToID("__Tmp_RT1"),
Shader.PropertyToID("__Tmp_RT2"),
Shader.PropertyToID("__Tmp_RT3"),
Shader.PropertyToID("__Tmp_RT4"),
Shader.PropertyToID("__Tmp_RT5"),
Shader.PropertyToID("__Tmp_RT6"),
Shader.PropertyToID("__Tmp_RT7"),
Shader.PropertyToID("__Tmp_RT8"),
Shader.PropertyToID("__Tmp_RT9"),
Shader.PropertyToID("__Tmp_RT10"),
Shader.PropertyToID("__Tmp_RT11"),
Shader.PropertyToID("__Tmp_RT12"),
Shader.PropertyToID("__Tmp_RT13")
};
readonly ComputeShader m_Shader;
readonly int m_KEncodeFastCubemapMip;
public EncodeBC6H(ComputeShader shader)
{
Assert.IsNotNull(shader);
m_Shader = shader;
m_KEncodeFastCubemapMip = m_Shader.FindKernel("KEncodeFastCubemapMip");
uint x, y, z;
m_Shader.GetKernelThreadGroupSizes(m_KEncodeFastCubemapMip, out x, out y, out z);
}
// Only use mode11 of BC6H encoding
/// <summary>
/// Encode a Cubemap in BC6H.
///
/// It will encode all faces and selected mips of the Cubemap.
///
/// It uses only mode 11 of BC6H.
/// </summary>
/// <param name="cmb">Command buffer for execution</param>
/// <param name="source">The source Cubemap</param>
/// <param name="sourceSize">The size of the source Cubemap</param>
/// <param name="target">The compressed texture.
/// It must be a BC6H Cubemap or Cubemap array with the same size as the source Cubemap</param>
/// <param name="fromMip">Starting mip to encode</param>
/// <param name="toMip">Last mip to encode</param>
/// <param name="targetArrayIndex">The index of the cubemap to store the compressed texture.
///
/// Only relevant when target is a CubemapArray</param>
public void EncodeFastCubemap(CommandBuffer cmb, RenderTargetIdentifier source, int sourceSize, RenderTargetIdentifier target, int fromMip, int toMip, int targetArrayIndex = 0)
{
var maxMip = Mathf.Max(0, (int)(Mathf.Log(sourceSize) / Mathf.Log(2)) - 2);
var actualFromMip = (int)Mathf.Clamp(fromMip, 0, maxMip);
var actualToMip = (int)Mathf.Min(maxMip, Mathf.Max(toMip, actualFromMip));
// Convert TextureCube source to Texture2DArray
var d = new RenderTextureDescriptor
{
autoGenerateMips = false,
bindMS = false,
colorFormat = RenderTextureFormat.ARGBInt,
depthBufferBits = 0,
dimension = TextureDimension.Tex2DArray,
enableRandomWrite = true,
msaaSamples = 1,
volumeDepth = 6,
sRGB = false,
useMipMap = false,
};
cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Source, source);
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
{
var size = (sourceSize >> mip) >> 2;
d.width = size;
d.height = size;
cmb.GetTemporaryRT(__Tmp_RT[mip], d);
}
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
{
var size = (sourceSize >> mip) >> 2;
cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Target, __Tmp_RT[mip]);
cmb.SetComputeIntParam(m_Shader, _MipIndex, mip);
cmb.DispatchCompute(m_Shader, m_KEncodeFastCubemapMip, size, size, 6);
}
var startSlice = 6 * targetArrayIndex;
for (var mip = fromMip; mip <= toMip; ++mip)
{
var rtMip = Mathf.Clamp(mip, actualFromMip, actualToMip);
for (var faceId = 0; faceId < 6; ++faceId)
cmb.CopyTexture(__Tmp_RT[rtMip], faceId, 0, target, startSlice + faceId, mip);
}
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
cmb.ReleaseTemporaryRT(__Tmp_RT[mip]);
}
}
public static class BC6HExtensions
{
public static void BC6HEncodeFastCubemap(this CommandBuffer cmb, RenderTargetIdentifier source, int sourceSize, RenderTargetIdentifier target, int fromMip, int toMip, int targetArrayIndex = 0)
{
EncodeBC6H.DefaultInstance.EncodeFastCubemap(cmb, source, sourceSize, target, fromMip, toMip, targetArrayIndex);
}
}
}

13
ScriptableRenderPipeline/Core/EncodeBC6H.cs.meta


fileFormatVersion: 2
guid: ef7e375d470b6404a9e355690703502b
timeCreated: 1507290672
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

49
ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute


#include "../ShaderLibrary/Common.hlsl"
#include "../ShaderLibrary/BC6H.hlsl"
#include "../ShaderLibrary/Sampling.hlsl"
TextureCube<float4> _Source;
RWTexture2DArray<uint4> _Target;
int _MipIndex;
SamplerState s_point_clamp;
static const uint2 kOffsets[] =
{
uint2(0, 0), uint2(1, 0), uint2(2, 0), uint2(3, 0),
uint2(0, 1), uint2(1, 1), uint2(2, 1), uint2(3, 1),
uint2(0, 2), uint2(1, 2), uint2(2, 2), uint2(3, 2),
uint2(0, 3), uint2(1, 3), uint2(2, 3), uint2(3, 3),
};
#pragma kernel KEncodeFastCubemapMip
[numthreads(1, 1, 1)]
void KEncodeFastCubemapMip(uint3 groupId : SV_GroupID, uint3 groupThreadId : SV_GroupThreadID, uint3 dispatchThreadId : SV_DispatchThreadID)
{
uint width = 0;
uint height = 0;
_Source.GetDimensions(width, height);
int size = width >> _MipIndex;
// Load 4x4 pixel block
float3 texels[16];
uint2 topLeftSourceID = dispatchThreadId.xy << 2;
uint faceId = dispatchThreadId.z;
float2 nvc;
float3 dir;
for (uint i = 0u; i < 16; ++i)
{
nvc = CubemapTexelToNVC(topLeftSourceID + kOffsets[i], size);
dir = CubemapTexelToDirection(nvc, faceId);
texels[i] = _Source.SampleLevel(s_point_clamp, dir, _MipIndex).rgb;
}
uint4 block = uint4(0, 0, 0, 0);
float blockMSLE = 0;
EncodeMode11(block, blockMSLE, texels);
_Target[dispatchThreadId] = block;
}

10
ScriptableRenderPipeline/Core/Resources/EncodeBC6H.compute.meta


fileFormatVersion: 2
guid: b69b95b3420fd904e8530b79f665a1f8
timeCreated: 1507123133
licenseType: Pro
ComputeShaderImporter:
externalObjects: {}
currentAPIMask: 4
userData:
assetBundleName:
assetBundleVariant:

176
ScriptableRenderPipeline/Core/ShaderLibrary/BC6H.hlsl


// Ref: https://github.com/knarkowicz/GPURealTimeBC6H/blob/master/bin/compress.hlsl
// Doc: https://msdn.microsoft.com/en-us/library/windows/desktop/hh308952(v=vs.85).aspx
#include "Common.hlsl"
// Measure compression error
float CalcMSLE(float3 a, float3 b)
{
float3 err = log2(( b + 1.0f) / (a + 1.0f ));
err = err * err;
return err.x + err.y + err.z;
}
// Quantification Helpers
float3 Quantize7(float3 x)
{
return (f32tof16(x) * 128.0f) / (0x7bff + 1.0f);
}
float3 Quantize9(float3 x)
{
return (f32tof16(x) * 512.0f) / (0x7bff + 1.0f);
}
float3 Quantize10(float3 x)
{
return (f32tof16(x) * 1024.0f) / (0x7bff + 1.0f);
}
float3 Unquantize7(float3 x)
{
return (x * 65536.0f + 0x8000) / 128.0f;
}
float3 Unquantize9(float3 x)
{
return (x * 65536.0f + 0x8000) / 512.0f;
}
float3 Unquantize10(float3 x)
{
return (x * 65536.0f + 0x8000) / 1024.0f;
}
// BC6H Helpers
// Compute index of a texel projected against endpoints
uint ComputeIndex3( float texelPos, float endPoint0Pos, float endPoint1Pos )
{
float r = ( texelPos - endPoint0Pos ) / ( endPoint1Pos - endPoint0Pos );
return (uint) clamp( r * 6.98182f + 0.00909f + 0.5f, 0.0f, 7.0f );
}
uint ComputeIndex4( float texelPos, float endPoint0Pos, float endPoint1Pos )
{
float r = ( texelPos - endPoint0Pos ) / ( endPoint1Pos - endPoint0Pos );
return (uint) clamp( r * 14.93333f + 0.03333f + 0.5f, 0.0f, 15.0f );
}
void SignExtend( inout float3 v1, uint mask, uint signFlag )
{
int3 v = (int3) v1;
v.x = ( v.x & mask ) | ( v.x < 0 ? signFlag : 0 );
v.y = ( v.y & mask ) | ( v.y < 0 ? signFlag : 0 );
v.z = ( v.z & mask ) | ( v.z < 0 ? signFlag : 0 );
v1 = v;
}
// 2nd step for unquantize
float3 FinishUnquantize( float3 endpoint0Unq, float3 endpoint1Unq, float weight )
{
float3 comp = ( endpoint0Unq * ( 64.0f - weight ) + endpoint1Unq * weight + 32.0f ) * ( 31.0f / 4096.0f );
return f16tof32( uint3( comp ) );
}
// BC6H Modes
void EncodeMode11( inout uint4 block, inout float blockMSLE, float3 texels[ 16 ] )
{
// compute endpoints (min/max RGB bbox)
float3 blockMin = texels[ 0 ];
float3 blockMax = texels[ 0 ];
for ( uint i = 1; i < 16; ++i )
{
blockMin = min( blockMin, texels[ i ] );
blockMax = max( blockMax, texels[ i ] );
}
// refine endpoints in log2 RGB space
float3 refinedBlockMin = blockMax;
float3 refinedBlockMax = blockMin;
for (i = 0; i < 16; ++i )
{
refinedBlockMin = min( refinedBlockMin, texels[ i ] == blockMin ? refinedBlockMin : texels[ i ] );
refinedBlockMax = max( refinedBlockMax, texels[ i ] == blockMax ? refinedBlockMax : texels[ i ] );
}
float3 logBlockMax = log2( blockMax + 1.0f );
float3 logBlockMin = log2( blockMin + 1.0f );
float3 logRefinedBlockMax = log2( refinedBlockMax + 1.0f );
float3 logRefinedBlockMin = log2( refinedBlockMin + 1.0f );
float3 logBlockMaxExt = ( logBlockMax - logBlockMin ) * ( 1.0f / 32.0f );
logBlockMin += min( logRefinedBlockMin - logBlockMin, logBlockMaxExt );
logBlockMax -= min( logBlockMax - logRefinedBlockMax, logBlockMaxExt );
blockMin = exp2( logBlockMin ) - 1.0f;
blockMax = exp2( logBlockMax ) - 1.0f;
float3 blockDir = blockMax - blockMin;
blockDir = blockDir / ( blockDir.x + blockDir.y + blockDir.z );
float3 endpoint0 = Quantize10( blockMin );
float3 endpoint1 = Quantize10( blockMax );
float endPoint0Pos = f32tof16( dot( blockMin, blockDir ) );
float endPoint1Pos = f32tof16( dot( blockMax, blockDir ) );
// check if endpoint swap is required
float fixupTexelPos = f32tof16( dot( texels[ 0 ], blockDir ) );
uint fixupIndex = ComputeIndex4( fixupTexelPos, endPoint0Pos, endPoint1Pos );
if ( fixupIndex > 7 )
{
Swap( endPoint0Pos, endPoint1Pos );
Swap( endpoint0, endpoint1 );
}
// compute indices
uint indices[ 16 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (i = 0; i < 16; ++i )
{
float texelPos = f32tof16( dot( texels[ i ], blockDir ) );
indices[ i ] = ComputeIndex4( texelPos, endPoint0Pos, endPoint1Pos );
}
// compute compression error (MSLE)
float3 endpoint0Unq = Unquantize10( endpoint0 );
float3 endpoint1Unq = Unquantize10( endpoint1 );
float msle = 0.0f;
for (i = 0; i < 16; ++i )
{
float weight = floor( ( indices[ i ] * 64.0f ) / 15.0f + 0.5f );
float3 texelUnc = FinishUnquantize( endpoint0Unq, endpoint1Unq, weight );
msle += CalcMSLE( texels[ i ], texelUnc );
}
// encode block for mode 11
blockMSLE = msle;
block.x = 0x03;
// endpoints
block.x |= (uint) endpoint0.x << 5;
block.x |= (uint) endpoint0.y << 15;
block.x |= (uint) endpoint0.z << 25;
block.y |= (uint) endpoint0.z >> 7;
block.y |= (uint) endpoint1.x << 3;
block.y |= (uint) endpoint1.y << 13;
block.y |= (uint) endpoint1.z << 23;
block.z |= (uint) endpoint1.z >> 9;
// indices
block.z |= indices[ 0 ] << 1;
block.z |= indices[ 1 ] << 4;
block.z |= indices[ 2 ] << 8;
block.z |= indices[ 3 ] << 12;
block.z |= indices[ 4 ] << 16;
block.z |= indices[ 5 ] << 20;
block.z |= indices[ 6 ] << 24;
block.z |= indices[ 7 ] << 28;
block.w |= indices[ 8 ] << 0;
block.w |= indices[ 9 ] << 4;
block.w |= indices[ 10 ] << 8;
block.w |= indices[ 11 ] << 12;
block.w |= indices[ 12 ] << 16;
block.w |= indices[ 13 ] << 20;
block.w |= indices[ 14 ] << 24;
block.w |= indices[ 15 ] << 28;
}

10
ScriptableRenderPipeline/Core/ShaderLibrary/BC6H.hlsl.meta


fileFormatVersion: 2
guid: 27d419a4917d0ea49978c236e058d464
timeCreated: 1507282342
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

198
SampleScenes/Common/Materials/Mat_Test_CubemapDebug.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Mat_Test_CubemapDebug
m_Shader: {fileID: 4800000, guid: 52626b3f25f2ae94bb64059e8f42c487, type: 3}
m_ShaderKeywords: _ALBEDOAFFECTEMISSIVE_OFF _ALPHACUTOFFENABLE_OFF _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
_DEPTHOFFSETENABLE_OFF _DISTORTIONENABLE_OFF _DOUBLESIDEDENABLE_OFF _ENABLESPECULAROCCLUSION_OFF
_ENABLEWIND_OFF _NORMALMAP_TANGENT_SPACE _PREREFRACTIONPASS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 2800000, guid: 7ab4e79cadc728f41bb8678cad593a13, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorMap:
m_Texture: {fileID: 8900000, guid: 8714eafe2130af14b835106673e808d1, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Diffuse:
m_Texture: {fileID: 8900000, guid: 8714eafe2130af14b835106673e808d1, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 7ab4e79cadc728f41bb8678cad593a13, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AORemapMax: 1
- _AORemapMin: 0
- _ATDistance: 1
- _AlbedoAffectEmissive: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _CoatCoverage: 1
- _CoatIOR: 0.5
- _CullMode: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DisplacementLockObjectScale: 1
- _DisplacementLockTilingScale: 1
- _DisplacementMode: 0
- _DistortionBlendMode: 0
- _DistortionBlurBlendMode: 0
- _DistortionBlurDstBlend: 1
- _DistortionBlurRemapMax: 1
- _DistortionBlurRemapMin: 0
- _DistortionBlurScale: 1
- _DistortionBlurSrcBlend: 1
- _DistortionDepthTest: 1
- _DistortionDstBlend: 1
- _DistortionEnable: 0
- _DistortionScale: 1
- _DistortionSrcBlend: 1
- _DistortionVectorBias: -1
- _DistortionVectorScale: 2
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _EnableBlendModePreserveSpecularLighting: 1
- _EnableFogOnTransparent: 1
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _Glossiness: 0.5
- _HeightAmplitude: 0.02
- _HeightCenter: 0.5
- _HeightMax: 1
- _HeightMin: -1
- _IOR: 1
- _InitialBend: 1
- _InvTilingScale: 1
- _LinkDetailsWithBase: 1
- _MaterialID: 1
- _Metallic: 0
- _MipIndex: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _PPDPrimitiveLength: 1
- _PPDPrimitiveWidth: 1
- _PreRefractionPass: 0
- _RefractionMode: 0
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SrcBlend: 1
- _StencilRef: 2
- _Stiffness: 1
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _SurfaceType: 0
- _TexWorldScale: 1
- _Thickness: 1
- _ThicknessMultiplier: 1
- _UVBase: 0
- _UVDetail: 0
- _ZTestMode: 4
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}

8
SampleScenes/Common/Materials/Mat_Test_CubemapDebug.mat.meta


fileFormatVersion: 2
guid: 78e152488d58e8242bf90ac931fc7c68
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

194
SampleScenes/Common/Materials/Mat_Test_Unlit.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Mat_Test_Unlit
m_Shader: {fileID: 4800000, guid: c4edd00ff2db5b24391a4fcb1762e459, type: 3}
m_ShaderKeywords: _ALBEDOAFFECTEMISSIVE_OFF _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF
_DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _DOUBLESIDEDENABLE_OFF _ENABLESPECULAROCCLUSION_OFF
_ENABLEWIND_OFF _PREREFRACTIONPASS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TransmittanceColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _UnlitColorMap:
m_Texture: {fileID: 2800000, guid: 7ab4e79cadc728f41bb8678cad593a13, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AORemapMax: 1
- _AORemapMin: 0
- _ATDistance: 1
- _AlbedoAffectEmissive: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _CoatCoverage: 1
- _CoatIOR: 0.5
- _CullMode: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DisplacementLockObjectScale: 1
- _DisplacementLockTilingScale: 1
- _DisplacementMode: 0
- _DistortionBlendMode: 0
- _DistortionBlurBlendMode: 0
- _DistortionBlurDstBlend: 1
- _DistortionBlurRemapMax: 1
- _DistortionBlurRemapMin: 0
- _DistortionBlurScale: 1
- _DistortionBlurSrcBlend: 1
- _DistortionDepthTest: 1
- _DistortionDstBlend: 1
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DistortionScale: 1
- _DistortionSrcBlend: 1
- _DistortionVectorBias: -1
- _DistortionVectorScale: 2
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _EnableBlendModePreserveSpecularLighting: 1
- _EnableFogOnTransparent: 1
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _HeightAmplitude: 0.02
- _HeightCenter: 0.5
- _HeightMax: 1
- _HeightMin: -1
- _IOR: 1
- _InitialBend: 1
- _InvTilingScale: 1
- _LinkDetailsWithBase: 1
- _MaterialID: 1
- _Metallic: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _PPDPrimitiveLength: 1
- _PPDPrimitiveWidth: 1
- _PreRefractionPass: 0
- _RefractionMode: 0
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SrcBlend: 1
- _StencilRef: 2
- _Stiffness: 1
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _SurfaceType: 0
- _TexWorldScale: 1
- _Thickness: 1
- _ThicknessMultiplier: 1
- _UVBase: 0
- _UVDetail: 0
- _ZTestMode: 4
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 1, g: 1, b: 1, a: 1}
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UnlitColor: {r: 1, g: 1, b: 1, a: 1}

8
SampleScenes/Common/Materials/Mat_Test_Unlit.mat.meta


fileFormatVersion: 2
guid: 1df706eb139563743a23dbac2becc078
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

62
SampleScenes/Common/Shaders/CubemapColorMap.shader


Shader "Hidden/CubemapColorMap" {
Properties {
_ColorMap("Color", Cube) = "white" {}
_MipIndex("Mip Index", Int) = 0
}
HLSLINCLUDE
#pragma target 5.0
#include "UnityCG.cginc"
TextureCube _ColorMap;
int _MipIndex;
SamplerState s_bilinear_clamp;
struct appdata {
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct v2f {
float4 positionCS : SV_POSITION;
float3 normalWS : TEXCOORD0;
};
v2f Vert(appdata i) {
v2f o;
float4 positionCS = UnityObjectToClipPos(i.positionOS);
float3 normalWS = normalize(mul(i.normalOS, (float3x3)unity_WorldToObject));
o.positionCS = positionCS;
o.normalWS = normalWS;
return o;
}
float4 Frag(v2f i) : SV_Target {
float3 col = _ColorMap.SampleLevel(s_bilinear_clamp, i.normalWS, _MipIndex).xyz;
return float4(col, 0.5);
}
#pragma vertex Vert
#pragma fragment Frag
ENDHLSL
SubShader {
Pass {
Name "ForwardUnlit"
Tags{ "LightMode" = "ForwardOnly" }
Blend One Zero
ZWrite On
Cull Back
HLSLPROGRAM
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
ENDHLSL
}
}
}

8
SampleScenes/Common/Shaders/CubemapColorMap.shader.meta


fileFormatVersion: 2
guid: 52626b3f25f2ae94bb64059e8f42c487
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

7
SampleScenes/CoreTest/Test_BC6HCompression.unity.meta


fileFormatVersion: 2
guid: 433aa972fff1ec44ca66dab7228e336b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/0xxx.meta


fileFormatVersion: 2
guid: 405d053465ae98342849302f26ddfee0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存