Exemplo n.º 1
0
        private void RenderBasic(DX11RenderContext context, DX11RenderSettings settings)
        {
            QuadShaderDeviceData qd = quaddata[context];

            qd.quadshader.SelectTechnique("Render");
            qd.quadgeometry.Bind(qd.quadlayouts[0]);

            for (int i = 0; i < this.spmax; i++)
            {
                bool popstate = false;
                if (this.FInState.IsConnected)
                {
                    context.RenderStateStack.Push(this.FInState[i]);
                    popstate = true;
                }

                qd.quadshader.SetBySemantic("COLOR", this.FInColor[i]);
                qd.quadshader.SetBySemantic("WORLD", this.FInWorld[i]);
                qd.quadshader.SetBySemantic("TEXTUREMATRIX", this.FInTexTransform[i]);

                qd.quadshader.ApplyPass(0);
                if (settings.DepthOnly)
                {
                    context.CurrentDeviceContext.PixelShader.Set(null);
                }

                qd.quadgeometry.Draw();

                if (popstate)
                {
                    context.RenderStateStack.Pop();
                }
            }
        }
Exemplo n.º 2
0
        public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj)
        {
            if (obj.Geometry != null)
            {
                if (obj.Geometry.HasBoundingBox)
                {
                    Vector3 min = obj.Geometry.BoundingBox.Minimum;

                    Vector3 scale = obj.Geometry.BoundingBox.Maximum - obj.Geometry.BoundingBox.Minimum;
                    scale.X = scale.X != 0.0f ? scale.X : 1.0f;
                    scale.Y = scale.Y != 0.0f ? scale.Y : 1.0f;
                    scale.Z = scale.Z != 0.0f ? scale.Z : 1.0f;

                    Matrix m = Matrix.Scaling(scale);

                    m.M41 = min.X;
                    m.M42 = min.Y;
                    m.M43 = min.Z;
                    shaderinstance.SetByName(this.Name, Matrix.Invert(m));
                }
                else
                {
                    shaderinstance.SetByName(this.Name, m);
                }
            }
            else
            {
                shaderinstance.SetByName(this.Name, m);
            }
        }
Exemplo n.º 3
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                IDX11LayerOrder currentOrder = settings.LayerOrder;
                if (this.FInVal.IsConnected)
                {
                    settings.LayerOrder = this.FInVal[0];
                }

                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(context, settings);
                    }
                }

                settings.LayerOrder = currentOrder;
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(context, settings);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;

            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    IDX11Geometry geom = settings.Geometry;

                    settings.Geometry = null;
                    if (settings.BackBuffer is IDX11Buffer)
                    {
                        IDX11Buffer buffer = settings.BackBuffer as IDX11Buffer;
                        if (buffer.Buffer.Description.OptionFlags.HasFlag(ResourceOptionFlags.DrawIndirect))
                        {
                            this.dispatcher.DispatchBuffer = buffer.Buffer;
                            this.dispatcher.Offet          = this.FInOffset[0];
                            settings.Geometry = this.geometry;
                        }
                    }

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    settings.Geometry = geom;
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 5
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FPassLayerIn.IsConnected)
                {
                    var hint = settings.RenderHint;
                    settings.RenderHint = eRenderHint.ApplyOnly;
                    for (int i = 0; i < this.FPassLayerIn.SliceCount; i++)
                    {
                        this.FPassLayerIn[i][context].Render(this.FPassLayerIn.PluginIO, context, settings);
                    }
                    settings.RenderHint = hint;
                }

                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.IsConnected)
            {
                bool allow = false;
                for (int i = 0; i < this.FViewPortIndex.SliceCount;i++)
                {
                    if (this.FViewPortIndex[i] < 0)
                    {
                        allow = true;
                    }
                    else if (this.FViewPortIndex[i] % settings.ViewportCount == settings.ViewportIndex)
                    {
                        allow = true;
                    }
                }

                if (allow)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FPassLayerIn.IsConnected)
                {
                    var hint = settings.RenderHint;
                    settings.RenderHint = eRenderHint.ApplyOnly;
                    for (int i = 0; i < this.FPassLayerIn.SliceCount; i++)
                    {
                        this.FPassLayerIn[i][context].Render(this.FPassLayerIn.PluginIO, context, settings);
                    }
                    settings.RenderHint = hint;
                }

                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    bool popstate = false;

                    if (this.FInState.IsConnected)
                    {
                        context.RenderStateStack.Push(this.FInState[0]);
                        popstate = true;
                    }

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    if (popstate)
                    {
                        context.RenderStateStack.Pop();
                    }
                }
            }
        }
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    bool enabled = this.FInViewports.PluginIO.IsConnected;
                    if (enabled)
                    {
                        context.CurrentDeviceContext.Rasterizer.SetViewports(this.FInViewports.ToArray());
                    }

                    try
                    {
                        this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                    catch
                    {
                        if (enabled)
                        {
                            context.RenderTargetStack.Apply();
                        }
                        throw;
                    }
                }
            }
        }
