浏览代码

Fix various issue, remove previous code

/main
sebastienlagarde 7 年前
当前提交
25cb23c4
共有 9 个文件被更改,包括 47 次插入158 次删除
  1. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl
  2. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader
  3. 21
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
  5. 37
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  6. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  7. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs
  8. 111
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BlitMipFlip.shader
  9. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BlitMipFlip.shader.meta

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl


else if (index == 8)
outColor = real3(0.75, 1.0, 0.25);
else if (index == 9)
outColor = real3(0.75, 0.25, 1.0);
outColor = real3(0.75, 0.25, 1.0);
outColor = real3(0.25, 1.0, 0.75);
outColor = real3(0.25, 1.0, 0.75);
outColor = real3(0.75, 0.75, 0.25);
outColor = real3(0.75, 0.75, 0.25);
outColor = real3(0.75, 0.25, 0.75);
outColor = real3(0.75, 0.25, 0.75);
outColor = real3(0.25, 0.75, 0.75);
outColor = real3(0.25, 0.75, 0.75);
outColor = real3(0.25, 0.25, 0.75);
outColor = real3(0.25, 0.25, 0.75);
else if (index == 15)
outColor = real3(0.75, 0.25, 0.25);

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader


int _ColorPickerMode;
float3 _ColorPickerFontColor;
float _ApplyLinearToSRGB;
float _RequireToFlipInputTexture;
struct Attributes
{

float4 Frag(Varyings input) : SV_Target
{
if (_RequireToFlipInputTexture > 0.0)
{
input.texcoord.y = 1.0 - input.texcoord.y;
}
return DisplayPixelInformationAtMousePosition(input, result, mouseResult);
float4 finalResult = DisplayPixelInformationAtMousePosition(input, result, mouseResult);
return finalResult;
}
ENDHLSL

21
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader


TEXTURE2D(_DebugFullScreenTexture);
SAMPLER(sampler_DebugFullScreenTexture);
float _FullScreenDebugMode;
float _RequireToFlipInputTexture;
struct Attributes
{

float4 Frag(Varyings input) : SV_Target
{
if (_RequireToFlipInputTexture > 0.0)
{
input.texcoord.y = 1.0 - input.texcoord.y;
}
// SSAO
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_SSAO)
{

float g = 2.0 - abs(hue * 6.0 - 2.0);
float b = 2.0 - abs(hue * 6.0 - 4.0);
float3 color = saturate(normalize(float3(mv,0)));
// float3 color = saturate(float3(r, g, b) * kIntensity);
float3 color = saturate(float3(r, g, b) * kIntensity);
// Grid subdivisions - should be dynamic
const float kGrid = 64.0;

// Sample the center of the cell to get the current arrow vector
float2 arrow_coord = center / _ScreenParams.xy;
if (_RequireToFlipInputTexture > 0.0)
{
arrow_coord.y = 1.0 - arrow_coord.y;
}
if (_RequireToFlipInputTexture == 0.0)
{
mv_arrow.y *= -1;
}
// Skip empty motion
float d = 0.0;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs


newAsset.cameraMotionVectors = Load<Shader>(HDRenderPipelinePath + "RenderPipelineResources/CameraMotionVectors.shader");
newAsset.copyStencilBuffer = Load<Shader>(HDRenderPipelinePath + "RenderPipelineResources/CopyStencilBuffer.shader");
newAsset.blit = Load<Shader>(HDRenderPipelinePath + "RenderPipelineResources/Blit.shader");
newAsset.blitFlipMip = Load<Shader>(HDRenderPipelinePath + "RenderPipelineResources/BlitFlipMip.shader");
// Sky
newAsset.blitCubemap = Load<Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader");

37
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


Material m_DebugFullScreen;
Material m_DebugColorPicker;
Material m_Blit;
Material m_BlitFlipMip;
Material m_ErrorMaterial;
// Various buffer

m_DebugFullScreen = CoreUtils.CreateEngineMaterial(m_Asset.renderPipelineResources.debugFullScreenShader);
m_DebugColorPicker = CoreUtils.CreateEngineMaterial(m_Asset.renderPipelineResources.debugColorPickerShader);
m_Blit = CoreUtils.CreateEngineMaterial(m_Asset.renderPipelineResources.blit);
m_BlitFlipMip = CoreUtils.CreateEngineMaterial(m_Asset.renderPipelineResources.blitFlipMip);
m_ErrorMaterial = CoreUtils.CreateEngineMaterial("Hidden/InternalErrorShader");
}

CoreUtils.Destroy(m_DebugFullScreen);
CoreUtils.Destroy(m_DebugColorPicker);
CoreUtils.Destroy(m_Blit);
CoreUtils.Destroy(m_BlitFlipMip);
CoreUtils.Destroy(m_ErrorMaterial);
m_SSSBufferManager.Cleanup();

}
// allowFlip is false if we call the function after the FinalPass or cmd.Blit that flip the screen
public void PushColorPickerDebugTexture(CommandBuffer cmd, RenderTargetIdentifier textureID, HDCamera hdCamera, bool allowFlip = true)
public void PushColorPickerDebugTexture(CommandBuffer cmd, RenderTargetIdentifier textureID, HDCamera hdCamera)
// RenderDebug() is call after the final pass that flip the screen (if we are not SceneView).
// Mean that when we push the buffer here, we need to flip it to display correctly.
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView && allowFlip;
m_BlitFlipMip.SetFloat(HDShaderIDs._MipIndex, 0);
cmd.Blit(textureID, m_DebugColorPickerRT, m_BlitFlipMip, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flip
cmd.Blit(textureID, m_DebugColorPickerRT);
}
}

