浏览代码

Address the PR feedback

/RenderPassXR_Sandbox
Evgenii Golubev 8 年前
当前提交
d8386bd4
共有 13 个文件被更改,包括 52 次插入48 次删除
  1. 42
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Deferred.shader
  3. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  4. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  5. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  6. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  7. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  8. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
  9. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/GGXConvolve.shader
  10. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
  11. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  12. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  13. 40
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs

42
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


m_Cleanup.Clear();
}
public void SetupGlobalParams(CommandBuffer cmd)
{
cmd.SetGlobalMatrix("_ViewMatrix", viewMatrix);
cmd.SetGlobalMatrix("_InvViewMatrix", viewMatrix.inverse);
cmd.SetGlobalMatrix("_ProjMatrix", projMatrix);
cmd.SetGlobalMatrix("_InvProjMatrix", projMatrix.inverse);
cmd.SetGlobalMatrix("_ViewProjMatrix", viewProjMatrix);
cmd.SetGlobalMatrix("_InvViewProjMatrix", viewProjMatrix.inverse);
cmd.SetGlobalVector("_InvProjParam", invProjParam);
cmd.SetGlobalVector("_ScreenSize", screenSize);
cmd.SetGlobalMatrix("_PrevViewProjMatrix", prevViewProjMatrix);
}
// Does not modify global settings. Used for shadows, low res. rendering, etc.
public void OverrideGlobalParams(Material material)
{
material.SetMatrix("_ViewMatrix", viewMatrix);
material.SetMatrix("_InvViewMatrix", viewMatrix.inverse);
material.SetMatrix("_ProjMatrix", projMatrix);
material.SetMatrix("_InvProjMatrix", projMatrix.inverse);
material.SetMatrix("_ViewProjMatrix", viewProjMatrix);
material.SetMatrix("_InvViewProjMatrix", viewProjMatrix.inverse);
material.SetVector("_InvProjParam", invProjParam);
material.SetVector("_ScreenSize", screenSize);
material.SetMatrix("_PrevViewProjMatrix", prevViewProjMatrix);
}
public void SetupComputeShader(ComputeShader cs, CommandBuffer cmd)
{
Utilities.SetMatrixCS(cmd, cs, "_ViewMatrix", viewMatrix);
Utilities.SetMatrixCS(cmd, cs, "_InvViewMatrix", viewMatrix.inverse);
Utilities.SetMatrixCS(cmd, cs, "_ProjMatrix", projMatrix);
Utilities.SetMatrixCS(cmd, cs, "_InvProjMatrix", projMatrix.inverse);
Utilities.SetMatrixCS(cmd, cs, "_ViewProjMatrix", viewProjMatrix);
Utilities.SetMatrixCS(cmd, cs, "_InvViewProjMatrix", viewProjMatrix.inverse);
cmd.SetComputeVectorParam( cs, "_InvProjParam", invProjParam);
cmd.SetComputeVectorParam( cs, "_ScreenSize", screenSize);
Utilities.SetMatrixCS(cmd, cs, "_PrevViewProjMatrix", prevViewProjMatrix);
}
}
public class GBufferManager

{
var cmd = CommandBufferPool.Get("Push Global Parameters");
Utilities.SetupGlobalHDCamera(hdCamera, cmd);
hdCamera.SetupGlobalParams(cmd);
// TODO: cmd.SetGlobalInt() does not exist, so we are forced to use Shader.SetGlobalInt() instead.

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Deferred.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
#pragma vertex Vert
#pragma fragment Frag

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_LtcDisneyDiffuseMatrix", Shader.GetGlobalTexture("_LtcDisneyDiffuseMatrix"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_LtcMultiGGXFresnelDisneyDiffuse", Shader.GetGlobalTexture("_LtcMultiGGXFresnelDisneyDiffuse"));
Utilities.SetupComputeShaderHDCamera(hdCamera, shadeOpaqueShader, cmd);
hdCamera.SetupComputeShader(shadeOpaqueShader, cmd);
Utilities.SetMatrixCS(cmd, shadeOpaqueShader, "g_mInvScrProjection", Shader.GetGlobalMatrix("g_mInvScrProjection"));
cmd.SetComputeIntParam(shadeOpaqueShader, "_UseTileLightList", Shader.GetGlobalInt("_UseTileLightList"));

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


#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON

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


#pragma target 5.0
#pragma only_renderers d3d11 ps4 // TEMP: until we go further in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON

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


#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go futher in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

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


#pragma target 5.0
#pragma only_renderers d3d11 ps4// TEMP: until we go futher in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader


#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/GGXConvolve.shader


