Sebastien Lagarde 8 年前
当前提交
488f2a32
共有 3 个文件被更改,包括 15 次插入18 次删除
  1. 6
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 14
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 13
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs

6
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


// Draw opaque objects using BasicPass shader pass
var settings = new DrawRendererSettings (cull, camera, shaderPassBasic);
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;
settings.inputCullingOptions.SetQueuesOpaque ();
settings.inputFilter.SetQueuesOpaque ();
loop.DrawRenderers (ref settings);
// Draw skybox

settings.sorting.sortOptions = SortOptions.BackToFront; // sort back to front
settings.inputCullingOptions.SetQueuesTransparent ();
settings.inputFilter.SetQueuesTransparent ();
loop.DrawRenderers (ref settings);
loop.Submit ();

var dir = light.localToWorld.GetColumn (2);
lightSpotDirections[i] = new Vector4 (-dir.x, -dir.y, -dir.z, 0);
float radAngle = Mathf.Deg2Rad * light.light.spotAngle;
float radAngle = Mathf.Deg2Rad * light.spotAngle;
float cosTheta = Mathf.Cos (radAngle * 0.25f);
float cosPhi = Mathf.Cos (radAngle * 0.5f);
float cosDiff = cosTheta - cosPhi;

14
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


DrawRendererSettings settings = new DrawRendererSettings(cull, camera, new ShaderPassName(passName));
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;
settings.inputCullingOptions.SetQueuesOpaque();
settings.inputFilter.SetQueuesOpaque();
renderLoop.DrawRenderers(ref settings);
}

rendererConfiguration = RendererConfiguration.PerObjectLightProbe | RendererConfiguration.PerObjectReflectionProbes,
sorting = { sortOptions = SortOptions.SortByMaterialThenMesh }
};
settings.inputCullingOptions.SetQueuesTransparent();
settings.inputFilter.SetQueuesTransparent();
renderLoop.DrawRenderers(ref settings);
}

RenderOpaqueRenderList(cullResults, camera, renderLoop, "ForwardUnlit");
RenderTransparentRenderList(cullResults, camera, renderLoop, "ForwardUnlit");
}
}
void FinalPass(RenderLoop renderLoop)
{

if (light.lightType == LightType.Spot)
{
var spotAngle = light.light.spotAngle;
var spotAngle = light.spotAngle;
var innerConePercent = AdditionalLightData.GetInnerSpotPercent01(additionalLightData);
var cosSpotOuterHalfAngle = Mathf.Clamp(Mathf.Cos(spotAngle * 0.5f * Mathf.Deg2Rad), 0.0f, 1.0f);
var cosSpotInnerHalfAngle = Mathf.Clamp(Mathf.Cos(spotAngle * 0.5f * innerConePercent * Mathf.Deg2Rad), 0.0f, 1.0f); // inner cone

s.bias = light.light.shadowBias;
shadows.Add(s);
shadows.Add(s);
}
}

Shader.SetGlobalBuffer("_PunctualLightList", s_punctualLightList);
Shader.SetGlobalInt("_PunctualLightCount", lights.Count);
Shader.SetGlobalBuffer("_PunctualShadowList", s_punctualShadowList);
Shader.SetGlobalBuffer("_PunctualShadowList", s_punctualShadowList);
}
void UpdateReflectionProbes(VisibleReflectionProbe[] activeReflectionProbes)

13
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


};
//@TODO: need to get light probes + LPPV too?
settings.inputCullingOptions.SetQueuesOpaque();
settings.inputFilter.SetQueuesOpaque();
settings.rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe;
loop.DrawRenderers(ref settings);
}

sorting = { sortOptions = SortOptions.SortByMaterialThenMesh }
};
settings.rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe;
if (opaquesOnly) settings.inputCullingOptions.SetQueuesOpaque();
else settings.inputCullingOptions.SetQueuesTransparent();
if (opaquesOnly) settings.inputFilter.SetQueuesOpaque();
else settings.inputFilter.SetQueuesTransparent();
loop.DrawRenderers(ref settings);
}

{
sorting = { sortOptions = SortOptions.SortByMaterialThenMesh }
};
settings.inputCullingOptions.SetQueuesOpaque();
settings.inputFilter.SetQueuesOpaque();
loop.DrawRenderers(ref settings);
}

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

正在加载...
取消
保存