Exemplo n.º 10
0
 public void Apply(DX11ShaderInstance instance, DX11RenderSettings settings, DX11ObjectRenderSettings objectsettings)
 {
     foreach (string rv in this.variables.Keys)
     {
         this.variables[rv].Apply(instance, settings, objectsettings);
     }
 }
Exemplo n.º 11
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    Matrix view = settings.View;
                    Matrix projection = settings.Projection;
                    Matrix vp = settings.ViewProjection;
                    bool depthonly = settings.DepthOnly;

                    this.UpdateSettings(settings);

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    settings.View = view;
                    settings.Projection = projection;
                    settings.ViewProjection = vp;
                    settings.DepthOnly = depthonly;
                }
            }
            else
            {
                this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);
            }
        }
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    RenderTargetStackElement currentFrameBuffer = context.RenderTargetStack.Current;

                    if (currentFrameBuffer.DepthStencil != null && currentFrameBuffer.DepthStencil is DX11DepthStencil)
                    {
                        context.RenderTargetStack.Push(currentFrameBuffer.DepthStencil, true, currentFrameBuffer.RenderTargets);

                        this.FLayerIn.RenderAll(context, settings);

                        context.RenderTargetStack.Pop();
                    }
                    else
                    {
                        logger.Log(LogType.Warning, "Trying to attach a depth stencil as readonly, but either none is bound or option is not available");
                        this.FLayerIn.RenderAll(context, settings);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    this.FLayerIn.RenderAll(context, settings);
                }
            }
        }
Exemplo n.º 13
0
        private void RenderInstanced(DX11RenderContext context, DX11RenderSettings settings)
        {
            QuadShaderDeviceData qd = quaddata[context];
            bool popstate           = false;

            if (this.FInState.IsConnected)
            {
                context.RenderStateStack.Push(this.FInState[0]);
                popstate = true;
            }

            qd.quadshader.SelectTechnique("RenderInstanced");
            qd.quadgeometry.Bind(qd.quadlayouts[2]);

            this.BindBuffers(context);

            qd.quadshader.ApplyPass(0);
            if (settings.DepthOnly)
            {
                context.CurrentDeviceContext.PixelShader.Set(null);
            }

            context.CurrentDeviceContext.DrawIndexedInstanced(qd.quadgeometry.IndexBuffer.IndicesCount, this.spmax, 0, 0, 0);

            if (popstate)
            {
                context.RenderStateStack.Pop();
            }
        }
