void RenderDefaultTransparent(ScriptableRenderContext context, ref RenderingData renderingData) { var camera = renderingData.camera; FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.transparent); SortingSettings sortingSettings = new SortingSettings(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; DrawingSettings drawingSettings = new DrawingSettings(new ShaderTagId("TransparentBack"), sortingSettings) { enableDynamicBatching = true, perObjectData = PerObjectData.ReflectionProbes, }; drawingSettings.SetShaderPassName(1, new ShaderTagId("TransparentFront")); RenderStateBlock stateBlock = new RenderStateBlock(RenderStateMask.Nothing); context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, ref stateBlock); }
partial void DrawUnsupportedShaders() { if (errorMaterial == null) { errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } var filteringSettings = FilteringSettings.defaultValue; var drawingSettings = new DrawingSettings(legacyShaderTagIds[0], new SortingSettings(camera)) { overrideMaterial = errorMaterial }; for (int i = 1; i < legacyShaderTagIds.Length; i++) { drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]); } context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
void DrawVisibleGeometry( bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject ) { PerObjectData lightsPerObjectFlags = useLightsPerObject ? PerObjectData.LightData | PerObjectData.LightIndices : PerObjectData.None; var sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; var drawingSettings = new DrawingSettings( unlitShaderTagId, sortingSettings ) { enableDynamicBatching = useDynamicBatching, enableInstancing = useGPUInstancing, perObjectData = PerObjectData.ReflectionProbes | PerObjectData.Lightmaps | PerObjectData.ShadowMask | PerObjectData.LightProbe | PerObjectData.OcclusionProbe | PerObjectData.LightProbeProxyVolume | PerObjectData.OcclusionProbeProxyVolume | lightsPerObjectFlags }; drawingSettings.SetShaderPassName(1, litShaderTagId); var filteringSettings = new FilteringSettings(RenderQueueRange.opaque); context.DrawRenderers( cullingResults, ref drawingSettings, ref filteringSettings ); context.DrawSkybox(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filteringSettings.renderQueueRange = RenderQueueRange.transparent; context.DrawRenderers( cullingResults, ref drawingSettings, ref filteringSettings ); }
private void RenderStochasticForward(SortingSettings sortingSettings, DrawingSettings drawSettings, FilteringSettings filterSettings, CullingResults cull, ScriptableRenderContext context) { CommandBuffer cmd = CommandBufferPool.Get("Stochastic"); //Set Color RT cmd.SetRenderTarget(m_ColorBuffer, m_DepthStencilBuffer); cmd.SetGlobalInt(ShaderIDs._MSAASampleCount, k_MSAASamples); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); //Opaque objects sortingSettings.criteria = SortingCriteria.CommonOpaque; drawSettings.sortingSettings = sortingSettings; drawSettings.SetShaderPassName(0, m_PassName); filterSettings.renderQueueRange = RenderQueueRange.opaque; context.DrawRenderers(cull, ref drawSettings, ref filterSettings); }
private void RenderTransmission(SortingSettings sortingSettings, DrawingSettings drawSettings, FilteringSettings filterSettings, CullingResults cull, ScriptableRenderContext context) { CommandBuffer cmd = CommandBufferPool.Get("Transmission"); //Set Alpha RT cmd.SetRenderTarget(m_TransmissionBuffer); cmd.ClearRenderTarget(false, true, Color.white); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); //Opaque objects sortingSettings.criteria = SortingCriteria.CommonOpaque; drawSettings.sortingSettings = sortingSettings; drawSettings.SetShaderPassName(0, m_TransmittancePassName); filterSettings.renderQueueRange = RenderQueueRange.opaque; context.DrawRenderers(cull, ref drawSettings, ref filterSettings); }
private void DrawUnsupportedShaders() { SortingSettings settings = new SortingSettings(_camera); DrawingSettings draw = new DrawingSettings(legacyShaderTagIds[0], settings); for (int i = 1; i < legacyShaderTagIds.Length; i++) { draw.SetShaderPassName(i, legacyShaderTagIds[i]); //本次绘制可以使用的shader tag,也就是pass中的lightmode } //本次绘制的所有物体都使用该material if (errorMaterial == null) { errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } draw.overrideMaterial = errorMaterial; //本次绘制使用的材质 FilteringSettings fiter = FilteringSettings.defaultValue; _context.DrawRenderers(_results, ref draw, ref fiter); }
protected void GetDefaultDrawSettings(ref RenderingData renderingData, Material material, out DrawingSettings drawingSettings, out FilteringSettings filteringSettings, out RenderStateBlock renderStateBlock) { drawingSettings = new DrawingSettings(m_shaderTagIdList[0], new SortingSettings(renderingData.cameraData.camera)); for (int i = 1; i < m_shaderTagIdList.Length; ++i) { drawingSettings.SetShaderPassName(i, m_shaderTagIdList[i]); } drawingSettings.overrideMaterial = material; drawingSettings.overrideMaterialPassIndex = 0; drawingSettings.enableDynamicBatching = renderingData.supportsDynamicBatching; drawingSettings.enableInstancing = material.enableInstancing; drawingSettings.perObjectData = perObjectData; // default render queue range is opaque. please change it before draw call if needed. filteringSettings = new FilteringSettings(new RenderQueueRange(renderQueueLowerBound, renderQueueUpperBound), ~parentProjector.projector.ignoreLayers); filteringSettings.renderingLayerMask = (uint)renderingLayerMask; renderStateBlock = parentProjector.GetDefaultRenderStateBlock(useStencilTest, m_stencilTestOptions); }
protected DrawingSettings CreateDrawingSettings(Camera camera, SortingCriteria sortingCriteria, PerObjectData perObjectData, bool supportsDynamicBatching) { SortingSettings sortingSettings = new SortingSettings(camera) { criteria = sortingCriteria }; DrawingSettings settings = new DrawingSettings(m_ShaderTagIDs[0], sortingSettings) { perObjectData = perObjectData, enableInstancing = true, enableDynamicBatching = supportsDynamicBatching }; for (int i = 1; i < m_ShaderTagIDs.Count; ++i) { settings.SetShaderPassName(i, m_ShaderTagIDs[i]); } return(settings); }
public static void RenderNormals(this IRenderPass2D pass, ScriptableRenderContext context, RenderingData renderingData, DrawingSettings drawSettings, FilteringSettings filterSettings, RenderTargetIdentifier depthTarget, CommandBuffer cmd, LightStats lightStats) { using (new ProfilingScope(cmd, m_ProfilingSampler)) { // figure out the scale var normalRTScale = 0.0f; if (depthTarget != BuiltinRenderTextureType.None) { normalRTScale = 1.0f; } else { normalRTScale = Mathf.Clamp(pass.rendererData.lightRenderTextureScale, 0.01f, 1.0f); } pass.CreateNormalMapRenderTexture(renderingData, cmd, normalRTScale); if (depthTarget != BuiltinRenderTextureType.None) { cmd.SetRenderTarget( pass.rendererData.normalsRenderTarget.Identifier(), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, depthTarget, RenderBufferLoadAction.Load, RenderBufferStoreAction.Store); } else { cmd.SetRenderTarget(pass.rendererData.normalsRenderTarget.Identifier(), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store); } cmd.ClearRenderTarget(false, true, k_NormalClearColor); context.ExecuteCommandBuffer(cmd); cmd.Clear(); drawSettings.SetShaderPassName(0, k_NormalsRenderingPassName); context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filterSettings); } }
partial void DrawUnsupportedShaders() { if (_errorMaterial == null) { _errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } var sortingSettings = new SortingSettings(_camera); var drawSettings = new DrawingSettings(_legencyShaderTagId[0], sortingSettings); drawSettings.overrideMaterial = _errorMaterial; for (int n = 0; n < _legencyShaderTagId.Length; ++n) { drawSettings.SetShaderPassName(n, _legencyShaderTagId[n]); } var filteringSettings = FilteringSettings.defaultValue; _context.DrawRenderers(_cullingResults, ref drawSettings, ref filteringSettings); }
internal static void RenderObjectsWithError(ScriptableRenderContext context, ref CullingResults cullResults, Camera camera, FilteringSettings filterSettings, SortingCriteria sortFlags) { SortingSettings sortingSettings = new SortingSettings(camera) { criteria = sortFlags }; DrawingSettings errorSettings = new DrawingSettings(m_LegacyShaderPassNames[0], sortingSettings) { perObjectData = PerObjectData.None, overrideMaterial = errorMaterial, overrideMaterialPassIndex = 0 }; for (int i = 1; i < m_LegacyShaderPassNames.Count; ++i) { errorSettings.SetShaderPassName(i, m_LegacyShaderPassNames[i]); } context.DrawRenderers(cullResults, ref errorSettings, ref filterSettings); }
private void DrawUnsupportedShaders() { var drawingSettings = new DrawingSettings( legacyShaderTagIds[0], new SortingSettings(camera) ) { overrideMaterial = errorMaterial }; var filteringSettings = FilteringSettings.defaultValue; for (var i = 1; i < legacyShaderTagIds.Length; i++) { drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]); } renderContext.DrawRenderers( cullingResults, ref drawingSettings, ref filteringSettings ); }
void DrawVisibleGeometry() { var sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; var drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings); var filteringSettings = new FilteringSettings(RenderQueueRange.opaque); drawingSettings.SetShaderPassName(1, litShaderTagId); context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); context.DrawSkybox(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filteringSettings.renderQueueRange = RenderQueueRange.transparent; context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
void DrawVisibleGeometry(bool useDynamicBatching, bool useGPUInstancing) { var sortingSettings = new SortingSettings(camera); var drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings); var filterSettings = new FilteringSettings(RenderQueueRange.opaque); drawingSettings.enableDynamicBatching = useDynamicBatching; drawingSettings.enableInstancing = useGPUInstancing; drawingSettings.SetShaderPassName(1, litShaderTagId); drawingSettings.perObjectData = PerObjectData.Lightmaps | PerObjectData.LightProbe; context.DrawRenderers(cullingResults, ref drawingSettings, ref filterSettings); context.DrawSkybox(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filterSettings.renderQueueRange = RenderQueueRange.transparent; context.DrawRenderers(cullingResults, ref drawingSettings, ref filterSettings); }
private void DrawErrorShader(ScriptableRenderContext context, SortingSettings sortingSettings, CullingResults cull, FilteringSettings filterSettings) { //Replace all legacy pass tag shaders by the pink error shader if (errorMaterial != null) { sortingSettings.criteria = SortingCriteria.None; filterSettings.renderQueueRange = RenderQueueRange.all; DrawingSettings errorSettings = new DrawingSettings(m_LegacyShaderPassNames[0], sortingSettings) { perObjectData = PerObjectData.None, overrideMaterial = errorMaterial, overrideMaterialPassIndex = 0 }; for (int i = 1; i < m_LegacyShaderPassNames.Count; ++i) { errorSettings.SetShaderPassName(i, m_LegacyShaderPassNames[i]); } context.DrawRenderers(cull, ref errorSettings, ref filterSettings); } }
public static void RenderNormals(this IRenderPass2D pass, ScriptableRenderContext context, RenderingData renderingData, DrawingSettings drawSettings, FilteringSettings filterSettings, RenderTargetIdentifier depthTarget, CommandBuffer cmd, LightStats lightStats) { using (new ProfilingScope(cmd, m_ProfilingSampler)) { // figure out the scale var normalRTScale = 0.0f; if (depthTarget != BuiltinRenderTextureType.None) { normalRTScale = 1.0f; } else { normalRTScale = Mathf.Clamp(pass.rendererData.lightRenderTextureScale, 0.01f, 1.0f); } pass.CreateNormalMapRenderTexture(renderingData, cmd, normalRTScale); var msaaEnabled = renderingData.cameraData.cameraTargetDescriptor.msaaSamples > 1; var storeAction = msaaEnabled ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store; var clearFlag = pass.rendererData.useDepthStencilBuffer ? ClearFlag.All : ClearFlag.Color; if (depthTarget != BuiltinRenderTextureType.None) { CoreUtils.SetRenderTarget(cmd, pass.rendererData.normalsRenderTarget, RenderBufferLoadAction.DontCare, storeAction, depthTarget, RenderBufferLoadAction.Load, RenderBufferStoreAction.Store, clearFlag, k_NormalClearColor); } else { CoreUtils.SetRenderTarget(cmd, pass.rendererData.normalsRenderTarget, RenderBufferLoadAction.DontCare, storeAction, clearFlag, k_NormalClearColor); } context.ExecuteCommandBuffer(cmd); cmd.Clear(); drawSettings.SetShaderPassName(0, k_NormalsRenderingPassName); context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filterSettings); } }
partial void DrawUnSupportedShadersGeometry() { if (errorMaterial == null) { errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } DrawingSettings drawingSettings = new DrawingSettings(); drawingSettings.sortingSettings = new SortingSettings(camera); drawingSettings.overrideMaterial = errorMaterial; for (int i = 0; i != legacyShaderTagIds.Length; ++i) { drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]); } FilteringSettings filteringSettings = FilteringSettings.defaultValue; renderContext.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
void DrawVisibleGeometry(bool useDynamicBatching, bool useGPUInstancing) { //--------- //绘制不透明物体 var sortingSettings = new SortingSettings(camera) //排序设置 { criteria = SortingCriteria.CommonOpaque //分类标准.通用不透明 }; var drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings) { enableDynamicBatching = useDynamicBatching, //动态批处理 enableInstancing = useGPUInstancing, //GPU实例化 perObjectData = PerObjectData.Lightmaps | PerObjectData.LightProbe | PerObjectData.LightProbeProxyVolume | PerObjectData.ReflectionProbes //光照贴图,光照探针,光探针代理体积 }; drawingSettings.SetShaderPassName(1, litShaderTagId); var filteringSettings = new FilteringSettings(RenderQueueRange.opaque); //渲染队列范围.不透明 context.DrawRenderers( cullingResults, ref drawingSettings, ref filteringSettings ); //--------- context.DrawSkybox(camera); //绘制天空盒 //--------- //绘制透明物体 sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filteringSettings.renderQueueRange = RenderQueueRange.transparent; context.DrawRenderers( cullingResults, ref drawingSettings, ref filteringSettings ); //--------- }
partial void DrawUnsupportedShaders() { if (!errorMaterial) { errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } var drawingSettings = new DrawingSettings(legacyShaderTagIds[0], new SortingSettings(camera)) { overrideMaterial = errorMaterial }; // https://docs.unity3d.com/2017.4/Documentation/ScriptReference/Experimental.Rendering.DrawRendererSettings.SetShaderPassName.html for (int i = 1; i < legacyShaderTagIds.Length; i++) { drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]); } var filteringSettings = FilteringSettings.defaultValue; context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
partial void DrawUnsupportedShaders(ref CullingResults cullingResults) { if (_errorMaterial == null) { _errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); } var drawingSettings = new DrawingSettings() { overrideMaterial = _errorMaterial }; drawingSettings.sortingSettings = new SortingSettings(_camera); for (int i = 0; i < _legacyShaderTagIds.Length; i++) { drawingSettings.SetShaderPassName(i, _legacyShaderTagIds[i]); } var filterSettings = FilteringSettings.defaultValue; _context.DrawRenderers(cullingResults, ref drawingSettings, ref filterSettings); }
private void DrawVisibleGeometry() { var sortingSettings = new SortingSettings(_camera); sortingSettings.criteria = SortingCriteria.CommonOpaque; var drawingSetting = new DrawingSettings(); drawingSetting.SetShaderPassName(0, unlitShaderTagId); drawingSetting.sortingSettings = sortingSettings; drawingSetting.enableInstancing = true; drawingSetting.enableDynamicBatching = true; var filteringSetting = new FilteringSettings(RenderQueueRange.opaque); _context.DrawRenderers(_cullingResults, ref drawingSetting, ref filteringSetting); _context.DrawSkybox(_camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; // drawingSetting.sortingSettings = sortingSettings; filteringSetting.renderQueueRange = RenderQueueRange.transparent; _context.DrawRenderers(_cullingResults, ref drawingSetting, ref filteringSetting); }
partial void DrawLegacy() { _errorMaterial = _errorMaterial != null ? _errorMaterial : new Material(Shader.Find("Hidden/InternalErrorShader")); var drawingSettings = new DrawingSettings( _legacyShaderTagIds[0], new SortingSettings(_camera) ) { overrideMaterial = _errorMaterial }; for (int i = 1; i < _legacyShaderTagIds.Length; i++) { drawingSettings.SetShaderPassName(i, _legacyShaderTagIds[i]); } var filteringSettings = new FilteringSettings(RenderQueueRange.all); _context.DrawRenderers(_cullingResults, ref drawingSettings, ref filteringSettings); }
void DrawDepthOnly(ScriptableRenderContext context, Camera camera) { SortingSettings sortingSettings = new SortingSettings(camera); sortingSettings.criteria = SortingCriteria.CommonOpaque; // front to back. //https://docs.unity3d.com/ScriptReference/Rendering.DrawingSettings.html DrawingSettings drawingSettings = new DrawingSettings(); drawingSettings.SetShaderPassName(0, shaderTagIds[0]); drawingSettings.sortingSettings = sortingSettings; drawingSettings.enableInstancing = true; //https://docs.unity3d.com/ScriptReference/Rendering.FilteringSettings.html FilteringSettings filteringSettings = new FilteringSettings(); filteringSettings.renderQueueRange = RenderQueueRange.opaque; filteringSettings.renderingLayerMask = 1; filteringSettings.layerMask = camera.cullingMask; context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
private void RenderNormal() { //绘制原来不透明物体,由于这里用的不是commandbuffer,所以要注意一下,在这个之前的commandbuffer需要先excure一遍 var drawSettings = new DrawingSettings(); drawSettings.SetShaderPassName(0, ShaderPass.c_UniltPass_ID); drawSettings.sortingSettings = new SortingSettings(hostCamera) { criteria = SortingCriteria.CommonOpaque }; drawSettings.perObjectData = PerObjectData.None; var filterSettings = new FilteringSettings { layerMask = hostCamera.cullingMask, renderingLayerMask = 1, renderQueueRange = RenderQueueRange.opaque }; CullingResults cullingResults = PipelineContext.renderContext.Cull(ref cullParams); PipelineContext.renderContext.DrawRenderers(cullingResults, ref drawSettings, ref filterSettings); PipelineContext.renderContext.DrawSkybox(hostCamera); }
private void DrawVisibleGeometry(bool useDynamicBatching, bool useGPUInstancing) { SortingSettings sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; DrawingSettings drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings) { enableDynamicBatching = useDynamicBatching, enableInstancing = useGPUInstancing }; drawingSettings.SetShaderPassName(1, litShaderTagId); FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.opaque); context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); context.DrawSkybox(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filteringSettings.renderQueueRange = RenderQueueRange.transparent; context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
//对不支持的shader指定默认的渲染材质 //void DrawUnsupportedShaders() //{ // if (errorMaterial == null) // errorMaterial = new Material(Shader.Find("Hidden/InternalErrorShader")); // var drawingSettings = new DrawingSettings(legacyShaderTagIds[0], new SortingSettings(camera)) // { // overrideMaterial = errorMaterial // }; // //遍历legacyShaderTagIds中所有的shader类型 // for (int i = 1; i<legacyShaderTagIds.Length; i++) // { // drawingSettings.SetShaderPassName(i, legacyShaderTagIds[i]); // } // var filteringSettings = FilteringSettings.defaultValue; // context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); //} void DrawVisibleGeometry(bool useDynamicBatching, bool useGPUInstancing) { //The camera's transparency sort mode is used to determine whether to use orthographic //sortingSettings 用于确定基于正交还是透视图的应用排序 var sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; var drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings) { enableDynamicBatching = useDynamicBatching, enableInstancing = useGPUInstancing, perObjectData = PerObjectData.Lightmaps | PerObjectData.ShadowMask | PerObjectData.LightProbe | PerObjectData.OcclusionProbe | PerObjectData.LightProbeProxyVolume | PerObjectData.OcclusionProbeProxyVolume }; drawingSettings.SetShaderPassName(1, litShaderTagId); var filteringSettings = new FilteringSettings(RenderQueueRange.all); context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); context.DrawSkybox(camera); }
// Here you can implement the rendering logic. // Use <c>ScriptableRenderContext</c> to issue drawing commands or execute command buffers // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { if (!outlineMaterial) { return; } SortingSettings sortingSettings = new SortingSettings(renderingData.cameraData.camera); sortingSettings.criteria = SortingCriteria.OptimizeStateChanges; // Better for SRP Batcher. DrawingSettings drawingSettings = new DrawingSettings(); drawingSettings.SetShaderPassName(0, shaderTagId); drawingSettings.sortingSettings = sortingSettings; drawingSettings.enableInstancing = true; drawingSettings.overrideMaterial = outlineMaterial; drawingSettings.overrideMaterialPassIndex = 0; RenderQueueRange range = new RenderQueueRange(); range.lowerBound = passSetting.queueMin; range.upperBound = passSetting.queueMax; FilteringSettings filteringSettings = new FilteringSettings(); filteringSettings.renderQueueRange = range; filteringSettings.renderingLayerMask = 1; filteringSettings.layerMask = passSetting.layer; outlineMaterial.SetFloat(OutlineWidthId, passSetting.outlineWidth); outlineMaterial.SetColor(OutlineColorId, passSetting.outlineColor); outlineMaterial.SetFloat(AspectId, renderingData.cameraData.camera.aspect); context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings); }
private void DrawVisibleObjects(bool useDynamicBatching, bool useGPUInstancing) { SortingSettings sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; // Lightmaps enable LIGHTMAP_ON, ShadowMask enable shadow mask texture, OcclusionProbe enable unity_ProbesOcclusion DrawingSettings drawingSettings = new DrawingSettings(unlitShaderTagID, sortingSettings) { enableDynamicBatching = useDynamicBatching, enableInstancing = useGPUInstancing, perObjectData = PerObjectData.Lightmaps | PerObjectData.ShadowMask | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.LightProbe | PerObjectData.LightProbeProxyVolume }; drawingSettings.SetShaderPassName(1, litShaderTagID); FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.opaque); renderContext.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); renderContext.DrawSkybox(camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filteringSettings.renderQueueRange = RenderQueueRange.transparent; renderContext.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); }
DrawingSettings GetDrawingSettings(ref RenderingData renderingData) { var camera = renderingData.cameraData.camera; var sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; var drawingSettings = new DrawingSettings(ShaderTagId.none, sortingSettings) { perObjectData = PerObjectData.MotionVectors, enableDynamicBatching = renderingData.supportsDynamicBatching, enableInstancing = true, }; for (int i = 0; i < s_ShaderTags.Length; ++i) { drawingSettings.SetShaderPassName(i, new ShaderTagId(s_ShaderTags[i])); } // Material that will be used if shader tags cannot be found drawingSettings.fallbackMaterial = m_ObjectMaterial; return(drawingSettings); }
void DrawVisibleGeometry() { var sortingSettings = new SortingSettings(Params.camera) { criteria = SortingCriteria.CommonOpaque }; var drawingSettings = new DrawingSettings(unlitShaderTagId, sortingSettings) { enableDynamicBatching = Params.useDynamicBatching, enableInstancing = Params.useGPUInstancing }; //增加shader标签 drawingSettings.SetShaderPassName(1, litShaderTagId); var filterSettings = new FilteringSettings(RenderQueueRange.opaque); GlobalUniqueParamsForRP.context.DrawRenderers(cullingResults, ref drawingSettings, ref filterSettings); //绘制天空盒,由Camera的ClearFlag决定是否渲染天空盒,在不透明队列后面渲染,避免天空盒overdraw GlobalUniqueParamsForRP.context.DrawSkybox(Params.camera); sortingSettings.criteria = SortingCriteria.CommonTransparent; drawingSettings.sortingSettings = sortingSettings; filterSettings.renderQueueRange = RenderQueueRange.transparent; GlobalUniqueParamsForRP.context.DrawRenderers(cullingResults, ref drawingSettings, ref filterSettings); }