当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsDevice.SetVertexShaderConstantFloat4方法代码示例

本文整理汇总了C#中GraphicsDevice.SetVertexShaderConstantFloat4方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetVertexShaderConstantFloat4方法的具体用法?C# GraphicsDevice.SetVertexShaderConstantFloat4怎么用?C# GraphicsDevice.SetVertexShaderConstantFloat4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.SetVertexShaderConstantFloat4方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

      public override void Draw(GraphicsDevice gd, TimeSpan time, Camera camera)
      {
         if (!IsVisible)
         {
            return;
         }

         ccwState = new RasterizerState
                    {
                       CullMode = CullMode.CullCounterClockwiseFace,
                       FillMode = ShowWireframe ? FillMode.WireFrame : FillMode.Solid,
                    };

         
         gd.Textures[0] = sunTexture;
         gd.Textures[1] = turbulence1Texture;
         gd.Textures[2] = turbulence2Texture;
         gd.Textures[3] = gradientTexture;
         
         gd.SamplerStates[1] = SamplerState.AnisotropicWrap;
         gd.SamplerStates[2] = SamplerState.AnisotropicWrap;
         gd.SamplerStates[3] = SamplerState.LinearClamp;


         //
         // Pass 1, Sun map
         //
         var transform = Transform;
         transform = Matrix.CreateScale((float) Scale) * transform;
         shaderConstants.WorldMatrix = transform;
         shaderConstants.WorldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(transform));
         shaderConstants.WorldViewProjectionMatrix = transform * camera.ViewTransform * camera.ProjectionTransform;
         shaderConstants.ViewInverseMatrix = Matrix.Invert(camera.ViewTransform);
         shaderConstants.TotalSeconds.X = (float) time.TotalSeconds;
         shaderConstants.LightPos = new Vector4(LightPosition, 1);
         gd.SetVertexShaderConstantFloat4(0, ref shaderConstants);

         var showWireframe = new Vector4(ShowWireframe ? 1 : 0);
         gd.SetPixelShaderConstantFloat4(0, ref showWireframe);

         gd.SetVertexShader(sunVertexShader);
         gd.SetPixelShader(sunPixelShader);

         gd.DepthStencilState = depthState;
         gd.BlendState = BlendState.Opaque;
         gd.RasterizerState = ccwState;

         // Perform refraction mapping
         if(ReflectionTexture != null)
         {
            gd.Textures[0] = ReflectionTexture;
            gd.SetPixelShader(refractionPixelShader);
         }
         mesh.Draw(gd);
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:55,代码来源:Sun.cs

示例2: Draw

      public override void Draw(GraphicsDevice gd, TimeSpan time, Camera camera)
      {
         if(!IsVisible)
         {
            return;
         }

         cwState = new RasterizerState
         {
            CullMode = CullMode.CullClockwiseFace,
            FillMode = ShowWireframe ? FillMode.WireFrame : FillMode.Solid,
         };

         ccwState = new RasterizerState
         {
            CullMode = CullMode.CullCounterClockwiseFace,
            FillMode = ShowWireframe ? FillMode.WireFrame : FillMode.Solid,
         };

         // Pass 1 - Draw Earth

         // s0: DayTexture = EarthDay
         // s1: NightTexture = EarthNight
         // s2: NightLightsTexture = EarthNightLights
         // s3: NormalTexture = EarthNormal
         // s4: MaskTexture = EarthMask
         gd.Textures[0] = dayTexture;
         gd.Textures[1] = nightTexture;
         gd.Textures[2] = nightLightsTexture;
         gd.Textures[3] = normalTexture;
         gd.Textures[4] = maskTexture;

         var worldMatrix = Transform;
         worldMatrix = Matrix.CreateScale((float) Scale) * worldMatrix;
         earthConstants.WorldMatrix = worldMatrix;
         earthConstants.WorldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(worldMatrix));
         earthConstants.WorldViewProjectionMatrix = worldMatrix * camera.ViewTransform * camera.ProjectionTransform;
         earthConstants.ViewInverseMatrix = Matrix.Invert(camera.ViewTransform);
         earthConstants.TotalSeconds.X = (float)time.TotalSeconds;
         earthConstants.LightPos = new Vector4(LightPosition, 1);

         gd.SetVertexShaderConstantFloat4(0, ref earthConstants);

         var showWireframe = new Vector4(ShowWireframe ? 1.0f : 0.0f, 0f, 0f, 0f);
         gd.SetPixelShaderConstantFloat4(0, ref showWireframe);

         gd.SetVertexShader(earthVertexShader);
         gd.SetPixelShader(earthPixelShader);

         gd.DepthStencilState = depthState;
         gd.BlendState = BlendState.Opaque;
         gd.RasterizerState = ccwState;

         mesh.Draw(gd);

         if (AtmosphereVisible)
         {
            //
            // Pass 2 - Draw clouds
            //

            // s0: CloudTexture = EarthClouds
            gd.Textures[0] = cloudTexture;
            gd.SetVertexShader(atmosphereVertexShader);
            gd.SetPixelShader(cloudsPixelShader);
            gd.BlendState = cloudBlendState;

            mesh.Draw(gd);

            //
            // Pass 3 - Lower atmosphere
            //                

            // s0: AtmosphereTexture = EarthAtmosphere
            gd.Textures[0] = atmosphereTexture;
            gd.SetPixelShader(lowerAtmospherePixelShader);
            gd.BlendState = atmosphereBlendState;

            mesh.Draw(gd);

            //
            // Pass 4 - Upper atmosphere
            //
            gd.SetVertexShader(upperAtmosphereVertexShader);
            gd.SetPixelShader(upperAtmospherePixelShader);
            gd.RasterizerState = cwState;

            mesh.Draw(gd);
         }

         // Rotate and draw Moon
         var transform = Matrix.CreateTranslation(0, 0, 1f);
         transform *= Matrix.CreateRotationY((float)time.TotalSeconds * 0.05f);
         transform *= worldMatrix;
         Moon.Transform = transform;
         Moon.Draw(gd, time, camera);
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:97,代码来源:Earth.cs

