///////////////////////////////////////////////////////////////////////////////////////////// // Unity MonoBehavior Messages ///////////////////////////////////////////////////////////////////////////////////////////// internal void Enable(RenderPipeline renderPipeline) { _renderTextureFormat = Compatibility.CheckSupportedRenderTextureFormat(); _renderPipeline = renderPipeline; _sourceContext = new RenderContext[1] { new RenderContext() }; _renderContext = new RenderContext[PipelineProperties.renderBufferSize]; for (int i = 0; i < PipelineProperties.renderBufferSize; i++) { _renderContext[i] = new RenderContext(); } _selectiveRenderContext = new RenderContext(); _renderMaterialNoGeometry = new Material(_resources.sm40Shader) { hideFlags = HideFlags.HideAndDontSave }; _renderTargetsBundle = new List <RenderTarget>(); _renderKeywordsBundle = new List <MaterialKeywords>(); //create buffers _bloomDownsampleBuffer = new MipBuffer(PipelineProperties.CommandBufferProperties.bloomDownsampleBuffer, _renderPipeline); _bloomUpsampleBuffer = new MipBuffer(PipelineProperties.CommandBufferProperties.bloomUpsampleBuffer, _renderPipeline); }
private void OnEnable() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif if (dbgData == null) { dbgData = new DebugData(this); } Init(); StartCoroutine(AdaptiveTask()); #if UNITY_2019_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP) // only on SRP if (!MadGoatSSAA_Utils.DetectSRP()) { return; } //UnityEngine.Experimental.Rendering.RenderPipeline.BeginCameraRendering(GetComponent<Camera>()); UnityEngine.Experimental.Rendering.RenderPipeline.beginCameraRendering += OnBeginCameraRender; #elif UNITY_2018_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP) // only on SRP if (!MadGoatSSAA_Utils.DetectSRP()) { return; } RenderPipeline.BeginCameraRendering(GetComponent <Camera>()); RenderPipeline.beginCameraRendering += OnBeginCameraRender; #endif }
public void Reset() { geometryOverrideLayer = Consts.ConfigGeometryOverrideLayerDefault; geometryLayerID = Consts.ConfigGeometryLayerIDDefault; geometryTag = Consts.ConfigGeometryTagDefault; geometryRenderQueue = (int)Consts.ConfigGeometryRenderQueueDefault; beamShader1Pass = Shader.Find("Hidden/VolumetricLightBeam1Pass"); beamShader2Pass = Shader.Find("Hidden/VolumetricLightBeam2Pass"); sharedMeshSides = Consts.ConfigSharedMeshSides; sharedMeshSegments = Consts.ConfigSharedMeshSegments; globalNoiseScale = Consts.NoiseScaleDefault; globalNoiseVelocity = Consts.NoiseVelocityDefault; noise3DData = Resources.Load("Noise3D_64x64x64") as TextAsset; noise3DSize = Consts.ConfigNoise3DSizeDefault; dustParticlesPrefab = Resources.Load("DustParticles", typeof(ParticleSystem)) as ParticleSystem; renderPipeline = Consts.ConfigGeometryRenderPipelineDefault; renderingMode = Consts.ConfigGeometryRenderingModeDefault; #if UNITY_EDITOR GlobalMesh.Destroy(); VolumetricLightBeam._EditorSetAllMeshesDirty(); OnRenderPipelineChanged(renderPipeline); #endif }
public static RenderPipeline RenderIcons(this RenderPipeline pipeline, IconSystem iconSystem) { var stage = new RenderIconsStage(iconSystem, pipeline.Device); pipeline.Add(stage); return(pipeline); }
public override void OnOpen() { pipeline = new RenderPipeline(); pipeline.RegisterPass(new Renderer2DPass()); pipeline.RegisterPass(new LineRenderPass()); pipeline.RegisterPass(new EditorDrawPass()); }
static void CheckRenderPipeline() { RenderPipeline rpInUnity = UnityInfo.GetCurrentRenderPipelineInUse(); ShapesImportState inst = Instance; if (inst == null) { Debug.LogWarning("Failed to detect render pipeline - Shapes will retry on the next script recompile"); return; // I guess some weird import order shenan happened? :c } RenderPipeline rpShapesShaders = inst.currentShaderRP; if (rpInUnity != rpShapesShaders) { string rpStr = rpInUnity.ToString(); if (rpInUnity == RenderPipeline.Legacy) { rpStr = "the built-in render pipeline"; } string desc = $"Looks like you're using {rpStr}!\nShapes will now regenerate all shaders, it might take a lil while~"; EditorUtility.DisplayDialog("Shapes", desc, "ok"); CodegenShaders.GenerateShadersAndMaterials(); } }
internal void ImportShaders(RenderPipeline renderPipeline) { switch (renderPipeline) { case RenderPipeline.Built_in: AssetDatabase.ImportPackage(AssetDatabase.GetAssetPath(_shadersBuiltin), false); break; case RenderPipeline.Lightweight: AssetDatabase.ImportPackage(AssetDatabase.GetAssetPath(_shadersLWRP), false); break; case RenderPipeline.Universal: AssetDatabase.ImportPackage(AssetDatabase.GetAssetPath(_shadersURP), false); break; default: //All cases should be handled break; } showInstallerOnReload = false; EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public static void CreateEngine() { // The pipeline processors for our application. // These are responsible for consuming frames // created by the engine class. events = new EventPipeline(); physics = new PhysicsPipeline(); animation = new AnimationPipeline(); rendering = new RenderPipeline(); events.Subscribe <QuitEvent>(OnQuit); var actions = new Action <FrameState>[] { events.ProcessFrame, physics.ProcessFrame, animation.ProcessFrame, rendering.ProcessFrame }; inputStates = new InputStateContainer(); events.Subscribe <InputDeviceEvent>(inputStates.HandleInput); var sequence = new SequentialPipeline(actions); // create our engine. engine = new Engine(); engine.action = events.ProcessFrame; engine.generator = new FrameGenerator(); }
void AppendPass(ShaderPassType pass, RenderPipeline rp) { using (Scope("Pass")) { // Name & LightMode bool isLegacyMainRenderPass = rp == RenderPipeline.Legacy && pass == ShaderPassType.Render; if (isLegacyMainRenderPass == false) { (string passName, string lightMode) = pass.NameAndLightMode(rp); AppendLine($"Name \"{passName}\""); AppendLine("Tags { " + (ShaderTag)("LightMode", lightMode) + " }"); } using (Scope("Stencil")) { AppendLine("Comp [_StencilComp]"); AppendLine("Pass [_StencilOpPass]"); AppendLine("Ref [_StencilID]"); AppendLine("ReadMask [_StencilReadMask]"); AppendLine("WriteMask [_StencilWriteMask]"); } // culling/blend mode if (pass == ShaderPassType.Render) { AppendLines(blendMode.GetPassRenderStates()); } else { AppendLine("Cull Off"); // todo: might be incorrect for DepthOnly } // hlsl program AppendHlslProgram(pass, rp); } }
/// <inheritdoc /> void IModule.LoadModule() { if (Application.isPlaying) { m_HoldForGameView = true; } CompositeRenderRuntimeUtils.OnImageEffectSettingsSet += SetImageEffectsProfile; CompositeRenderRuntimeUtils.OnImageEffectSettingsUnset += TearDownImageEffectsProfile; EditorApplication.playModeStateChanged += EditorApplicationPlayModeStateChanged; if (CompositeRenderRuntimeUtils.ImageEffectSettings != null) { SetImageEffectsProfile(CompositeRenderRuntimeUtils.ImageEffectSettings); } foreach (var contextPair in m_CompositeViewRenderContexts) { if (contextPair.Key is SceneView) { contextPair.Value.Dispose(); } } m_CompositeViewRenderContexts.Clear(); m_SceneViews.Clear(); SceneView.beforeSceneGui += OnBeforeSceneGui; SceneView.duringSceneGui += OnDuringSceneGui; // Cache render pipeline to catch if it changes when the composite render module is running. m_RenderPipeline = RenderPipelineManager.currentPipeline; CompositeRenderEditorUtils.SetupRenderShaderGlobals(); }
public static RenderPipeline Render2DOutline(this RenderPipeline pipeline, BoundarySystem boundarySystem) { var stage = new Render2DBoundariesStage(boundarySystem, pipeline.Device); pipeline.Add(stage); return(pipeline); }
public static RenderPipeline GetRenderPipeline() { #if UNITY_2018_1_OR_NEWER #if UNITY_2019_1_OR_NEWER //Render pipeline is no longer expiremental UnityEngine.Rendering.RenderPipelineAsset renderPipelineAsset = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset; #else UnityEngine.Experimental.Rendering.RenderPipelineAsset renderPipelineAsset = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset; #endif if (renderPipelineAsset) { if (renderPipelineAsset.name.Contains("Lightweight") || renderPipelineAsset.name.Contains("LWRP")) { pipeline = RenderPipeline.Lightweight; } else if (renderPipelineAsset.name.Contains("HD")) { pipeline = RenderPipeline.HighDefinition; } } else { pipeline = RenderPipeline.Legacy; } #if SCPE_DEV Debug.Log("<b>" + SCPE.ASSET_NAME + "</b> Pipeline active: " + pipeline.ToString()); #endif #else pipeline = RenderPipeline.Legacy; #endif return pipeline; }
void CheckRenderPipelineChanged() { // Check to see if pipeline changed in first scene view layout if (Event.current.type != EventType.Repaint) { if (m_PipelineChanged) { return; } var activeRenderPipeline = RenderPipelineManager.currentPipeline; m_PipelineChanged = activeRenderPipeline != m_RenderPipeline; m_RenderPipeline = activeRenderPipeline; } // In first repaint (render) of scene view ready the dispose // if the render pipeline has changed else { if (m_PipelineChanged && !m_DisposingAllSceneViews) { EditorApplication.delayCall += DisposeAllSceneViews; m_DisposingAllSceneViews = true; } } }
public void GameLoop(object sender, EventArgs args) { if (currentLevel.WavesAmount == 0) { currentLevel.IsCompleted = true; currentLevel.Particles.Add(ParticleFactory.CreateExit(currentLevel.Exit.Center)); } if (player.IsDead) { ResetState(); } if (currentLevel.IsCompleted && CollisionDetector.GetCollisionInfo(player.CollisionShape, currentLevel.Exit) != null) { currentLevel = LevelManager.MoveNextLevel(); InitState(); } var shouldRenderRaytracing = keyState.pressesOnPAmount % 2 == 1; var shouldRenderDebug = keyState.pressesOnIAmount % 2 == 1; UpdateState(shouldRenderRaytracing); RenderPipeline.Render(currentLevel, camera, cursor.Position, shouldRenderRaytracing, shouldRenderDebug); AudioEngine.Update(); }
public static RenderPipeline RenderDebugLines(this RenderPipeline pipeline, LineSystem lineSystem) { var stage = new RenderDebugLinesStage(lineSystem, pipeline.Device); pipeline.Add(stage); return(pipeline); }
public static RenderPipeline RenderShadows(this RenderPipeline pipeline, ShadowPipeline shadowPipeline) { var stage = new RenderShadowsStage(shadowPipeline); pipeline.Add(stage); return(pipeline); }
public GenShader(RenderPipeline rp, RenderingMode rm, EnabledFeatures enabledFeatures) { m_RenderingMode = rm; m_EnabledFeatures = enabledFeatures; switch (rp) { case RenderPipeline.BuiltIn: AddPass(CullMode.Front); if (rm == RenderingMode.MultiPass) { AddPass(CullMode.Back); } m_RenderPipeline = SRPHelper.RenderPipeline.BuiltIn; break; case RenderPipeline.URP: AddPass(CullMode.Front); m_RenderPipeline = SRPHelper.RenderPipeline.URP; break; case RenderPipeline.HDRP: AddPass(CullMode.Front); m_RenderPipeline = SRPHelper.RenderPipeline.HDRP; break; } }
public static RenderPipeline UpdateSystem(this RenderPipeline pipeline, IUpdatableSystem system) { var stage = new UpdateSystemStage(system); pipeline.Add(stage); return(pipeline); }
protected override void Dispose(bool disposeManagedResources) { _renderPipeline.Dispose(); _renderPipeline = null; base.Dispose(disposeManagedResources); }
internal static bool TryGetPreprocessorRP(out RenderPipeline rp) { List <string> keywords = GetCurrentKeywords(); bool kwURP = keywords.Contains(RenderPipeline.URP.PreprocessorDefineName()); bool kwHDRP = keywords.Contains(RenderPipeline.HDRP.PreprocessorDefineName()); rp = default; if (kwURP && !kwHDRP) { rp = RenderPipeline.URP; } else if (kwHDRP && !kwURP) { rp = RenderPipeline.HDRP; } else if (!kwHDRP && !kwURP) { rp = RenderPipeline.Legacy; } else { return(false); } return(true); }
static void EnsurePreprocessorsAreDefined(RenderPipeline rpTarget) { BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; List <string> symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(';').ToList(); bool changed = false; void CheckRpSymbol(RenderPipeline rp) { bool on = rp == rpTarget; string ppName = rp.PreprocessorDefineName(); if (on && symbols.Contains(ppName) == false) { symbols.Add(ppName); changed = true; } else if (on == false && symbols.Remove(ppName)) { changed = true; } } CheckRpSymbol(RenderPipeline.URP); CheckRpSymbol(RenderPipeline.HDRP); if (changed) { Debug.Log($"Shapes updated your project scripting define symbols since you seem to be using {rpTarget.PrettyName()}, I hope that's okay~"); PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", symbols)); } }
static void SetPreprocessorRpSymbols(RenderPipeline rpTarget) { Debug.Log($"Setting preprocessor symbols for {rpTarget.PrettyName()}"); List <string> symbols = GetCurrentKeywords(); bool changed = false; void CheckRpSymbol(RenderPipeline rp) { bool on = rp == rpTarget; string ppName = rp.PreprocessorDefineName(); if (on && symbols.Contains(ppName) == false) { symbols.Add(ppName); changed = true; } else if (on == false && symbols.Remove(ppName)) { changed = true; } } CheckRpSymbol(RenderPipeline.URP); CheckRpSymbol(RenderPipeline.HDRP); if (changed && ShapesIO.TryMakeAssetsEditable(ShapesIO.projectSettingsPath)) { //Debug.Log( $"Shapes updated your project scripting define symbols since you seem to be using {rpTarget.PrettyName()}, I hope that's okay~" ); SetCurrentKeywords(symbols); } }
public ShaderBuilder(string name, ShapesBlendMode blendMode, RenderPipeline rp) { this.blendMode = blendMode; this.shaderName = name; using (Scope($"Shader \"Shapes/{name} {blendMode.ToString()}\"")) { using (Scope("Properties")) { AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest (\"Z Test\", int) = 4"); AppendLine("_ZOffsetFactor (\"Z Offset Factor\", Float ) = 0"); AppendLine("_ZOffsetUnits (\"Z Offset Units\", int ) = 0"); AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp (\"Stencil Comparison\", int) = 8"); AppendLine("[Enum(UnityEngine.Rendering.StencilOp)] _StencilOpPass (\"Stencil Operation Pass\", int) = 0"); AppendLine("_StencilID (\"Stencil ID\", int) = 0"); AppendLine("_StencilReadMask (\"Stencil Read Mask\", int) = 255"); AppendLine("_StencilWriteMask (\"Stencil Write Mask\", int) = 255"); } using (Scope("SubShader")) { using (Scope("Tags")) { // subshader tags AppendLines(rp.GetSubshaderTags()); AppendLines(blendMode.GetSubshaderTags()); } AppendPass(ShaderPassType.Render, rp); if (rp != RenderPipeline.Legacy) { AppendPass(ShaderPassType.DepthOnly, rp); } AppendPass(ShaderPassType.Picking, rp); AppendPass(ShaderPassType.Selection, rp); } } }
private void OnLoadScene(GameObject go) { this.m_SceneRoot = (TacticsSceneSettings)go.GetComponent <TacticsSceneSettings>(); if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.m_SceneRoot, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object)Camera.get_main(), (UnityEngine.Object)null)) { RenderPipeline component = (RenderPipeline)((Component)Camera.get_main()).GetComponent <RenderPipeline>(); if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null)) { component.BackgroundImage = (Texture)this.m_SceneRoot.BackgroundImage; component.ScreenFilter = (Texture)this.m_SceneRoot.ScreenFilter; } if (this.m_SceneRoot.OverrideCameraSettings) { this.m_CamYawMin = this.m_SceneRoot.CameraYawMin; this.m_CamYawMax = this.m_SceneRoot.CameraYawMax; } else { GameSettings instance = GameSettings.Instance; this.m_CamYawMin = instance.GameCamera_YawMin; this.m_CamYawMax = instance.GameCamera_YawMax; } this.m_SceneRoot.GenerateGridMesh(this.CurrentMap.Width, this.CurrentMap.Height); } go.SetActive(true); }
private void AddDebug(RenderPipeline pipeline, RenderPipelineSettings settings) { pipeline .EnableIf(settings.EnableDebugLines, x => x.RenderDebugLines(this.Systems.Get <LineSystem>())) .EnableIf(settings.Enable3DOutlines, x => x.Render3DOutline(this.Systems.Get <BoundarySystem>())) .EnableIf(settings.Enable2DOutlines, x => x.Render2DOutline(this.Systems.Get <BoundarySystem>())) .EnableIf(settings.EnableIcons, x => x.RenderIcons(this.Systems.Get <IconSystem>())); }
private void OnEnable() { if (!BeamGeometry.IsUsingCustomRenderPipeline()) { return; } RenderPipeline.add_beginCameraRendering(new Action <Camera>(this.OnBeginCameraRendering)); }
public override void Initialize() { _renderPipeline = new RenderPipeline(Game.GraphicsDevice); Game.Input.MessageBuffer.Handlers.Add(_cameraInputMessageHandler); base.Initialize(); }
public static IEnumerable <string> GetSubshaderTags(this RenderPipeline rp) { if (rp == RenderPipeline.Legacy) { yield break; // this is due to a bug where SRP sometimes picks the legacy pipeline. Putting it last and without a tag fixes this } yield return((ShaderTag)("RenderPipeline", rp.PipelineSubshaderTagValue())); }
public DeferredRenderPipeline( GraphicsDevice device, ShadowMapSystem shadowMapSystem, ModelSystem modelSystem, AveragedParticleSystem particleSystem, AdditiveParticleSystem additiveParticleSystem, ProjectorSystem projectorSystem, EffectFactory effectFactory, AmbientLightSystem ambientLightSystem, DirectionalLightSystem directionalLightSystem, PointLightSystem pointLightSystem, CascadedShadowMapSystem cascadedShadowMapSystem, ShadowCastingLightSystem shadowCastingLightSystem, SunlightSystem sunlightSystem, BoundarySystem boundarySystem, DynamicTextureSystem dynamicTextureSystem, IconSystem iconSystem, CutsceneSystem cutsceneSystem, IMeterRegistry meterRegistry) { this.ShadowMapSystem = shadowMapSystem; this.ModelSystem = modelSystem; this.TransparentParticleSystem = particleSystem; this.AdditiveParticleSystem = additiveParticleSystem; this.ProjectorSystem = projectorSystem; this.CombineEffect = effectFactory.Construct <CombineEffect>(); this.FxaaEffect = effectFactory.Construct <FxaaEffect>(); this.AmbientLightSystem = ambientLightSystem; this.DirectionalLightSystem = directionalLightSystem; this.PointLightSystem = pointLightSystem; this.CascadedShadowMapSystem = cascadedShadowMapSystem; this.ShadowCastingLightSystem = shadowCastingLightSystem; this.SunlightSystem = sunlightSystem; this.BoundarySystem = boundarySystem; this.DynamicTextureSystem = dynamicTextureSystem; this.CutsceneSystem = cutsceneSystem; this.IconSystem = iconSystem; var width = device.PresentationParameters.BackBufferWidth; var height = device.PresentationParameters.BackBufferHeight; this.GBuffer = new GBuffer(device, width, height); this.Input = new RenderPipelineInput(); this.Settings = new RenderPipelineSettings(); this.ShadowPipeline = ShadowPipeline.Create(device, meterRegistry); this.LightingPipeline = LightingPipeline.Create(device, meterRegistry); this.ModelPipeline = ModelPipeline.Create(device, meterRegistry); this.ParticlePipeline = ParticlePipeline.Create(device, meterRegistry); this.ProjectorPipeline = ProjectorPipeline.Create(device, meterRegistry); this.Pipeline = RenderPipeline.Create(device, meterRegistry); this.RootPass = new Pass(PassType.Opaque, 0); this.Recreate(); }
public static RenderPipeline RenderParticles( this RenderPipeline pipeline, ParticlePipeline particlePipeline) { var stage = new RenderParticlesStage(particlePipeline); pipeline.Add(stage); return(pipeline); }
public ResolutionRelativeRenderLayer( string fullName , GlobalLayerScaleType layerScaleType , UniformLayerScaleType uniformScaleType ) : base(fullName) { rp = ArtemisEngine.RenderPipeline; // for convenience LayerScaleType = layerScaleType; UniformScaleType = uniformScaleType; RecalculateTargetTransform(); }
private void CreatePipeline(bool renderInOnePass) { // Processor Entities.Processors.Add(new CubemapSourceProcessor(GraphicsDevice)); // Rendering pipeline var cubeMapPipeline = new RenderPipeline("CubeMap"); cubeMapPipeline.Renderers.Add(new ModelRenderer(Services, renderInOnePass ? "CubemapGeomEffect" : "CubemapEffect").AddLayerFilter(RenderGroups.Group1)); RenderSystem.Pipeline.Renderers.Add(new CubemapRenderer(Services, cubeMapPipeline, renderInOnePass)); RenderSystem.Pipeline.Renderers.Add(new CameraSetter(Services)); RenderSystem.Pipeline.Renderers.Add(new RenderTargetSetter(Services) { ClearColor = Color.CornflowerBlue }); RenderSystem.Pipeline.Renderers.Add(new ModelRenderer(Services, "CubemapEffect")); }
private void CreatePipeline() { // Processor Entities.Processors.Add(new CubemapSourceProcessor(GraphicsDevice)); // Rendering pipeline RenderSystem.Pipeline.Renderers.Add(new CameraSetter(Services)); RenderSystem.Pipeline.Renderers.Add(new RenderTargetSetter(Services) { ClearColor = Color.CornflowerBlue, EnableClearDepth = true, ClearDepth = 1f }); // Create G-buffer pass var gbufferPipeline = new RenderPipeline("GBuffer"); // Renders the G-buffer for opaque geometry. gbufferPipeline.Renderers.Add(new ModelRenderer(Services, "CubemapIBLEffect.XenkoGBufferShaderPass")); var gbufferProcessor = new GBufferRenderProcessor(Services, gbufferPipeline, GraphicsDevice.DepthStencilBuffer, false); // Add sthe G-buffer pass to the pipeline. RenderSystem.Pipeline.Renderers.Add(gbufferProcessor); var readOnlyDepthBuffer = GraphicsDevice.DepthStencilBuffer; // TODO ToDepthStencilBuffer(true); IBLRenderer = new LightingIBLRenderer(Services, "CubemapIBLSpecular", readOnlyDepthBuffer); RenderSystem.Pipeline.Renderers.Add(IBLRenderer); RenderSystem.Pipeline.Renderers.Add(new RenderTargetSetter(Services) { ClearColor = Color.CornflowerBlue, EnableClearDepth = false, }); RenderSystem.Pipeline.Renderers.Add(new DelegateRenderer(Services) { Render = ShowIBL }); }