本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}