本文整理汇总了C#中GraphicsDevice.CreateDepthStencilSurface方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.CreateDepthStencilSurface方法的具体用法?C# GraphicsDevice.CreateDepthStencilSurface怎么用?C# GraphicsDevice.CreateDepthStencilSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.CreateDepthStencilSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaterSurface
public WaterSurface(GraphicsDevice device, Camera camera, Vector3 normal, float position, int sizeX, int sizeY)
{
Vector3 x;
Device = device;
Camera = camera;
Normal = normal;
Position = position;
Plane = new Plane(normal, position);
NoiseMaker = new NoiseMaker(Device, GridSizeX, GridSizeY);
PlaneWithinFrustum = false;
// Set the initial water color
WaterColor = Color.Aquamarine;
// Calculate the U and V vectors
if (Math.Abs(Vector3.Dot(Vector3.UnitX, normal)) < Math.Abs(Vector3.Dot(Vector3.UnitY, normal)))
{
x = Vector3.UnitX;
}
else
{
x = Vector3.UnitY;
}
U = x - normal * Vector3.Dot(normal, x);
U = Vector3.Normalize(U);
// Get V (cross)
V = Vector3.Cross(U, normal);
GridSizeX = sizeX + 1;
GridSizeY = sizeY + 1;
SetDisplacementAmplitude(0);
if (!InitializeBuffers())
{
return;
}
// Load the textures
if ((Fresnel = Texture2D.FromFile(Device, "textures/fresnel_water_linear.bmp")) == null)
{
return;
}
if ((XYNoise = Texture2D.FromFile(Device, "textures/xynoise.png")) == null)
{
return;
}
// Initialize the reflection and refraction textures, and the depth stencil
Reflection = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget,
SurfaceFormat.Color, ResourcePool.Default);
Refraction = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget,
SurfaceFormat.Color, ResourcePool.Default);
DepthStencil = Device.CreateDepthStencilSurface(REFLREFRDETAIL, REFLREFRDETAIL, DepthFormat.Depth24Stencil8,
MultiSampleType.None, 0, true);
// Load the effect
CompiledEffect water = Effect.CompileEffectFromFile("shaders/watereffect.fx", null, null,
CompilerOptions.Debug | CompilerOptions.SkipOptimization, TargetPlatform.Windows);
if (!water.Success)
{
return;
}
else
{
WaterEffect = new Effect(Device, water.GetShaderCode(), CompilerOptions.None, null);
}
Initialized = true;
}