|
|
|
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Rendering; |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
cmd.SetComputeFloatParams(shadercs, name, data); |
|
|
|
} |
|
|
|
|
|
|
|
int UpdateDirectionalLights(Camera camera, ActiveLight[] activeLights) |
|
|
|
int UpdateDirectionalLights(Camera camera, VisibleLight[] visibleLights) |
|
|
|
for (int nLight = 0; nLight < activeLights.Length; nLight++) |
|
|
|
for (int nLight = 0; nLight < visibleLights.Length; nLight++) |
|
|
|
ActiveLight light = activeLights[nLight]; |
|
|
|
VisibleLight light = visibleLights[nLight]; |
|
|
|
if (light.lightType == LightType.Directional) |
|
|
|
{ |
|
|
|
Debug.Assert(dirLightCount < gMaxNumDirLights, "Too many directional lights."); |
|
|
|
|
|
|
return dirLightCount; |
|
|
|
} |
|
|
|
|
|
|
|
void UpdateShadowConstants(ActiveLight[] activeLights, ref ShadowOutput shadow) |
|
|
|
void UpdateShadowConstants(VisibleLight[] visibleLights, ref ShadowOutput shadow) |
|
|
|
{ |
|
|
|
int nNumLightsIncludingTooMany = 0; |
|
|
|
|
|
|
|
|
|
|
Vector4[] g_vLightFalloffParams = new Vector4[MAX_LIGHTS]; |
|
|
|
|
|
|
|
for (int nLight = 0; nLight < activeLights.Length; nLight++) |
|
|
|
for (int nLight = 0; nLight < visibleLights.Length; nLight++) |
|
|
|
ActiveLight light = activeLights[nLight]; |
|
|
|
VisibleLight light = visibleLights[nLight]; |
|
|
|
LightType lightType = light.lightType; |
|
|
|
Vector3 position = light.light.transform.position; |
|
|
|
Vector3 lightDir = light.light.transform.forward.normalized; |
|
|
|
|
|
|
|
|
|
|
int GenerateSourceLightBuffers(Camera camera, CullResults inputs) |
|
|
|
{ |
|
|
|
VisibleReflectionProbe[] probes = inputs.culledReflectionProbes; |
|
|
|
VisibleReflectionProbe[] probes = inputs.visibleReflectionProbes; |
|
|
|
int numLights = inputs.culledLights.Length; |
|
|
|
int numLights = inputs.visibleLights.Length; |
|
|
|
int numProbes = probes.Length; |
|
|
|
int numVolumes = numLights + numProbes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
uint shadowLightIndex = 0; |
|
|
|
foreach (var cl in inputs.culledLights) |
|
|
|
foreach (var cl in inputs.visibleLights) |
|
|
|
{ |
|
|
|
float range = cl.range; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderLoop.SetupCameraProperties(camera); |
|
|
|
|
|
|
|
UpdateLightConstants(cullResults.culledLights, ref shadows); |
|
|
|
UpdateLightConstants(cullResults.visibleLights, ref shadows); |
|
|
|
|
|
|
|
DrawRendererSettings settings = new DrawRendererSettings(cullResults, camera, new ShaderPassName("ForwardBase")); |
|
|
|
settings.rendererConfiguration = RendererConfiguration.ConfigureOneLightProbePerRenderer | RendererConfiguration.ConfigureReflectionProbesProbePerRenderer; |
|
|
|
|
|
|
//m_DeferredReflectionMaterial.SetInt("_DstBlend", camera.hdr ? (int)BlendMode.One : (int)BlendMode.Zero);
|
|
|
|
loop.SetupCameraProperties(camera); |
|
|
|
|
|
|
|
UpdateShadowConstants(cullResults.culledLights, ref shadows); |
|
|
|
UpdateShadowConstants(cullResults.visibleLights, ref shadows); |
|
|
|
|
|
|
|
RenderGBuffer(cullResults, camera, loop); |
|
|
|
|
|
|
|
|
|
|
loop.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|
|
|
|
|
int numDirLights = UpdateDirectionalLights(camera, cullResults.culledLights); |
|
|
|
int numDirLights = UpdateDirectionalLights(camera, cullResults.visibleLights); |
|
|
|
|
|
|
|
// Push all global params
|
|
|
|
PushGlobalParams(camera, loop, camera.cameraToWorldMatrix, projscr, invProjscr, numDirLights); |
|
|
|