Exemplo n.º 14
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    var spMax = SpreadUtils.SpreadMax(this.FInWorld, this.FInRelative);
                    for (int i = 0; i < spMax; i++)
                    {
                        Matrix world = settings.WorldTransform;

                        if (this.FInRelative[i])
                        {
                            settings.WorldTransform = settings.WorldTransform * this.FInWorld[i];
                        }
                        else
                        {
                            settings.WorldTransform = this.FInWorld[i];
                        }


                        this.FLayerIn.RenderAll(context, settings);
                        settings.WorldTransform = world;
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    this.FLayerIn.RenderAll(context, settings);
                }
            }
        }
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    settings.PreferredTechniques.Add(FTechnique[0].Trim().ToLower());

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    settings.PreferredTechniques.RemoveAt(settings.PreferredTechniques.Count - 1);
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 16
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    if (this.FInGeometry.IsConnected)
                    {
                        settings.Geometry = this.FInGeometry[0][context];
                    }

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 17
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.IsConnected)
            {
                bool allow = false;
                for (int i = 0; i < this.FViewPortIndex.SliceCount; i++)
                {
                    if (this.FViewPortIndex[i] < 0)
                    {
                        allow = true;
                    }
                    else if (this.FViewPortIndex[i] % settings.ViewportCount == settings.ViewportIndex)
                    {
                        allow = true;
                    }
                }

                if (allow)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 18
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                var rect = context.CurrentDeviceContext.Rasterizer.GetScissorRectangles();
                if (this.FLayerIn.IsConnected)
                {

                    context.CurrentDeviceContext.Rasterizer.SetScissorRectangles(this.rectangles);
                    try
                    {
                        for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                        {
                            this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                        }
                    }
                    finally
                    {
                        context.CurrentDeviceContext.Rasterizer.SetScissorRectangles(rect);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    List <IDX11RenderSemantic> semantics = new List <IDX11RenderSemantic>();
                    if (this.FInSemantics.PluginIO.IsConnected)
                    {
                        semantics.AddRange(this.FInSemantics);
                        settings.CustomSemantics.AddRange(semantics);
                    }


                    List <DX11Resource <IDX11RenderSemantic> > ressemantics = new List <DX11Resource <IDX11RenderSemantic> >();
                    if (this.FInResSemantics.PluginIO.IsConnected)
                    {
                        ressemantics.AddRange(this.FInResSemantics);
                        settings.ResourceSemantics.AddRange(ressemantics);
                    }

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    foreach (IDX11RenderSemantic semantic in semantics)
                    {
                        settings.CustomSemantics.Remove(semantic);
                    }

                    foreach (DX11Resource <IDX11RenderSemantic> rs in ressemantics)
                    {
                        settings.ResourceSemantics.Remove(rs);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    var currentRef = context.CurrentDeviceContext.OutputMerger.BlendFactor;

                    context.CurrentDeviceContext.OutputMerger.BlendFactor = this.FInFactor[0];

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    context.CurrentDeviceContext.OutputMerger.BlendFactor = currentRef;

                }
            }
            else
            {
                for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                {
                    this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                }
            }
        }
 public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
 {
     if (this.FEnabled[0])
     {
         bool bck = settings.PreserveShaderStages;
         settings.PreserveShaderStages = true;
         if (this.FLayerIn.IsConnected)
         {
             for (int i = 0; i < this.FLayerIn.SliceCount; i++)
             {
                 this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
             }
         }
         settings.PreserveShaderStages = bck;
     }
     else
     {
         if (this.FLayerIn.IsConnected)
         {
             for (int i = 0; i < this.FLayerIn.SliceCount; i++)
             {
                 this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
             }
         }
     }
 }
Exemplo n.º 22
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    IDX11Geometry geom = settings.Geometry;

                    settings.Geometry = null;
                    if (settings.BackBuffer is IDX11Buffer)
                    {
                        IDX11Buffer buffer = settings.BackBuffer as IDX11Buffer;
                        if (buffer.Buffer.Description.OptionFlags.HasFlag(ResourceOptionFlags.DrawIndirect))
                        {
                            this.dispatcher.DispatchBuffer = buffer.Buffer;
                            this.dispatcher.Offet = this.FInOffset[0];
                            settings.Geometry = this.geometry;
                        }
                    }

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    settings.Geometry = geom;
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 23
0
        public void Render(DX11RenderContext context)
        {
            if (!this.FInLayer.PluginIO.IsConnected && this.AllowEmptyLayer == false)
            {
                return;
            }

            if (this.rendereddevices.Contains(context))
            {
                return;
            }

            if (!this.updateddevices.Contains(context))
            {
                this.Update(null, context);
            }

            if (this.FInEnabled[0])
            {
                DX11RenderSettings rs = this.settings[context];

                this.PreRender(context, rs);

                for (int j = 0; j < this.FInLayer.SliceCount; j++)
                {
                    this.FInLayer[j][context].Render(this.FInLayer.PluginIO, context, rs);
                }

                this.PostRender(context);
            }
        }
 public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
 {
     if (this.FEnabled[0])
     {
         bool bck = settings.PreserveShaderStages;
         settings.PreserveShaderStages = true;
         if (this.FLayerIn.IsConnected)
         {
             for (int i = 0; i < this.FLayerIn.SliceCount; i++)
             {
                 this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
             }
         }
         settings.PreserveShaderStages = bck;
     }
     else
     {
         if (this.FLayerIn.IsConnected)
         {
             for (int i = 0; i < this.FLayerIn.SliceCount; i++)
             {
                 this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
             }
         }
     }
 }
Exemplo n.º 25
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.IsConnected)
            {
                for (int i = 0; i < FSemantic.SliceCount; i++)
                {
                    RWStructuredBufferRenderSemantic ccrs = null;
                    foreach (var rsem in settings.CustomSemantics)
                    {
                        if (rsem.Semantic == FSemantic[i])
                        {
                            if (rsem is RWStructuredBufferRenderSemantic)
                            {
                                ccrs = rsem as RWStructuredBufferRenderSemantic;
                            }
                        }
                    }

                    if (FInReset[i])
                    {
                        if (ccrs != null)
                        {
                            int[] resetval = { FInResetCounterValue[i] };
                            var   uavarray = new UnorderedAccessView[1] {
                                ccrs.Data.UAV
                            };
                            context.CurrentDeviceContext.ComputeShader.SetUnorderedAccessViews(uavarray, 0, 1, resetval);
                        }
                    }
                }
                this.FLayerIn[0][context].Render(context, settings);
            }
        }
