Example #1
0
 internal static void CheckStoreActionValid(RenderBufferStoreAction store, string bufferType)
 {
     if ((store != RenderBufferStoreAction.Store) && (store != RenderBufferStoreAction.DontCare))
     {
         throw new ArgumentException("Bad " + bufferType + " StoreAction");
     }
 }
Example #2
0
 internal static void CheckStoreActionValid(RenderBufferStoreAction store, string bufferType)
 {
     if ((store != RenderBufferStoreAction.Store) && (store != RenderBufferStoreAction.DontCare))
     {
         object[] args = new object[] { bufferType };
         throw new ArgumentException(UnityString.Format("Bad {0} StoreAction provided.", args));
     }
 }
		internal static RenderBufferStoreAction[] StoreActions(RenderBuffer[] buf)
		{
			RenderBufferStoreAction[] array = new RenderBufferStoreAction[buf.Length];
			for (int i = 0; i < buf.Length; i++)
			{
				array[i] = buf[i].storeAction;
				buf[i].storeAction = RenderBufferStoreAction.Store;
			}
			return array;
		}
		internal RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, int face, RenderBufferLoadAction[] colorLoad, RenderBufferStoreAction[] colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore)
		{
			this.color = color;
			this.depth = depth;
			this.mipLevel = mip;
			this.cubemapFace = face;
			this.colorLoad = colorLoad;
			this.colorStore = colorStore;
			this.depthLoad = depthLoad;
			this.depthStore = depthStore;
		}
Example #5
0
 private static extern void Internal_SetMRTFullSetup(RenderBuffer[] colorSA, out RenderBuffer depth, int mip, CubemapFace face, RenderBufferLoadAction[] colorLoadSA, RenderBufferStoreAction[] colorStoreSA, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore);
Example #6
0
 private static extern void Internal_SetRTFullSetup(out RenderBuffer color, out RenderBuffer depth, int mip, int face, RenderBufferLoadAction colorLoad, RenderBufferStoreAction colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore);
Example #7
0
 // Explicit load and store actions
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier buffer, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, ClearFlag clearFlag, Color clearColor)
 {
     cmd.SetRenderTarget(buffer, loadAction, storeAction);
     ClearRenderTarget(cmd, clearFlag, clearColor);
 }
        public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd, RenderTargetIdentifier rt, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction)
        {
#if UNITY_2018_2_OR_NEWER
            cmd.SetRenderTarget(rt, loadAction, storeAction);
#else
            cmd.SetRenderTarget(rt);
#endif
        }
Example #9
0
 extern private static void Internal_SetMRTFullSetup(
     [NotNull] RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face, int depthSlice,
     [NotNull] RenderBufferLoadAction[] colorLA, [NotNull] RenderBufferStoreAction[] colorSA,
     RenderBufferLoadAction depthLA, RenderBufferStoreAction depthSA
     );
Example #10
0
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorAttachment, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction, ClearFlag clearFlags, Color clearColor, TextureDimension dimension)
 {
     if (dimension == TextureDimension.Tex2DArray)
     {
         CoreUtils.SetRenderTarget(cmd, colorAttachment, clearFlags, clearColor, 0, CubemapFace.Unknown, -1);
     }
     else
     {
         CoreUtils.SetRenderTarget(cmd, colorAttachment, colorLoadAction, colorStoreAction, clearFlags, clearColor);
     }
 }
 protected void SetRenderTarget(CommandBuffer cmd, RenderBufferLoadAction loadOp, RenderBufferStoreAction storeOp, ClearFlag clearFlag, Color clearColor)
 {
     if (colorAttachmentHandle != RenderTargetHandle.CameraTarget)
     {
         if (depthAttachmentHandle != RenderTargetHandle.CameraTarget)
         {
             SetRenderTarget(
                 cmd,
                 colorAttachmentHandle.Identifier(),
                 loadOp,
                 storeOp,
                 depthAttachmentHandle.Identifier(),
                 loadOp,
                 storeOp,
                 clearFlag,
                 clearColor,
                 descriptor.dimension);
         }
         else
         {
             SetRenderTarget(cmd, colorAttachmentHandle.Identifier(), loadOp, storeOp, clearFlag, clearColor, descriptor.dimension);
         }
     }
     else
     {
         SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget, loadOp, storeOp, clearFlag, clearColor, descriptor.dimension);
     }
 }
 public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face, RenderBufferLoadAction[] colorLoad, RenderBufferStoreAction[] colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore)
 {
     this.color       = color;
     this.depth       = depth;
     this.mipLevel    = mip;
     this.cubemapFace = face;
     this.colorLoad   = colorLoad;
     this.colorStore  = colorStore;
     this.depthLoad   = depthLoad;
     this.depthStore  = depthStore;
 }
