Пример #1
0
 protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext)
 {
     ShaderPass pass = MaterialVariables.GetPass(this, context);
     if (pass.IsNULL)
     { return; }
     pass.BindShader(deviceContext);
     pass.BindStates(deviceContext, DefaultStateBinding);
     if (!BindMaterialTextures(deviceContext, pass))
     {
         return;
     }
     if (context.RenderHost.IsShadowMapEnabled)
     {
         pass.PixelShader.BindTexture(deviceContext, shadowMapSlot, context.SharedResource.ShadowView);
     }
     DynamicReflector?.BindCubeMap(deviceContext);
     OnDraw(deviceContext, InstanceBuffer);
     DynamicReflector?.UnBindCubeMap(deviceContext);
     if (RenderWireframe && WireframePass != ShaderPass.NullPass)
     {
         if (RenderType == RenderType.Transparent && context.IsOITPass)
         {
             pass = WireframeOITPass;
         }
         else
         {
             pass = WireframePass;
         }
         pass.BindShader(deviceContext, false);
         pass.BindStates(deviceContext, DefaultStateBinding);
         deviceContext.SetRasterState(RasterStateWireframe);
         OnDraw(deviceContext, InstanceBuffer);
     }
 }
        protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext)
        {
            ShaderPass pass = MaterialVariables.GetPass(RenderType, context);

            if (pass.IsNULL)
            {
                return;
            }
            MaterialVariables.UpdateMaterialStruct(deviceContext, ref modelStruct);
            pass.BindShader(deviceContext);
            pass.BindStates(deviceContext, DefaultStateBinding);
            if (!materialVariables.BindMaterial(context, deviceContext, pass))
            {
                return;
            }

            DynamicReflector?.BindCubeMap(deviceContext);
            DrawIndexed(deviceContext, GeometryBuffer.IndexBuffer, InstanceBuffer);
            DynamicReflector?.UnBindCubeMap(deviceContext);
            if (RenderWireframe && !WireframePass.IsNULL)
            {
                if (RenderType == RenderType.Transparent && context.IsOITPass)
                {
                    pass = WireframeOITPass;
                }
                else
                {
                    pass = WireframePass;
                }
                pass.BindShader(deviceContext, false);
                pass.BindStates(deviceContext, DefaultStateBinding);
                deviceContext.SetRasterState(RasterStateWireframe);
                DrawIndexed(deviceContext, GeometryBuffer.IndexBuffer, InstanceBuffer);
            }
        }
Пример #3
0
            protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext)
            {
                var pass = MaterialVariables.GetPass(RenderType, context);

                if (pass.IsNULL)
                {
                    return;
                }
                OnUpdatePerModelStruct(context);
                if (!materialVariables.UpdateMaterialStruct(deviceContext, ref modelStruct))
                {
                    return;
                }
                pass.BindShader(deviceContext);
                pass.BindStates(deviceContext, DefaultStateBinding);
                if (!materialVariables.BindMaterialResources(context, deviceContext, pass))
                {
                    return;
                }

                DynamicReflector?.BindCubeMap(deviceContext);
                materialVariables.Draw(deviceContext, GeometryBuffer, InstanceBuffer.ElementCount);
                DynamicReflector?.UnBindCubeMap(deviceContext);

                if (RenderWireframe)
                {
                    pass = materialVariables.GetWireframePass(RenderType, context);
                    if (pass.IsNULL)
                    {
                        return;
                    }
                    pass.BindShader(deviceContext, false);
                    pass.BindStates(deviceContext, DefaultStateBinding);
                    deviceContext.SetRasterState(RasterStateWireframe);
                    materialVariables.Draw(deviceContext, GeometryBuffer, InstanceBuffer.ElementCount);
                }
            }