Пример #1
0
        protected unsafe sealed override void RecordCommandsInternal(MyRenderableProxy proxy)
        {
            if (proxy.Material.Info.GeometryTextureRef.IsUsed)
            {
                MyRenderProxy.Fail(String.Format("Ensure all glass materials for model '{0}' are dynamic materials inside Environment.sbc", proxy.Mesh.Info.Name));
                return;
            }

            MyTransparentMaterial material;

            if (!MyTransparentMaterials.TryGetMaterial(proxy.Material.Info.Name.String, out material))
            {
                MyRenderProxy.Fail(String.Format("Missing transparent material '{0}'", proxy.Material.Info.Name));
                return;
            }

            Stats.Draws++;

            MyRenderUtils.BindShaderBundle(RC, proxy.Shaders);

            SetProxyConstants(proxy);
            BindProxyGeometry(proxy, RC);

            ISrvBindable texture = MyManagers.FileTextures.GetTexture(material.Texture, MyFileTextureEnum.GUI, true);

            RC.PixelShader.SetSrv(0, texture);

            StaticGlassConstants glassConstants = new StaticGlassConstants();

            var glassCB = MyCommon.GetObjectCB(sizeof(StaticGlassConstants));

            RC.PixelShader.SetConstantBuffer(2, glassCB);
            var mapping = MyMapping.MapDiscard(glassCB);

            glassConstants.Color      = material.Color;
            glassConstants.Reflective = material.Reflectivity;
            mapping.WriteAndPosition(ref glassConstants);

            mapping.Unmap();

            var submesh = proxy.DrawSubmesh;

            if (proxy.InstanceCount == 0)
            {
                RC.DrawIndexed(submesh.IndexCount, submesh.StartIndex, submesh.BaseVertex);
                ++Stats.Instances;
                Stats.Triangles += submesh.IndexCount / 3;
            }
            else
            {
                RC.DrawIndexedInstanced(submesh.IndexCount, proxy.InstanceCount, submesh.StartIndex, submesh.BaseVertex, proxy.StartInstance);
                Stats.Instances += proxy.InstanceCount;
                Stats.Triangles += proxy.InstanceCount * submesh.IndexCount / 3;
            }
        }
Пример #2
0
        protected unsafe sealed override void RecordCommandsInternal(MyRenderableProxy proxy)
        {
            if (proxy.Material.Info.GeometryTextureRef.IsUsed)
            {
                MyRenderProxy.Fail(String.Format("Ensure all glass materials for model '{0}' are dynamic materials inside Environment.sbc", proxy.Mesh.Info.Name));
                return;
            }

            MyTransparentMaterial material;
            if (!MyTransparentMaterials.TryGetMaterial(proxy.Material.Info.Name.String, out material))
            {
                MyRenderProxy.Fail(String.Format("Missing transparent material '{0}'", proxy.Material.Info.Name));
                return;
            }

            Stats.Draws++;

            MyRenderUtils.BindShaderBundle(RC, proxy.Shaders);

            SetProxyConstants(proxy);
            BindProxyGeometry(proxy, RC);

            ISrvBindable texture = MyManagers.FileTextures.GetTexture(material.Texture, MyFileTextureEnum.GUI, true);
            RC.PixelShader.SetSrv(0, texture);
            
            StaticGlassConstants glassConstants = new StaticGlassConstants();

            var glassCB = MyCommon.GetObjectCB(sizeof(StaticGlassConstants));
            RC.PixelShader.SetConstantBuffer(2, glassCB);
            var mapping = MyMapping.MapDiscard(glassCB);

            glassConstants.Color = material.Color;
            glassConstants.Reflective = material.Reflectivity;
            mapping.WriteAndPosition(ref glassConstants);

            mapping.Unmap();

            var submesh = proxy.DrawSubmesh;

            RC.DrawIndexed(submesh.IndexCount, submesh.StartIndex, submesh.BaseVertex);
            ++Stats.Instances;
        }