示例3: Draw

      public override void Draw(GraphicsDevice gd, TimeSpan time, Camera camera)
      {
         if (!IsVisible)
         {
            return;
         }

         ccwState = new RasterizerState
         {
            CullMode = CullMode.CullCounterClockwiseFace,
            FillMode = ShowWireframe ? FillMode.WireFrame : FillMode.Solid,
         };

         // s0: DayTexture = Moon
         // s1: NormalTexture = MoonNormal
         gd.Textures[0] = moonTexture;
         gd.Textures[1] = moonNormalTexture;

         var transform = Transform;
         transform = Matrix.CreateScale((float) Scale) * transform;
         shaderConstants.WorldMatrix = transform;
         shaderConstants.WorldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(transform));
         shaderConstants.WorldViewProjectionMatrix = transform * camera.ViewTransform * camera.ProjectionTransform;
         shaderConstants.ViewInverseMatrix = Matrix.Invert(camera.ViewTransform);
         shaderConstants.TotalSeconds.X = (float)time.TotalSeconds;
         shaderConstants.LightPos = new Vector4(LightPosition, 1);

         gd.SetVertexShaderConstantFloat4(0, ref shaderConstants);

         var showWireframe = new Vector4(ShowWireframe ? 1 : 0);
         gd.SetPixelShaderConstantFloat4(0, ref showWireframe);

         gd.SetVertexShader(moonVertexShader);
         gd.SetPixelShader(moonPixelShader);

         gd.DepthStencilState = depthState;
         gd.BlendState = BlendState.Opaque;
         gd.RasterizerState = ccwState;

         mesh.Draw(gd);
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:41,代码来源:Moon.cs

示例4: Draw

        public void Draw(GraphicsDevice graphicsDevice, Matrix worldViewProjection)
        {
            graphicsDevice.SetVertexBuffer(vertexBuffer);
            graphicsDevice.SetVertexShader(ShaderCollection.DefaultVertexShader);
            graphicsDevice.SetVertexShaderConstantFloat4(0, ref worldViewProjection);

            if (!this.IsSelected)
            {
                graphicsDevice.SetPixelShader(ShaderCollection.TransparentSlicePixelShader);
            }
            else
            {
                graphicsDevice.SetPixelShader(ShaderCollection.SelectedSlicePixelShader);
            }

            graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicClamp;
            graphicsDevice.Textures[0] = Texture;

            graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
        }
开发者ID:palik,项目名称:OCTSegmentation,代码行数:20,代码来源:Image2D.cs


注:本文中的GraphicsDevice.SetVertexShaderConstantFloat4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。