Exemplo n.º 26
0
 public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
 {
     if (this.FEnabled[0])
     {
         var rect = context.CurrentDeviceContext.Rasterizer.GetScissorRectangles();
         if (this.FLayerIn.IsConnected)
         {
             context.CurrentDeviceContext.Rasterizer.SetScissorRectangles(this.rectangles);
             try
             {
                 for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                 {
                     this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                 }
             }
             finally
             {
                 context.CurrentDeviceContext.Rasterizer.SetScissorRectangles(rect);
             }
         }
     }
     else
     {
         if (this.FLayerIn.IsConnected)
         {
             for (int i = 0; i < this.FLayerIn.SliceCount; i++)
             {
                 this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
             }
         }
     }
 }
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    var currentRef = context.CurrentDeviceContext.OutputMerger.BlendFactor;

                    context.CurrentDeviceContext.OutputMerger.BlendFactor = this.FInFactor[0];

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(context, settings);
                    }

                    context.CurrentDeviceContext.OutputMerger.BlendFactor = currentRef;
                }
            }
            else
            {
                for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                {
                    this.FLayerIn[i][context].Render(context, settings);
                }
            }
        }
        public void Render(DX11RenderContext context)
        {
            if (!this.FInLayer.IsConnected && this.AllowEmptyLayer == false)
            {
                return;
            }

            if (this.rendereddevices.Contains(context))
            {
                return;
            }

            if (!this.updateddevices.Contains(context))
            {
                this.Update(context);
            }

            if (this.FInEnabled[0])
            {
                DX11RenderSettings rs = this.settings[context];

                this.PreRender(context, rs);

                if (this.FInLayer.IsConnected)
                {
                    this.FInLayer.RenderAll(context, rs);
                }


                this.PostRender(context);
            }
        }
Exemplo n.º 29
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.SliceCount == 0) { return; }

            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    Matrix view = settings.View;
                    Matrix projection = settings.Projection;
                    Matrix vp = settings.ViewProjection;
                    bool depthonly = settings.DepthOnly;

                    this.UpdateSettings(settings);

                    for (int i = 0; i < this.FLayerIn.SliceCount;i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    settings.View = view;
                    settings.Projection = projection;
                    settings.ViewProjection = vp;
                    settings.DepthOnly = depthonly;
                }
            }
            else
            {
                for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                {
                    this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                }
            }
        }
Exemplo n.º 30
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                List <IDX11ObjectValidator> valids = new List <IDX11ObjectValidator>();
                if (this.FInVal.IsConnected)
                {
                    for (int i = 0; i < this.FInVal.SliceCount; i++)
                    {
                        if (this.FInVal[i].Enabled)
                        {
                            IDX11ObjectValidator v = this.FInVal[i];
                            //v.Reset();
                            v.SetGlobalSettings(settings);

                            valids.Add(v);
                            settings.ObjectValidators.Add(v);
                        }
                    }
                }

                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }

                foreach (IDX11ObjectValidator v in valids)
                {
                    settings.ObjectValidators.Remove(v);
                }
            }
        }
Exemplo n.º 31
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    bool popstate = false;

                    if (this.FInState.IsConnected)
                    {
                        context.RenderStateStack.Push(this.FInState[0]);
                        popstate = true;
                    }

                    this.FLayerIn.RenderAll(context, settings);

                    if (popstate)
                    {
                        context.RenderStateStack.Pop();
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    this.FLayerIn.RenderAll(context, settings);
                }
            }
        }