m_FullScreenDebugPushed = true; // We need this flag because otherwise if no full screen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cmd.ReleaseTemporaryRT(m_DebugFullScreenTempRT);
CoreUtils.CreateCmdTemporaryRT(cmd, m_DebugFullScreenTempRT, hdCamera.renderTextureDesc, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
// RenderDebug() is call after the final pass that flip the screen (if we are not SceneView).
// Mean that when we push the buffer here, we need to flip it to display correctly.
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView;
m_BlitFlipMip.SetFloat(HDShaderIDs._MipIndex, 0);
cmd.Blit(textureID, m_DebugFullScreenTempRT, m_BlitFlipMip, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flipY
cmd.Blit(textureID, m_DebugFullScreenTempRT);
}
}

desc.height = desc.height >> mipIndex;
CoreUtils.CreateCmdTemporaryRT(cmd, m_DebugFullScreenTempRT, desc, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
// TODO: TexArray
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView;
m_BlitFlipMip.SetFloat(HDShaderIDs._MipIndex, mipIndex);
cmd.Blit(textureID, m_DebugFullScreenTempRT, m_BlitFlipMip, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flipY
cmd.CopyTexture(textureID, 0, mipIndex, m_DebugFullScreenTempRT, 0, 0); // TODO: Support tex arrays
}
}

desc.height = desc.height >> mipIndex;
CoreUtils.CreateCmdTemporaryRT(cmd, m_DebugFullScreenTempRT, desc, 0, FilterMode.Point, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear);
// TODO: TexArray
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView;
m_BlitFlipMip.SetFloat(HDShaderIDs._MipIndex, mipIndex);
cmd.Blit(textureID, m_DebugFullScreenTempRT, m_BlitFlipMip, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flipY
cmd.CopyTexture(textureID, 0, mipIndex, m_DebugFullScreenTempRT, 0, 0); // TODO: Support tex arrays
}
}

cmd.SetGlobalTexture(HDShaderIDs._DebugFullScreenTexture, m_DebugFullScreenTempRT);
// TODO: Replace with command buffer call when available
m_DebugFullScreen.SetFloat(HDShaderIDs._FullScreenDebugMode, (float)m_CurrentDebugDisplaySettings.fullScreenDebugMode);
// Everything we have capture is flipped (as it happen before FinalPass/postprocess/Blit. So if we are not in SceneView
// (i.e. we have perform a flip, we need to flip the input texture)
m_DebugFullScreen.SetFloat(HDShaderIDs._RequireToFlipInputTexture, hdCamera.camera.cameraType != CameraType.SceneView ? 1.0f : 0.0f);
PushColorPickerDebugTexture(cmd, m_DebugFullScreenTempRT, hdCamera, false); // We are in RenderDebug() here so we msut not flip the copy
PushColorPickerDebugTexture(cmd, m_DebugFullScreenTempRT, hdCamera);
}
// Then overlays