Example #13
0
 private static extern void SetStoreAction_Injected(ref RenderBuffer _unity_self, RenderBufferStoreAction action);
Example #14
0
        public static void RenderLightVolumes(this IRenderPass2D pass, RenderingData renderingData, CommandBuffer cmd, int layerToRender, int endLayerValue,
                                              RenderTargetIdentifier renderTexture, RenderTargetIdentifier depthTexture, RenderBufferStoreAction intermediateStoreAction,
                                              RenderBufferStoreAction finalStoreAction, bool requiresRTInit, List <Light2D> lights)
        {
            var maxShadowLightCount = ShadowRendering.maxTextureCount * 4;  // Now encodes shadows into RGBA as well as seperate textures

            // This case should never happen, but if it does it may cause an infinite loop later.
            if (maxShadowLightCount < 1)
            {
                Debug.LogError("maxShadowLightCount cannot be less than 1");
                return;
            }

            // Determine last light with volumetric shadows to be rendered if we want to use a different store action after using rendering its volumetric shadows
            int useFinalStoreActionAfter = lights.Count;

            if (intermediateStoreAction != finalStoreAction)
            {
                for (int i = lights.Count - 1; i >= 0; i--)
                {
                    if (lights[i].renderVolumetricShadows)
                    {
                        useFinalStoreActionAfter = i;
                        break;
                    }
                }
            }

            // Break up light rendering into batches for the purpose of shadow casting
            var lightIndex = 0;

            while (lightIndex < lights.Count)
            {
                var remainingLights = (uint)lights.Count - lightIndex;
                var batchedLights   = 0;

                // Add lights to our batch until the number of shadow textures reach the maxShadowTextureCount
                var shadowLightCount = 0;
                while (batchedLights < remainingLights && shadowLightCount < maxShadowLightCount)
                {
                    var light = lights[lightIndex + batchedLights];
                    if (light.renderVolumetricShadows)
                    {
                        ShadowRendering.PrerenderShadows(pass, renderingData, cmd, layerToRender, light, shadowLightCount, light.shadowVolumeIntensity);
                        shadowLightCount++;
                    }
                    batchedLights++;
                }

                // Set the current RT to the light RT
                if (shadowLightCount > 0 || requiresRTInit)
                {
                    var storeAction = lightIndex + batchedLights >= useFinalStoreActionAfter ? finalStoreAction : intermediateStoreAction;
                    cmd.SetRenderTarget(renderTexture, RenderBufferLoadAction.Load, storeAction, depthTexture, RenderBufferLoadAction.Load, storeAction);
                    requiresRTInit = false;
                }

                // Render all the lights.
                shadowLightCount = 0;
                for (var lightIndexOffset = 0; lightIndexOffset < batchedLights; lightIndexOffset++)
                {
                    var light = lights[(int)(lightIndex + lightIndexOffset)];

                    if (light.lightType == Light2D.LightType.Global)
                    {
                        continue;
                    }

                    if (light.volumeIntensity <= 0.0f || !light.volumeIntensityEnabled)
                    {
                        continue;
                    }

                    var topMostLayerValue = light.GetTopMostLitLayer();
                    if (endLayerValue == topMostLayerValue) // this implies the layer is correct
                    {
                        var lightVolumeMaterial = pass.rendererData.GetLightMaterial(light, true);
                        var lightMesh           = light.lightMesh;

                        // Set the shadow texture to read from.
                        if (light.volumetricShadowsEnabled && light.shadowVolumeIntensity > 0)
                        {
                            ShadowRendering.SetGlobalShadowTexture(cmd, light, shadowLightCount++);
                        }
                        else
                        {
                            ShadowRendering.DisableGlobalShadowTexture(cmd);
                        }

                        if (light.lightType == Light2D.LightType.Sprite && light.lightCookieSprite != null && light.lightCookieSprite.texture != null)
                        {
                            cmd.SetGlobalTexture(k_CookieTexID, light.lightCookieSprite.texture);
                        }

                        SetGeneralLightShaderGlobals(pass, cmd, light);

                        // Is this needed
                        if (light.normalMapQuality != Light2D.NormalMapQuality.Disabled || light.lightType == Light2D.LightType.Point)
                        {
                            SetPointLightShaderGlobals(pass, cmd, light);
                        }

                        // Could be combined...
                        if (light.lightType == Light2D.LightType.Parametric || light.lightType == Light2D.LightType.Freeform || light.lightType == Light2D.LightType.Sprite)
                        {
                            cmd.DrawMesh(lightMesh, light.transform.localToWorldMatrix, lightVolumeMaterial);
                        }
                        else if (light.lightType == Light2D.LightType.Point)
                        {
                            DrawPointLight(cmd, light, lightMesh, lightVolumeMaterial);
                        }
                    }
                }


                // Release all of the temporary shadow textures
                for (var releaseIndex = shadowLightCount - 1; releaseIndex >= 0; releaseIndex--)
                {
                    ShadowRendering.ReleaseShadowRenderTexture(cmd, releaseIndex);
                }

                lightIndex += batchedLights;
            }
        }