Exemplo n.º 32
0
 public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings)
 {
     Vector2 v = new Vector2(settings.RenderWidth, settings.RenderHeight);
     v.X = 1.0f / v.X;
     v.Y = 1.0f / v.Y;
     shaderinstance.SetByName(this.Name, v);
 }
Exemplo n.º 33
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                List<IDX11ObjectValidator> valids = new List<IDX11ObjectValidator>();
                if (this.FInVal.PluginIO.IsConnected)
                {
                    for (int i = 0; i < this.FInVal.SliceCount; i++)
                    {
                        if (this.FInVal[i].Enabled)
                        {
                            IDX11ObjectValidator v = this.FInVal[i];
                            //v.Reset();
                            v.SetGlobalSettings(settings);

                            valids.Add(v);
                            settings.ObjectValidators.Add(v);
                        }
                    }
                }

                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);
                }

                foreach (IDX11ObjectValidator v in valids)
                {
                    settings.ObjectValidators.Remove(v);
                }

            }
        }
Exemplo n.º 34
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                IDX11LayerOrder currentOrder = settings.LayerOrder;
                if (this.FInVal.IsConnected)
                {
                    settings.LayerOrder = this.FInVal[0];
                }

                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }

                settings.LayerOrder = currentOrder;
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 35
0
 public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings)
 {
     if (settings.ReadBuffer != null)
     {
         shaderinstance.SetByName(this.Name, settings.ReadBuffer.SRV);
     }
 }
Exemplo n.º 36
0
        private void RenderSlice(DX11RenderContext context, DX11RenderSettings settings, int i, bool viewportpop)
        {
            float cw = (float)this.ClientSize.Width;
            float ch = (float)this.ClientSize.Height;

            settings.ViewportIndex = i;
            settings.ApplyTransforms(this.FInView[i], this.FInProjection[i], this.FInAspect[i], this.FInCrop[i]);

            settings.BackBuffer   = this.FOutBackBuffer[0][context];
            settings.RenderWidth  = this.FOutBackBuffer[0][context].Resource.Description.Width;
            settings.RenderHeight = this.FOutBackBuffer[0][context].Resource.Description.Height;
            settings.ResourceSemantics.Clear();
            settings.CustomSemantics.Clear();

            if (viewportpop)
            {
                context.RenderTargetStack.PushViewport(this.FInViewPort[i].Normalize(cw, ch));
            }


            //Call render on all layers
            this.FInLayer.RenderAll(context, settings);

            if (viewportpop)
            {
                context.RenderTargetStack.Pop();
            }
        }
Exemplo n.º 37
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    Matrix view       = settings.View;
                    Matrix projection = settings.Projection;
                    Matrix vp         = settings.ViewProjection;
                    bool   depthonly  = settings.DepthOnly;

                    this.UpdateSettings(settings);

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    settings.View           = view;
                    settings.Projection     = projection;
                    settings.ViewProjection = vp;
                    settings.DepthOnly      = depthonly;
                }
            }
            else
            {
                this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);
            }
        }
Exemplo n.º 38
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;

            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    if (this.FInGeometry.IsConnected)
                    {
                        settings.Geometry = this.FInGeometry[0][context];
                    }

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(context, settings);
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(context, settings);
                    }
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 39
0
        public void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;

            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    if (this.FInGeometry.IsConnected)
                    {
                        settings.Geometry = this.FInGeometry[0][context];
                    }

                    this.FLayerIn.RenderAll(context, settings);
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    this.FLayerIn.RenderAll(context, settings);
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 40
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    List<IDX11RenderSemantic> semantics = new List<IDX11RenderSemantic>();
                    if (this.FInSemantics.PluginIO.IsConnected)
                    {
                        semantics.AddRange(this.FInSemantics);
                        settings.CustomSemantics.AddRange(semantics);
                    }

                    List<DX11Resource<IDX11RenderSemantic>> ressemantics = new List<DX11Resource<IDX11RenderSemantic>>();
                    if (this.FInResSemantics.PluginIO.IsConnected)
                    {
                        ressemantics.AddRange(this.FInResSemantics);
                        settings.ResourceSemantics.AddRange(ressemantics);
                    }

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    foreach (IDX11RenderSemantic semantic in semantics)
                    {
                        settings.CustomSemantics.Remove(semantic);
                    }

                    foreach (DX11Resource<IDX11RenderSemantic> rs in ressemantics)
                    {
                        settings.ResourceSemantics.Remove(rs);
                    }

                }
            }
        }