Varyings Vert(Attributes input)
{
Varyings output;
// Unity renders upside down, so the clip space coordinates have to be flipped.
output.positionCS = float4(input.positionCS.x, -input.positionCS.y, UNITY_RAW_FAR_CLIP_VALUE, 1.0);
output.eyeVector = input.eyeVector;
return output;

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader


{
// TODO: implement SV_vertexID full screen quad
Varyings output;
// Unity renders upside down, so the clip space coordinates have to be flipped.
output.positionCS = float4(input.positionCS.x, -input.positionCS.y, UNITY_RAW_FAR_CLIP_VALUE, 1.0);
output.eyeVector = input.eyeVector;

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader


{
// TODO: implement SV_vertexID full screen quad
Varyings output;
// Unity renders upside down, so the clip space coordinates have to be flipped.
output.positionCS = float4(input.positionCS.x, -input.positionCS.y, UNITY_RAW_FAR_CLIP_VALUE, 1.0);
output.eyeVector = input.eyeVector;

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


protected Mesh BuildSkyMesh(Vector3 cameraPosition, Matrix4x4 cameraInvViewProjectionMatrix)
{
// These are clip space coords.
Vector4 vertData0 = new Vector4(-1.0f, -1.0f, 0.0f, 1.0f);
Vector4 vertData1 = new Vector4( 1.0f, -1.0f, 0.0f, 1.0f);
Vector4 vertData2 = new Vector4( 1.0f, 1.0f, 0.0f, 1.0f);

40
Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs


return gpuVP;
}
public static void SetupGlobalHDCamera(HDCamera hdCamera, CommandBuffer cmd)
{
cmd.SetGlobalMatrix("_ViewMatrix", hdCamera.viewMatrix);
cmd.SetGlobalMatrix("_InvViewMatrix", hdCamera.viewMatrix.inverse);
cmd.SetGlobalMatrix("_ProjMatrix", hdCamera.projMatrix);
cmd.SetGlobalMatrix("_InvProjMatrix", hdCamera.projMatrix.inverse);
cmd.SetGlobalMatrix("_ViewProjMatrix", hdCamera.viewProjMatrix);
cmd.SetGlobalMatrix("_InvViewProjMatrix", hdCamera.viewProjMatrix.inverse);
cmd.SetGlobalVector("_InvProjParam", hdCamera.invProjParam);
cmd.SetGlobalVector("_ScreenSize", hdCamera.screenSize);
cmd.SetGlobalMatrix("_PrevViewProjMatrix", hdCamera.prevViewProjMatrix);
}
// Does not modify global settings. Used for shadows, low res. rendering, etc.
public static void OverrideGlobalHDCamera(HDCamera hdCamera, Material material)
{
material.SetMatrix("_ViewMatrix", hdCamera.viewMatrix);
material.SetMatrix("_InvViewMatrix", hdCamera.viewMatrix.inverse);
material.SetMatrix("_ProjMatrix", hdCamera.projMatrix);
material.SetMatrix("_InvProjMatrix", hdCamera.projMatrix.inverse);
material.SetMatrix("_ViewProjMatrix", hdCamera.viewProjMatrix);
material.SetMatrix("_InvViewProjMatrix", hdCamera.viewProjMatrix.inverse);
material.SetVector("_InvProjParam", hdCamera.invProjParam);
material.SetVector("_ScreenSize", hdCamera.screenSize);
material.SetMatrix("_PrevViewProjMatrix", hdCamera.prevViewProjMatrix);
}
public static void SetupComputeShaderHDCamera(HDCamera hdCamera, ComputeShader cs, CommandBuffer cmd)
{
SetMatrixCS(cmd, cs, "_ViewMatrix", hdCamera.viewMatrix);
SetMatrixCS(cmd, cs, "_InvViewMatrix", hdCamera.viewMatrix.inverse);
SetMatrixCS(cmd, cs, "_ProjMatrix", hdCamera.projMatrix);
SetMatrixCS(cmd, cs, "_InvProjMatrix", hdCamera.projMatrix.inverse);
SetMatrixCS(cmd, cs, "_ViewProjMatrix", hdCamera.viewProjMatrix);
SetMatrixCS(cmd, cs, "_InvViewProjMatrix", hdCamera.viewProjMatrix.inverse);
cmd.SetComputeVectorParam(cs, "_InvProjParam", hdCamera.invProjParam);
cmd.SetComputeVectorParam(cs, "_ScreenSize", hdCamera.screenSize);
SetMatrixCS(cmd, cs, "_PrevViewProjMatrix", hdCamera.prevViewProjMatrix);
}
// TEMP: These functions should be implemented C++ side, for now do it in C#
static List<float> m_FloatListdata = new List<float>();
public static void SetMatrixCS(CommandBuffer cmd, ComputeShader shadercs, string name, Matrix4x4 mat)

正在加载...
取消
保存