Example #15
0
 internal void SetStoreAction(RenderBufferStoreAction action)
 {
     RenderBuffer.SetStoreAction_Injected(ref this, action);
 }
 public RenderTargetBinding(RenderTargetIdentifier[] colorRenderTargets, RenderBufferLoadAction[] colorLoadActions, RenderBufferStoreAction[] colorStoreActions, RenderTargetIdentifier depthRenderTarget, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
 {
     this.m_ColorRenderTargets = colorRenderTargets;
     this.m_DepthRenderTarget  = depthRenderTarget;
     this.m_ColorLoadActions   = colorLoadActions;
     this.m_ColorStoreActions  = colorStoreActions;
     this.m_DepthLoadAction    = depthLoadAction;
     this.m_DepthStoreAction   = depthStoreAction;
     this.m_Flags = RenderTargetFlags.None;
 }
 internal static RenderBufferStoreAction[] StoreActions(RenderBuffer[] buf)
 {
   RenderBufferStoreAction[] bufferStoreActionArray = new RenderBufferStoreAction[buf.Length];
   for (int index = 0; index < buf.Length; ++index)
   {
     bufferStoreActionArray[index] = buf[index].storeAction;
     buf[index].storeAction = RenderBufferStoreAction.Store;
   }
   return bufferStoreActionArray;
 }
 public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd, RenderTargetIdentifier rt, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction)
 {
     cmd.SetRenderTarget(rt);
 }
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                                    RenderTargetIdentifier depthBuffer, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction,
                                    ClearFlag clearFlag)
 {
     SetRenderTarget(cmd, colorBuffer, colorLoadAction, colorStoreAction, depthBuffer, depthLoadAction, depthStoreAction, clearFlag, clearColorAllBlack);
 }
Example #20
0
        private void CopyCameraSortingLayerRenderTexture(ScriptableRenderContext context, RenderingData renderingData, RenderBufferStoreAction mainTargetStoreAction)
        {
            var cmd = CommandBufferPool.Get();

            cmd.Clear();
            this.CreateCameraSortingLayerRenderTexture(renderingData, cmd, m_Renderer2DData.cameraSortingLayerDownsamplingMethod);

            Material copyMaterial = m_Renderer2DData.cameraSortingLayerDownsamplingMethod == Downsampling._4xBox ? m_SamplingMaterial : m_BlitMaterial;

            RenderingUtils.Blit(cmd, colorAttachment, m_Renderer2DData.cameraSortingLayerRenderTarget.id, copyMaterial, 0, false, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare);
            cmd.SetRenderTarget(colorAttachment, RenderBufferLoadAction.Load, mainTargetStoreAction,
                                depthAttachment, RenderBufferLoadAction.Load, mainTargetStoreAction);
            cmd.SetGlobalTexture(k_CameraSortingLayerTextureID, m_Renderer2DData.cameraSortingLayerRenderTarget.id);
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
 protected void SetRenderTarget(CommandBuffer cmd, RenderBufferLoadAction loadOp, RenderBufferStoreAction storeOp, ClearFlag clearFlag, Color clearColor)
 {
     SetRenderTarget(
         cmd,
         colorAttachmentHandle.Identifier(),
         loadOp,
         storeOp,
         depthAttachmentHandle.Identifier(),
         loadOp,
         storeOp,
         clearFlag,
         clearColor,
         descriptor.dimension);
 }
Example #22
0
 internal void SetStoreAction(RenderBufferStoreAction action)
 {
     RenderBufferHelper.SetStoreAction(out this, (int) action);
 }
 public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd, RenderTargetIdentifier color, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction, RenderTargetIdentifier depth, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
 {
     cmd.SetRenderTarget(color, depth);
 }
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                                    RenderTargetIdentifier depthBuffer, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction,
                                    ClearFlag clearFlag, Color clearColor)
 {
     cmd.SetRenderTarget(colorBuffer, colorLoadAction, colorStoreAction, depthBuffer, depthLoadAction, depthStoreAction);
     ClearRenderTarget(cmd, clearFlag, clearColor);
 }