Exemplo n.º 41
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    bool popstate = false;

                    if (this.FInState.IsConnected)
                    {
                        context.RenderStateStack.Push(this.FInState[0]);
                        popstate = true;
                    }

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    if (popstate) { context.RenderStateStack.Pop(); }

                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 42
0
        private void ApplyOnly(DX11RenderContext context, DX11RenderSettings settings)
        {
            Device        device = context.Device;
            DeviceContext ctx    = context.CurrentDeviceContext;

            var            variableCache = this.shaderVariableCache[context];
            DX11ShaderData sdata         = this.deviceshaderdata[context];

            this.varmanager.SetGlobalSettings(sdata.ShaderInstance, settings);
            variableCache.ApplyGlobals(settings);

            DX11ObjectRenderSettings oset = new DX11ObjectRenderSettings();

            oset.DrawCallIndex  = 0;
            oset.Geometry       = null;
            oset.IterationCount = 1;
            oset.IterationIndex = 0;
            oset.WorldTransform = this.mworld[0 % this.mworldcount];
            variableCache.ApplySlice(oset, 0);
            sdata.ApplyPass(ctx);

            if (this.FInLayer.IsConnected)
            {
                this.FInLayer.RenderAll(context, settings);
            }
        }
Exemplo n.º 43
0
        protected override void UpdateSettings(DX11RenderSettings settings)
        {
            float f = this.FDoubleScale[0] ? 2.0f : 1.0f;

            settings.View           = Matrix.Identity;
            settings.Projection     = Matrix.Scaling(f / settings.RenderWidth, f / settings.RenderHeight, 1.0f) * FTransformIn[0];
            settings.ViewProjection = settings.Projection;
        }
Exemplo n.º 44
0
        public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings)
        {
            Vector2 v = new Vector2(settings.RenderWidth, settings.RenderHeight);

            v.X = 1.0f / v.X;
            v.Y = 1.0f / v.Y;
            shaderinstance.SetByName(this.Name, v);
        }
Exemplo n.º 45
0
        private Vector2 GetVector(DX11RenderSettings settings)
        {
            Vector2 v = new Vector2(settings.RenderWidth, settings.RenderHeight);

            v.X = 1.0f / v.X;
            v.Y = 1.0f / v.Y;
            return(v);
        }
Exemplo n.º 46
0
 public List<int> Reorder(DX11RenderSettings settings, List<DX11ObjectRenderSettings> objectSettings)
 {
     internalBuffer.Clear();
     for (int i = 0; i < FInIndex.SliceCount; i++)
     {
         internalBuffer.Add(FInIndex[i]);
     }
     return this.internalBuffer;
 }
Exemplo n.º 47
0
 public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
 {
     if (this.FLayerIn.IsConnected)
     {
         for (int i = 0; i < this.FLayerIn.SliceCount; i++)
         {
             this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
         }
     }
 }
Exemplo n.º 48
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0] && this.FInViewports.SliceCount > 0 && this.FNormalized.SliceCount > 0)
            {
                if (this.FLayerIn.IsConnected)
                {
                    bool enabled = this.FInViewports.PluginIO.IsConnected;

                    if (enabled)
                    {
                        var vp = this.FInViewports[settings.ViewportIndex];
                        if (FNormalized[settings.ViewportIndex])
                        {
                            vp = vp.Normalize(settings.RenderWidth, settings.RenderHeight);
                        }

                        context.CurrentDeviceContext.Rasterizer.SetViewports(vp);
                    }

                    Exception exp = null;
                    try
                    {
                        for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                        {
                            this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                        }
                    }
                    catch (Exception ex)
                    {
                        exp = ex;
                    }
                    finally
                    {
                        if (enabled)
                        {
                            context.RenderTargetStack.Apply();
                        }
                    }
                    if (exp != null)
                    {
                        throw exp;
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 49
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.PluginIO.IsConnected)
            {
                bool current = settings.ResetCounter;
                settings.ResetCounter = this.FInReset[0];

                this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                settings.ResetCounter = current;
            }
        }
Exemplo n.º 50
0
        protected override void UpdateSettings(DX11RenderSettings settings)
        {
            float w = settings.RenderWidth;
            float h = settings.RenderHeight;

            float sx, sy;

            #region Build scale
            if (FAlign[0].Name == "FitIn")
            {
                if (w > h)
                {
                    sx = h / w;
                    sy = 1.0f;
                }
                else
                {
                    sx = 1.0f;
                    sy = w / h;
                }
            }
            else if (FAlign[0].Name == "FitOut")
            {
                if (w > h)
                {
                    sx = 1.0f;
                    sy = w / h;
                }
                else
                {
                    sx = h / w;
                    sy = 1.0f;
                }
            }
            else if (FAlign[0].Name == "FitWidth")
            {
                sx = 1.0f;
                sy = w / h;
            }
            else //FitHeight
            {
                sy = 1.0f;
                sx = h / w;
            }
            #endregion

            Matrix aspect = Matrix.Scaling(sx* FScale[0], sy * FScale[0], 1.0f);

            settings.Projection = settings.Projection * aspect * FTransformIn[0];
            settings.ViewProjection = settings.View * settings.Projection;
        }
Exemplo n.º 51
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FLayerIn.IsConnected)
            {
                bool current = settings.ResetCounter;
                settings.ResetCounter = this.FInReset[0];

                for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                {
                    this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                }

                settings.ResetCounter = current;
            }
        }
