Пример #1
0
            /// <summary>
            /// Called when [render].
            /// </summary>
            /// <param name="context">The context.</param>
            /// <param name="deviceContext">The device context.</param>
            protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext)
            {
                var shaderPass = materialVariables.GetPass(RenderType, context);

                if (shaderPass.IsNULL)
                {
                    return;
                }
                OnUpdatePerModelStruct();
                if (!materialVariables.UpdateMaterialStruct(deviceContext, ref modelStruct, PointLineModelStruct.SizeInBytes))
                {
                    return;
                }
                if (materialVariables.BindMaterialResources(context, deviceContext, shaderPass))
                {
                    shaderPass.BindShader(deviceContext);
                    shaderPass.BindStates(deviceContext, DefaultStateBinding);
                    materialVariables.Draw(deviceContext, GeometryBuffer, InstanceBuffer.ElementCount);
                }
            }
Пример #2
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);
                }
            }