浏览代码

Always do HDR in FPTL test, switch albedo buffers to LDR

/main
Aras Pranckevicius 8 年前
当前提交
f1c43935
共有 2 个文件被更改,包括 10 次插入18 次删除
  1. 22
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 6
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader

22
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


var format10 = RenderTextureFormat.ARGB32;
if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB2101010))
format10 = RenderTextureFormat.ARGB2101010;
var formatHDR = RenderTextureFormat.DefaultHDR;
//@TODO: cleanup, right now only because we want to use unmodified Standard shader that encodes emission differently based on HDR or not,
// so we make it think we always render in HDR
cmd.EnableShaderKeyword ("UNITY_HDR_ON");
cmd.GetTemporaryRT(kGBufferAlbedo, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferSpecRough, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferAlbedo, width, height, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferSpecRough, width, height, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferEmission, width, height, 0, FilterMode.Point, format10, RenderTextureReadWrite.Linear); //@TODO: HDR
cmd.GetTemporaryRT(kGBufferEmission, width, height, 0, FilterMode.Point, formatHDR, RenderTextureReadWrite.Linear);
cmd.GetTemporaryRT(kCameraTarget, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kCameraTarget, width, height, 0, FilterMode.Point, formatHDR, RenderTextureReadWrite.Default);
var colorMRTs = new RenderTargetIdentifier[4] { kGBufferAlbedo, kGBufferSpecRough, kGBufferNormal, kGBufferEmission };
cmd.SetRenderTarget(colorMRTs, new RenderTargetIdentifier(kGBufferZ));

ResizeIfNecessary(iW, iH);
//@TODO: cleanup, right now only because we want to use unmodified Standard shader that encodes emission differently based on HDR or not
if (camera.allowHDR)
Shader.EnableKeyword ("UNITY_HDR_ON");
else
Shader.DisableKeyword ("UNITY_HDR_ON");
// do anything we need to do upon a new frame.
NewFrame ();

//m_DeferredReflectionMaterial.SetInt("_DstBlend", camera.hdr ? (int)BlendMode.One : (int)BlendMode.Zero);
loop.SetupCameraProperties(camera);
UpdateShadowConstants(cullResults.visibleLights, ref shadows);
UpdateShadowConstants (cullResults.visibleLights, ref shadows);
RenderGBuffer(cullResults, camera, loop);

6
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


#pragma fragment frag
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
//@TODO: cleanup, right now only because we want to use unmodified Standard shader that encodes emission differently based on HDR or not
#pragma multi_compile ___ UNITY_HDR_ON
#include "UnityLightingCommon.cginc"

data.diffuseColor = gbuffer0.xyz; data.specularColor = gbuffer1.xyz;
float ao = gbuffer0.a;
data.emission = gbuffer3.xyz;
#ifndef UNITY_HDR_ON //@TODO: cleanup, right now only because we want to use unmodified Standard shader that encodes emission differently based on HDR or not
data.emission.rgb = -log2(data.emission.rgb);
#endif
return data;
}

正在加载...
取消
保存