public bool Cull(ShadowSettings shadowSettings) { if (_camera.TryGetCullingParameters(out ScriptableCullingParameters _parameters)) { _parameters.shadowDistance = shadowSettings.maxDistance; _results = _context.Cull(ref _parameters); return(true); } return(false); }
public CustomRenderPipeline( bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, ShadowSettings shadowSettings ) { this.shadowSettings = shadowSettings; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; GraphicsSettings.lightsUseLinearIntensity = true; }
public void Setup( ScriptableRenderContext context, CullingResults cullingResults, ShadowSettings settings ) { this.context = context; this.cullingResults = cullingResults; this.settings = settings; useShadowMask = false; shadowedDirLightCount = 0; }
public void Setup( ScriptableRenderContext context, CullingResults cullingResults, ShadowSettings settings ) { this.context = context; this.cullingResults = cullingResults; this.settings = settings; ShadowedDirectionalLightCount = 0; }
public void Setup( ScriptableRenderContext context, CullingResults culling, ShadowSettings shadowSettings ) { cullingResults = culling; buffer.BeginSample(bufferName); shadows.Setup(context, culling, shadowSettings); SetupLights(); buffer.EndSample(bufferName); context.ExecuteCommandBuffer(buffer); buffer.Clear(); }
public CelShadedRenderPipeline(bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, ShadowSettings shadowSettings, float defaultShadowBrightness, float brightnessMultiplier, float shadowTreshold) { this.shadowSettings = shadowSettings; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; this.defaultShadowBrightness = defaultShadowBrightness; this.brightnessMultiplier = brightnessMultiplier; this.shadowTreshold = shadowTreshold; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; GraphicsSettings.lightsUseLinearIntensity = true; }
public CustomRenderPipeline(bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, bool useLightsPerObject, ShadowSettings shadowSettings) { this.shadowSettings = shadowSettings; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; this.useLightsPerObject = useLightsPerObject; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; GraphicsSettings.lightsUseLinearIntensity = true; InitializeForEditor(); }
public void Render(ScriptableRenderContext context, CullingResults results, ShadowSettings shadowSettings) { _results = results; _context = context; _shadowSettings = shadowSettings; _commandBuffer.BeginSample(BufferName); _shadow.SetUp(context, results, shadowSettings); SetUpLights(); _shadow.Render(); _commandBuffer.EndSample(BufferName); ExecuteCommandBuffer(); }
public void Render( ScriptableRenderContext context, Camera camera, bool allowHDR, bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject, ShadowSettings shadowSettings, PostFXSettings postFXSettings, int colorLUTResolution ) { this.context = context; this.camera = camera; var crpCamera = camera.GetComponent <CustomRenderPipelineCamera>(); CameraSettings cameraSettings = crpCamera ? crpCamera.Settings : defaultCameraSettings; if (cameraSettings.overridePostFX) { postFXSettings = cameraSettings.postFXSettings; } PrepareBuffer(); PrepareForSceneWindow(); if (!Cull(shadowSettings.maxDistance)) { return; } useHDR = allowHDR && camera.allowHDR; buffer.BeginSample(SampleName); ExecuteBuffer(); lighting.Setup( context, cullingResults, shadowSettings, useLightsPerObject, cameraSettings.maskLights ? cameraSettings.renderingLayerMask : -1 ); postFXStack.Setup( context, camera, postFXSettings, useHDR, colorLUTResolution, cameraSettings.finalBlendMode ); buffer.EndSample(SampleName); Setup(); DrawVisibleGeometry( useDynamicBatching, useGPUInstancing, useLightsPerObject, cameraSettings.renderingLayerMask ); DrawUnsupportedShaders(); DrawGizmosBeforeFX(); if (postFXStack.IsActive) { postFXStack.Render(frameBufferId); } DrawGizmosAfterFX(); Cleanup(); Submit(); }
public void Setup( ScriptableRenderContext context, CullingResults cullingResults, bool useLightsPerObject, ShadowSettings shadowSettings, int renderingLayerMask ) { this.cullingResults = cullingResults; buffer.BeginSample(bufferName); shadows.Setup(context, cullingResults, shadowSettings); SetupLights(useLightsPerObject, renderingLayerMask); shadows.Render(); buffer.EndSample(bufferName); context.ExecuteCommandBuffer(buffer); buffer.Clear(); }
public CustomRenderPipeline(bool allowHDR, bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, bool useLightsPerObject, ShadowSettings shadowSettings, PostFXSettings postFXSettings, int colorLUTResolution ) { this.colorLUTResolution = colorLUTResolution; this.allowHDR = allowHDR; this.postFXSettings = postFXSettings; this.shadowSettings = shadowSettings; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; this.useLightsPerObject = useLightsPerObject; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; GraphicsSettings.lightsUseLinearIntensity = true; InitializeForEditor(); }
/// <summary> /// empty constructor. /// </summary> public OpenGlDevice() { InitializeCtrlHandler(); OnTime = new EventHandler(Timer_Tick); Camera = new Camera(this); Light L = new Light(); L.Device = this; Lights.Add(L); ShadowSetting = new ShadowSettings(this); Selector.Device = this; if (Devices == null) { Devices = new List <OpenGlDevice>(); } }
public CustomRenderPipeline(CameraBufferSettings cameraBufferSettings, bool useDynamicBathcing, bool useGPUInstancing, bool useLightsPerObject, bool useSRPBatcher, ShadowSettings shadowSettings, PostFXSettings postFXSettings, int colorLUTResolution, Shader cameraRendererShader) { this.colorLUTResolution = colorLUTResolution; this.cameraBufferSettings = cameraBufferSettings; this.postFXSettings = postFXSettings; this.shadowSettings = shadowSettings; this.useDynamicBathcing = useDynamicBathcing; this.useGPUInstancing = useGPUInstancing; this.useLightsPerObject = useLightsPerObject; //开启SRP Batch 会优先使用 GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; //是用Gamma颜色还是线性颜色 GraphicsSettings.lightsUseLinearIntensity = true; // InitializeForEditor(); renderer = new CameraRenderer(cameraRendererShader); }
public WindsmoonRenderPipeline(bool allowHDR, bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, bool useLightsPerObject, ShadowSettings shadowSettings, PostProcessingAsset postProcessingAsset, GrassSeaConfig grassSeaConfig) { this.allowHDR = allowHDR; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; this.useLightsPerObject = useLightsPerObject; this.shadowSettings = shadowSettings; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; GraphicsSettings.lightsUseLinearIntensity = true; this.shadowSettings = shadowSettings; this.postProcessingAsset = postProcessingAsset; this.grassSeaConfig = grassSeaConfig; #if UNITY_EDITOR Lightmapping.SetDelegate(requestLightDelegate); #endif }
public void Setup( ScriptableRenderContext context, CullingResults cullingResults, ShadowSettings shadowSettings, bool useLightPerObject, int camRenderingLayerMask) { this.cullingResults = cullingResults; buffer.BeginSample(buffername); //Setup shadows before setup lights shadows.Setup(context, cullingResults, shadowSettings); //get all the Lightsinfo and sent to GPU SetupLights(useLightPerObject, camRenderingLayerMask); //render shadow shadows.Render(); buffer.EndSample(buffername); context.ExecuteCommandBuffer(buffer); buffer.Clear(); }
public void Render(ScriptableRenderContext context, Camera camera, bool useDynamicBatching, bool useGPUInstancing, ShadowSettings shadowSettings) { this.context = context; this.camera = camera; PrepareBuffer(); PrepareForSceneWindow(); if (!Cull(shadowSettings.maxDistance)) { return; } Setup(); lighting.Setup(context, cullingResults, shadowSettings); DrawVisibleGeomertry(useDynamicBatching, useGPUInstancing); DrawUnsupportedShaders(); DrawGizmos(); Submit(); }
public void Setup(ScriptableRenderContext context, CullingResults cullingResults, ShadowSettings shadowSettings) { this.cullingResults = cullingResults; this.context = context; this.shadowSettings = shadowSettings; //init ans not use shadowmask useShadowMask = false; ShadowedDirectionalLightCount = 0; ShadowedOtherLightCount = 0; /* * buffer.BeginSample(buffername); * SetupLights(); * buffer.EndSample(buffername); * context.ExecuteCommandBuffer(buffer); * buffer.Clear(); */ }
CullingResults cullingResults; // We want to figure out what can be rendered public void Render( ScriptableRenderContext ctx, Camera camera, bool useDynamicBatching, bool useGPUInstancing, ShadowSettings shadowSettings) { this.ctx = ctx; this.camera = camera; // Allow secondary cameras PrepareBuffer(); // Allow UI Drawing in the scene view PrepareForSceneWindow(); if (!Cull(shadowSettings.MaxDistance)) { return; } buffer.BeginSample(SampleName); ExecuteBuffer(); // Do the lighting setup first to not affect the usual rendering. lighting.SetUp(ctx, cullingResults, shadowSettings); buffer.EndSample(SampleName); SetUp(); DrawVisibleGeometry(useDynamicBatching, useGPUInstancing); DrawUnsupportedShaders(); DrawGizmos(); // Clean up the lighting, which cleans up the shadows also. lighting.CleanUp(); // Submit the previous cmd to the render queue Submit(); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_EnvironmentDefinition objBuilder = (MyObjectBuilder_EnvironmentDefinition)builder; FogProperties = objBuilder.FogProperties; SunProperties = objBuilder.SunProperties; PostProcessSettings = objBuilder.PostProcessSettings; SSAOSettings = objBuilder.SSAOSettings; HBAOSettings = objBuilder.HBAOSettings; ShadowSettings.CopyFrom(objBuilder.ShadowSettings); SmallShipMaxSpeed = objBuilder.SmallShipMaxSpeed; LargeShipMaxSpeed = objBuilder.LargeShipMaxSpeed; SmallShipMaxAngularSpeed = objBuilder.SmallShipMaxAngularSpeed; LargeShipMaxAngularSpeed = objBuilder.LargeShipMaxAngularSpeed; ContourHighlightColor = new Color(objBuilder.ContourHighlightColor); ContourHighlightThickness = objBuilder.ContourHighlightThickness; HighlightPulseInSeconds = objBuilder.HighlightPulseInSeconds; EnvironmentTexture = objBuilder.EnvironmentTexture; EnvironmentOrientation = objBuilder.EnvironmentOrientation; }
public void SetUp(ScriptableRenderContext ctx, CullingResults cullingResults, ShadowSettings shadowSettings) { this.cullingResults = cullingResults; buffer.BeginSample(BufferName); // SetUpDirectionalLights() is obsolete since it only supports 1 light // SetUpDirectionalLights(); // Lighting sets up shadows shadows.SetUp(ctx, cullingResults, shadowSettings); // Set up all visible lights we want to support - for now only Directional ones :) SetUpLights(); // Render the shadows shadows.Render(); buffer.EndSample(BufferName); ctx.ExecuteCommandBuffer(buffer); buffer.Clear(); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the shadow settings object. /// </summary> /// <param name="settings">Initial values to assign to the GUI elements.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public ShadowSettingsGUI(ShadowSettings settings, GUILayout layout) { this.settings = settings; directionalShadowDistanceField.OnChanged += x => { this.settings.DirectionalShadowDistance = x; MarkAsModified(); ConfirmModify(); }; numCascadesField.OnChanged += x => { this.settings.NumCascades = (uint)x; MarkAsModified(); ConfirmModify(); }; cascadeDistributionExponentField.OnChanged += x => { this.settings.CascadeDistributionExponent = x; MarkAsModified(); ConfirmModify(); }; filteringQualityField.OnChanged += x => { this.settings.ShadowFilteringQuality = (uint)x; MarkAsModified(); ConfirmModify(); }; filteringQualityField.Step = 1.0f; layout.AddElement(directionalShadowDistanceField); layout.AddElement(numCascadesField); layout.AddElement(cascadeDistributionExponentField); layout.AddElement(filteringQualityField); }
public void Render( ScriptableRenderContext context, Camera camera, bool useDynamicBatching, bool useGPUInstancing, ShadowSettings shadowSettings, PostFXSettings postFXSettings ) { this.context = context; this.camera = camera; PrepareBuffer(); PrepareForSceneWindow(); if (!Cull(shadowSettings.maxDistance)) { return; } buffer.BeginSample(SampleName); ExecuteBuffer(); lighting.Setup(context, cullingResults, shadowSettings); postFXStack.Setup(context, camera, postFXSettings); buffer.EndSample(SampleName); Setup(); DrawVisibleGeometry(useDynamicBatching, useGPUInstancing); DrawUnsupportedShaders(); DrawGizmosBeforeFX(); //开启绘制 if (postFXStack.IsActive) { postFXStack.Render(frameBufferId); } DrawGizmosAfterFX(); Cleanup(); Submit(); }
public CustomPipeline(bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher, ShadowSettings shadowSettings, CustomPostProcessingStack defaultStack, int shadowMapSize, float shadowDistance, float shadowFadeRange, int shadowCascades, Vector3 shadowCascadeSplit, float renderScale, int msaaSamples, bool allowHDR) { GraphicsSettings.lightsUseLinearIntensity = true; GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; this.useDynamicBatching = useDynamicBatching; this.useGPUInstancing = useGPUInstancing; this.shadowSettings = shadowSettings; this.defaultStack = defaultStack; this.shadowMapSize = shadowMapSize; this.shadowDistance = shadowDistance; this.shadowFadeRange = shadowFadeRange; this.shadowCascades = shadowCascades; this.shadowCascadeSplit = shadowCascadeSplit; this.renderScale = renderScale; QualitySettings.antiAliasing = msaaSamples; this.msaaSamples = Mathf.Max(QualitySettings.antiAliasing, 1); this.allowHDR = allowHDR; globalShadowData.y = 1f / shadowFadeRange; if (SystemInfo.usesReversedZBuffer) { worldToShadowCascadeMatrices[4].m33 = 1f; } #if UNITY_EDITOR Lightmapping.SetDelegate(lightmappingLightsDelegate); #endif }
public void Render(ScriptableRenderContext context, Camera camera, bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject, ShadowSettings shadowSettings) { this.context = context; this.camera = camera; PrepareBuffer(); PrepareForSceneWindow(); if (!Cull(shadowSettings.maxDistance)) { return; } buffer.BeginSample(SampleName); ExecuteBuffer(); lighting.Setup(context, cullingResults, shadowSettings, useLightsPerObject); buffer.EndSample(SampleName); Setup(); DrawVisibleGeometry(useDynamicBatching, useGPUInstancing, useLightsPerObject); DrawUnsupportedShaders(); DrawGizmos(); lighting.Cleanup(); Submit(); }
#pragma warning restore IDE1006, CS0169 public void Set(uint numCascades, ShadowSettings settings, ShadowData data) { ShadowMatrix = data.ShadowMatrix; SetArrayData( numCascades, data.CascadeSplits, out CascadeSplit0, out CascadeSplit1, out CascadeSplit2, out CascadeSplit3); SetArrayData( numCascades, data.CascadeOffsets, out CascadeOffset0, out CascadeOffset1, out CascadeOffset2, out CascadeOffset3); SetArrayData( numCascades, data.CascadeScales, out CascadeScale0, out CascadeScale1, out CascadeScale2, out CascadeScale3); Bias = settings.Bias; OffsetScale = settings.NormalOffset; VisualizeCascades = settings.VisualizeCascades ? 1u : 0u; FilterAcrossCascades = 1u; ShadowDistance = settings.ShadowDistance; ShadowsType = settings.ShadowsType; NumSplits = numCascades; }
private void Setup(ShadowSettings shadowSettings) { renderContext.SetupCameraProperties(camera); // ?? this method must be called before excute commandbuffer, or clear command will call GL.Draw to clear CameraClearFlags cameraClearFlags = camera.clearFlags; if (postProcessingStack.IsActive) { // clear color and depth unless use the skybox clear flag (sky box flag is the smallest value of the clearFlags enum) if (cameraClearFlags > CameraClearFlags.Color) { cameraClearFlags = CameraClearFlags.Color; } commandBuffer.GetTemporaryRT(cameraFrameBufferPropertyID, camera.pixelWidth, camera.pixelHeight, 32, FilterMode.Bilinear, useHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default); commandBuffer.SetRenderTarget(cameraFrameBufferPropertyID, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store); } commandBuffer.ClearRenderTarget(cameraClearFlags <= CameraClearFlags.Depth, cameraClearFlags == CameraClearFlags.Color, cameraClearFlags == CameraClearFlags.Color ? camera.backgroundColor.linear : Color.clear); // ?? tbdr resolve commandBuffer.BeginSample(commandBufferName); ExecuteCommandBuffer(); }
public void Render( ScriptableRenderContext context, Camera camera, CameraBufferSettings bufferSettings, bool useDynamicBatching, bool useGPUInstancing, bool useLightsPerObject, ShadowSettings shadowSettings, PostFXSettings postFXSettings, int colorLUTResolution ) { this.context = context; this.camera = camera; var crpCamera = camera.GetComponent <CustomRenderPipelineCamera>(); CameraSettings cameraSettings = crpCamera ? crpCamera.Settings : defaultCameraSettings; if (camera.cameraType == CameraType.Reflection) { useColorTexture = bufferSettings.copyColorReflection; useDepthTexture = bufferSettings.copyDepthReflection; } else { useColorTexture = bufferSettings.copyColor && cameraSettings.copyColor; useDepthTexture = bufferSettings.copyDepth && cameraSettings.copyDepth; } if (cameraSettings.overridePostFX) { postFXSettings = cameraSettings.postFXSettings; } float renderScale = cameraSettings.GetRenderScale(bufferSettings.renderScale); useScaledRendering = renderScale <0.99f || renderScale> 1.01f; PrepareBuffer(); PrepareForSceneWindow(); if (!Cull(shadowSettings.maxDistance)) { return; } useHDR = bufferSettings.allowHDR && camera.allowHDR; if (useScaledRendering) { renderScale = Mathf.Clamp(renderScale, renderScaleMin, renderScaleMax); bufferSize.x = (int)(camera.pixelWidth * renderScale); bufferSize.y = (int)(camera.pixelHeight * renderScale); } else { bufferSize.x = camera.pixelWidth; bufferSize.y = camera.pixelHeight; } buffer.BeginSample(SampleName); buffer.SetGlobalVector(bufferSizeId, new Vector4( 1f / bufferSize.x, 1f / bufferSize.y, bufferSize.x, bufferSize.y )); ExecuteBuffer(); lighting.Setup( context, cullingResults, shadowSettings, useLightsPerObject, cameraSettings.maskLights ? cameraSettings.renderingLayerMask : -1 ); bufferSettings.fxaa.enabled &= cameraSettings.allowFXAA; postFXStack.Setup( context, camera, bufferSize, postFXSettings, cameraSettings.keepAlpha, useHDR, colorLUTResolution, cameraSettings.finalBlendMode, bufferSettings.bicubicRescaling, bufferSettings.fxaa ); buffer.EndSample(SampleName); Setup(); DrawVisibleGeometry( useDynamicBatching, useGPUInstancing, useLightsPerObject, cameraSettings.renderingLayerMask ); DrawUnsupportedShaders(); DrawGizmosBeforeFX(); if (postFXStack.IsActive) { postFXStack.Render(colorAttachmentId); } else if (useIntermediateBuffer) { DrawFinal(cameraSettings.finalBlendMode); ExecuteBuffer(); } DrawGizmosAfterFX(); Cleanup(); Submit(); }
public virtual void PrepareLightsForGPU(ShadowSettings shadowSettings, CullResults cullResults, Camera camera, ref ShadowOutput shadowOutput) { }
void SetShadows(ShadowSettings setting) { if (LightmapSettings.lightmapsMode == LightmapsMode.Single) LightmapSettings.lightmapsMode = LightmapsMode.Dual; foreach(Light l in lights) l.shadows = setting.shadows; QualitySettings.shadowProjection = setting.shadowProjection; QualitySettings.shadowCascades = setting.shadowCascades; QualitySettings.shadowDistance = setting.shadowDistance; }
public static CastSpritesShadowComponentData ToComponentData(ShadowSettings shadowSettings) { var res = shadowSettings.ShadowsData; return(res); }
public void Setup(ScriptableRenderContext context, CullingResults cullingResults, ShadowSettings shadowSettings, float shadowTreshold) { this.cullingResults = cullingResults; this.shadowTreshold = shadowTreshold; buffer.BeginSample(bufferName); shadows.Setup(context, cullingResults, shadowSettings); SetupLights(); shadows.Render(); buffer.EndSample(bufferName); context.ExecuteCommandBuffer(buffer); buffer.Clear(); }