Example #25
0
 private static extern void Internal_SetRTFullSetup(out RenderBuffer color, out RenderBuffer depth, int mip, int face, RenderBufferLoadAction colorLoad, RenderBufferStoreAction colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore);
Example #26
0
 internal void SetStoreAction(RenderBufferStoreAction action)
 {
     RenderBufferHelper.SetStoreAction(out this, (int)action);
 }
Example #27
0
        public RenderTargetBinding(RenderTargetIdentifier[] colorRenderTargets, RenderBufferLoadAction[] colorLoadActions, RenderBufferStoreAction[] colorStoreActions,
                                   RenderTargetIdentifier depthRenderTarget, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
        {
            m_ColorRenderTargets = colorRenderTargets;
            m_DepthRenderTarget  = depthRenderTarget;

            m_ColorLoadActions  = colorLoadActions;
            m_ColorStoreActions = colorStoreActions;

            m_DepthLoadAction  = depthLoadAction;
            m_DepthStoreAction = depthStoreAction;
        }
Example #28
0
 extern internal void SetStoreAction(RenderBufferStoreAction action);
Example #29
0
 public RenderTargetBinding(RenderTargetIdentifier colorRenderTarget, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                            RenderTargetIdentifier depthRenderTarget, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
     : this(new RenderTargetIdentifier[] { colorRenderTarget }, new RenderBufferLoadAction[] { colorLoadAction }, new RenderBufferStoreAction[] { colorStoreAction }, depthRenderTarget, depthLoadAction, depthStoreAction)
 {
 }
Example #30
0
 private static extern void Internal_SetMRTFullSetup(RenderBuffer[] colorSA, out RenderBuffer depth, int mip, CubemapFace face, RenderBufferLoadAction[] colorLoadSA, RenderBufferStoreAction[] colorStoreSA, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore);
 public void SetRenderTarget(RenderTargetIdentifier rt, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction)
 {
     if (loadAction == RenderBufferLoadAction.Clear)
     {
         throw new ArgumentException("RenderBufferLoadAction.Clear is not supported");
     }
     SetRenderTargetSingle_Internal(rt, loadAction, storeAction, loadAction, storeAction);
 }
Example #32
0
        public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd,
                                                              RenderTargetIdentifier color, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                                                              RenderTargetIdentifier depth, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
        {
#if UNITY_2018_2_OR_NEWER
            cmd.SetRenderTarget(color, colorLoadAction, colorStoreAction, depth, depthLoadAction, depthStoreAction);
#else
            cmd.SetRenderTarget(color, depth);
#endif
        }
 public void SetRenderTarget(RenderTargetIdentifier color, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                             RenderTargetIdentifier depth, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
 {
     if (colorLoadAction == RenderBufferLoadAction.Clear || depthLoadAction == RenderBufferLoadAction.Clear)
     {
         throw new ArgumentException("RenderBufferLoadAction.Clear is not supported");
     }
     SetRenderTargetColorDepth_Internal(color, depth, colorLoadAction, colorStoreAction, depthLoadAction, depthStoreAction);
 }
Example #34
0
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier buffer, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, ClearFlag clearFlag)
 {
     SetRenderTarget(cmd, buffer, loadAction, storeAction, clearFlag, clearColorAllBlack);
 }
 extern private void SetRenderTargetSingle_Internal(RenderTargetIdentifier rt,
                                                    RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                                                    RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction);
 extern private void SetRenderTargetColorDepth_Internal(RenderTargetIdentifier color, RenderTargetIdentifier depth,
                                                        RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
                                                        RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction);
 extern private void SetRenderTargetMulti_Internal(RenderTargetIdentifier[] colors, Rendering.RenderTargetIdentifier depth,
                                                   RenderBufferLoadAction[] colorLoadActions, RenderBufferStoreAction[] colorStoreActions,
                                                   RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction);
Example #38
0
 internal static void CheckStoreActionValid(RenderBufferStoreAction store, string bufferType)
 {
   if (store != RenderBufferStoreAction.Store && store != RenderBufferStoreAction.DontCare)
     throw new ArgumentException(UnityString.Format("Bad {0} StoreAction provided.", (object) bufferType));
 }
Example #39
0
 private static void Internal_SetMRTFullSetup(RenderBuffer[] color, out RenderBuffer depth, int mip, int face, RenderBufferLoadAction[] colorLoad, RenderBufferStoreAction[] colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore)
 {
     throw new NotImplementedException("なにこれ");
 }