浏览代码

FPTL: fix decoding of emission buffer

/main
Aras Pranckevicius 8 年前
当前提交
3333b3d3
共有 2 个文件被更改,包括 19 次插入5 次删除
  1. 16
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 8
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader

16
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


// render opaque objects using Deferred pass
DrawRendererSettings settings = new DrawRendererSettings(cull, camera, new ShaderPassName("Deferred"));
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;
settings.rendererConfiguration = RendererConfiguration.PerObjectLightmaps; //@TODO: need to get light probes + LPPV too?
settings.inputCullingOptions.SetQueuesOpaque();
loop.DrawRenderers(ref settings);
}

// render opaque objects using Deferred pass
DrawRendererSettings settings = new DrawRendererSettings(cull, camera, new ShaderPassName("ForwardSinglePass"));
//settings.rendererConfiguration = RendererConfiguration.PerObjectLightProbe | RendererConfiguration.PerObjectReflectionProbes;
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;
//settings.rendererConfiguration = RendererConfiguration.PerObjectLightProbe | RendererConfiguration.PerObjectReflectionProbes;
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;
if (opaquesOnly) settings.inputCullingOptions.SetQueuesOpaque();
loop.DrawRenderers(ref settings);
}

const float radToDeg = (float)(180.0 / pi);
//float sa = cl.GetSpotAngle(); // total field of view from left to right side
//float sa = cl.GetSpotAngle(); // total field of view from left to right side
float sa = radToDeg * (2 * Mathf.Acos(1.0f / cl.invCosHalfSpotAngle)); // spot angle doesn't exist in the structure so reversing it for now.

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");
NewFrame();
NewFrame ();
ShadowOutput shadows;
m_ShadowPass.Render(loop, cullResults, out shadows);

8
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;
}

g_localParams.Vworld = Vworld;
uint numLightsProcessed = 0;
float3 c = /*data.emission +*/ ExecuteLightListTiled(numLightsProcessed, pixCoord, vP, vPw, Vworld);
float3 c = data.emission + ExecuteLightListTiled(numLightsProcessed, pixCoord, vP, vPw, Vworld);
//c = OverlayHeatMap(numLightsProcessed, c);
return float4(c,1.0);

正在加载...
取消
保存