Exemplo n.º 52
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    bool enabled = this.FInViewports.PluginIO.IsConnected;
                    if (enabled)
                    {
                        context.CurrentDeviceContext.Rasterizer.SetViewports(this.FInViewports.ToArray());
                    }

                    Exception exp = null;
                    try
                    {
                        for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                        {
                            this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                        }
                    }
                    catch (Exception ex)
                    {
                        exp = ex;
                    }
                    finally
                    {
                        if (enabled)
                        {
                            context.RenderTargetStack.Apply();
                        }
                    }
                    if (exp != null)
                    {
                        throw exp;
                    }
                }
            }
            else
            {
                if (this.FLayerIn.IsConnected)
                {
                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }
                }
            }
        }
Exemplo n.º 53
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            IDX11Geometry g = settings.Geometry;
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    if (this.FInGeometry.PluginIO.IsConnected)
                    {
                        settings.Geometry = this.FInGeometry[0][context];
                    }

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);
                }
            }
            settings.Geometry = g;
        }
Exemplo n.º 54
0
 public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj)
 {
     if (obj.Geometry != null)
     {
         if (obj.Geometry.HasBoundingBox)
         {
             shaderinstance.SetByName(this.Name,obj.Geometry.BoundingBox.Minimum);
         }
         else
         {
             shaderinstance.SetByName(this.Name, vec);
         }
     }
     else
     {
         shaderinstance.SetByName(this.Name, vec);
     }
 }
Exemplo n.º 55
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    var currentTag = settings.Tag;

                    settings.Tag = tag.SliceCount > 0 ? tag[0] : null;

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    settings.Tag = currentTag;

                }
            }
        }
Exemplo n.º 56
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.IsConnected)
                {
                    var currentRef = context.CurrentDeviceContext.OutputMerger.DepthStencilReference;

                    context.CurrentDeviceContext.OutputMerger.DepthStencilReference = this.FInReference[0];

                    for (int i = 0; i < this.FLayerIn.SliceCount; i++)
                    {
                        this.FLayerIn[i][context].Render(this.FLayerIn.PluginIO, context, settings);
                    }

                    context.CurrentDeviceContext.OutputMerger.DepthStencilReference = currentRef;

                }
            }
        }
Exemplo n.º 57
0
        public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.FEnabled[0])
            {
                if (this.FLayerIn.PluginIO.IsConnected)
                {
                    bool popstate = false;

                    if (this.FInState.PluginIO.IsConnected)
                    {
                        context.RenderStateStack.Push(this.FInState[0]);
                        popstate = true;
                    }

                    this.FLayerIn[0][context].Render(this.FLayerIn.PluginIO, context, settings);

                    if (popstate) { context.RenderStateStack.Pop(); }

                }
            }
        }
Exemplo n.º 58
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (!this.settings.ContainsKey(context))
            {
                DX11RenderSettings rs = new DX11RenderSettings();
                this.settings.Add(context, rs);

                this.OnUpdate(context, rs);
            }

            this.updateddevices.Add(context);
        }
Exemplo n.º 59
0
 protected virtual void PreRender(DX11RenderContext context, DX11RenderSettings settings)
 {
 }
Exemplo n.º 60
0
 protected abstract void OnUpdate(DX11RenderContext context, DX11RenderSettings settings);