// The material display debug perform sRGBToLinear conversion as the final blit currently hardcode a linearToSrgb conversion. As when we read with color picker this is not done,
// we perform it inside the color picker shader. But we shouldn't do it for HDR buffer.
m_DebugColorPicker.SetFloat(HDShaderIDs._ApplyLinearToSRGB, m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled() ? 1.0f : 0.0f);
// Everything we have capture is flipped (as it happen before FinalPass/postprocess/Blit. So if we are not in SceneView
// (i.e. we have perform a flip, we need to flip the input texture) + we need to handle the case were we debug a fullscreen pass that have already perform the flip
m_DebugColorPicker.SetFloat(HDShaderIDs._RequireToFlipInputTexture, hdCamera.camera.cameraType != CameraType.SceneView ? 1.0f : 0.0f);
//m_DebugFullScreen.SetFloat(HDShaderIDs._IsSceneView, (float)hdCamera.camera.cameraType == CameraType.SceneView ? 1.0f : 0.0f);
CoreUtils.DrawFullScreen(cmd, m_DebugColorPicker, (RenderTargetIdentifier)BuiltinRenderTextureType.CameraTarget);
}
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _ColorPickerMode = Shader.PropertyToID("_ColorPickerMode");
public static readonly int _ApplyLinearToSRGB = Shader.PropertyToID("_ApplyLinearToSRGB");
public static readonly int _ColorPickerFontColor = Shader.PropertyToID("_ColorPickerFontColor");
public static readonly int _RequireToFlipInputTexture = Shader.PropertyToID("_RequireToFlipInputTexture");
public static readonly int _MainTex = Shader.PropertyToID("_MainTex");
public static readonly int _MipIndex = Shader.PropertyToID("_MipIndex");
public static readonly int _WorldScales = Shader.PropertyToID("_WorldScales");
public static readonly int _FilterKernels = Shader.PropertyToID("_FilterKernels");

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs


public Shader cameraMotionVectors;
public Shader copyStencilBuffer;
public Shader blit;
public Shader blitFlipMip;
// Sky
public Shader blitCubemap;

111
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BlitMipFlip.shader


Shader "Hidden/HDRenderPipeline/BlitMipFlip"
{
Properties
{
_MainTex("Texture", any) = "" {} // Name it like in internal-BlitCopy so we can reuse the shader with Blit command
_MipIndex("MipIndex", Float) = 0
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "../ShaderVariables.hlsl"
TEXTURE2D(_MainTex); // Name it like in internal-BlitCopy so we can reuse the shader with Blit command
SamplerState sampler_PointClamp;
SamplerState sampler_LinearClamp;
float _MipIndex;
struct Attributes
{
uint vertexID : SV_VertexID;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID);
return output;
}
float4 FragNearest(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_PointClamp, input.texcoord, _MipIndex);
}
float4 FragBilinear(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_LinearClamp, input.texcoord, _MipIndex);
}
float4 FragNearestFlipY(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_PointClamp, float2(input.texcoord.x, 1.0 - input.texcoord.y), _MipIndex);
}
float4 FragBilinearFlipY(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_LinearClamp, float2(input.texcoord.x, 1.0 - input.texcoord.y), _MipIndex);
}
ENDHLSL
SubShader
{
// 0: Nearest
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragNearest
ENDHLSL
}
// 1: Bilinear
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragBilinear
ENDHLSL
}
// 2: Nearest + flipY
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragNearestFlipY
ENDHLSL
}
// 3: Bilinear + flipY
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragBilinearFlipY
ENDHLSL
}
}
Fallback Off
}

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BlitMipFlip.shader.meta


fileFormatVersion: 2
guid: ef092fc4aaa1bb546a9ab4e457c4b07a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存