Example #1
0
        internal override void Internal_Render(GPUContext context)
        {
            // Copy flags
            View.Flags = Flags;
            View.Mode  = Mode;

            // Create buffers if missing
            if (Buffers == null)
            {
                Buffers = RenderBuffers.New();
            }

            // Prepare view
            OnBegin(context);
            Viewport viewport = new Viewport(Vector2.Zero, Buffers.Size);

            if (Camera != null)
            {
                View.CopyFrom(Camera, ref viewport);
            }

            // Get custom post effects to render (registered ones and from the current camera)
            _postFx.Clear();
            foreach (var e in CustomPostFx)
            {
                _postFx.Add(e);
            }
            if (AllowGlobalCustomPostFx)
            {
                foreach (var e in GlobalCustomPostFx)
                {
                    _postFx.Add(e);
                }
            }
            if (Camera != null)
            {
                var perCameraPostFx = Camera.GetScripts <PostProcessEffect>();
                for (int i = 0; i < perCameraPostFx.Length; i++)
                {
                    _postFx.Add(perCameraPostFx[i]);
                }
            }

            // Call scene rendering
            var customActors = CustomActors.Count > 0 ? CustomActors.ToArray() : null;

            context.DrawScene(this, Output, Buffers, View, Flags, Mode, customActors, ActorsSource, _postFx);

            // Finish
            OnEnd(context);
        }
Example #2
0
        public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, ref RenderView view, ViewFlags flags, ViewMode mode, List <Actor> customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            // Get unmanaged actors
            var actors = GetActors(customActors, out int actorsCount);

            // Get unmanaged postFx
            var postFx = GetPostFx(customPostFx, out int postFxCount);

            Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsCount, actorsSource, postFx, postFxCount);
#endif
        }
Example #3
0
        public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, RenderView view, ViewFlags flags, ViewMode mode, Actor[] customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            // Get unmanaged actors
            IntPtr[] actors = null;
            if (customActors != null)
            {
                actors = new IntPtr[customActors.Length];
                for (int i = 0; i < customActors.Length; i++)
                {
                    actors[i] = GetUnmanagedPtr(customActors[i]);
                }
            }

            // Get unmanaged postFx
            IntPtr[] postFx = null;
            if (customPostFx != null)
            {
                var postFxList = new List <IntPtr>(customPostFx.Count);
                foreach (var e in customPostFx)
                {
                    if (e && e.CanRender)
                    {
                        postFxList.Add(e.unmanagedPtr);
                    }
                }

                if (postFxList.Count > 0)
                {
                    postFx = postFxList.ToArray();
                }
            }

            Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsSource, postFx);
#endif
        }
Example #4
0
        public void DrawPostFxMaterial(MaterialBase material, RenderTarget output, RenderTarget input, RenderView view, RenderBuffers buffers = null)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            Internal_DrawPostFxMaterial1(unmanagedPtr, Object.GetUnmanagedPtr(material), Object.GetUnmanagedPtr(output), Object.GetUnmanagedPtr(input), ref view, Object.GetUnmanagedPtr(buffers));
#endif
        }
Example #5
0
        public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, RenderView view, ViewFlags flags, ViewMode mode, Actor[] customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            // Get unmanaged actors
            IntPtr[] actors      = null;
            int      actorsCount = 0;
            if (customActors != null)
            {
                actorsCount = customActors.Length;
                if (_cachedActors == null || _cachedActors.Length < actorsCount)
                {
                    _cachedActors = new IntPtr[Mathf.NextPowerOfTwo(actorsCount)];
                }
                actors = _cachedActors;

                for (int i = 0; i < actorsCount; i++)
                {
                    _cachedActors[i] = GetUnmanagedPtr(customActors[i]);
                }
            }

            // Get unmanaged postFx
            IntPtr[] postFx      = null;
            int      postFxCount = 0;
            if (customPostFx != null && customPostFx.Count > 0)
            {
                if (_cachedPostFxA == null)
                {
                    _cachedPostFxA = new List <PostProcessEffect>();
                }
                _cachedPostFxA.Capacity = Mathf.Max(_cachedPostFxA.Capacity, Mathf.NextPowerOfTwo(customPostFx.Count));

                foreach (var e in customPostFx)
                {
                    if (e && e.CanRender)
                    {
                        _cachedPostFxA.Add(e);
                    }
                }

                _cachedPostFxA.Sort(ComparePostFx);

                postFxCount = _cachedPostFxA.Count;
                if (_cachedPostFxB == null || _cachedPostFxB.Length < postFxCount)
                {
                    _cachedPostFxB = new IntPtr[_cachedPostFxA.Capacity];
                }
                postFx = _cachedPostFxB;

                for (int i = 0; i < postFxCount; i++)
                {
                    _cachedPostFxB[i] = GetUnmanagedPtr(_cachedPostFxA[i]);
                }

                _cachedPostFxA.Clear();
            }

            Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsCount, actorsSource, postFx, postFxCount);
#endif
        }