本文整理汇总了C#中RenderHelper.PushDepthStencilState方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.PushDepthStencilState方法的具体用法?C# RenderHelper.PushDepthStencilState怎么用?C# RenderHelper.PushDepthStencilState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.PushDepthStencilState方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearGBuffer
public void ClearGBuffer(RenderHelper render)
{
render.PushDepthStencilState(DepthStencilState.None);
clearBufferEffect.Parameters["BackColor"].SetValue(backGroundColor.ToVector3());
render.RenderFullScreenQuadVertexPixel(clearBufferEffect);
render.PopDepthStencilState();
}
示例2: ClearGBuffer
public void ClearGBuffer(RenderHelper render)
{
render.ValidateSamplerStates();
render.PushDepthStencilState(DepthStencilState.None);
render.RenderFullScreenQuadVertexPixel(clearBufferEffect);
render.PopDepthStencilState();
render.ValidateSamplerStates();
}
示例3: Draw
public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
{
rHelper.PushRenderTarget(target);
rHelper.Clear(Color.Black);
effectdistorcion.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
effectdistorcion.Parameters["DEPTH"].SetValue(rHelper[PrincipalConstants.DephRT]);
effectdistorcion.Parameters["DistortionScale"].SetValue(Distortion);
rHelper.PushDepthStencilState(DepthStencilState.None);
foreach (var obj in objs)
{
IModelo modelo = obj.Modelo;
for (int i = 0; i < modelo.MeshNumber; i++)
{
BatchInformation[] bi = modelo.GetBatchInformation(i);
for (int j = 0; j < bi.Count(); j++)
{
Matrix w = bi[j].ModelLocalTransformation * obj.WorldMatrix;
effectdistorcion.Parameters["WorldViewProjection"].SetValue(w * world.CameraManager.ActiveCamera.View * world.CameraManager.ActiveCamera.Projection);
effectdistorcion.Parameters["WorldView"].SetValue(w * world.CameraManager.ActiveCamera.View);
rHelper.RenderBatch(bi[j], effectdistorcion);
}
}
}
rHelper.PopDepthStencilState();
x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
rHelper.Clear(Color.Black);
effect.Parameters["SceneTexture"].SetValue(ImageToProcess);
effect.Parameters["DistortionMap"].SetValue(x);
//effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess,effect,GraphicInfo.FullScreenRectangle);
}
示例4: DrawDirectionalLight
private void DrawDirectionalLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, DirectionalLightPE dl, IDeferredGBuffer DeferredGBuffer)
{
directionalLightEffect.Parameters["shadowBufferSize"].SetValue(shadownBufferSize);
if(dl.CastShadown)
//directionalLightEffect.Parameters["xShadowMap"].SetValue(shadowMap);
render.device.Textures[3] = shadowMap;
else
//directionalLightEffect.Parameters["xShadowMap"].SetValue(blank);
render.device.Textures[3] = blank;
//directionalLightEffect.Parameters["colorMap"].SetValue(DeferredGBuffer[GBufferTypes.COLOR]);
//directionalLightEffect.Parameters["normalMap"].SetValue(DeferredGBuffer[GBufferTypes.NORMAL]);
//directionalLightEffect.Parameters["depthMap"].SetValue(DeferredGBuffer[GBufferTypes.DEPH]);
render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);
SamplerState s3 = render.SetSamplerState(SamplerState.PointClamp, 3);
directionalLightEffect.Parameters["View"].SetValue(camera.View);
directionalLightEffect.Parameters["Projection"].SetValue(camera.Projection);
directionalLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
directionalLightEffect.Parameters["shadown"].SetValue(dl.CastShadown);
directionalLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));
directionalLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
directionalLightEffect.Parameters["lightDirection"].SetValue(dl.LightDirection);
directionalLightEffect.Parameters["Color"].SetValue(dl.Color.ToVector3());
directionalLightEffect.Parameters["lightIntensity"].SetValue(dl.LightIntensity);
render.PushDepthStencilState(DepthStencilState.None);
render.RenderFullScreenQuadVertexPixel(directionalLightEffect);
render.PopDepthStencilState();
render.SetSamplerState(s2, 2);
render.SetSamplerState(s3, 3);
}
示例5: DrawnSpotLight
private void DrawnSpotLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, SpotLightPE sl, IDeferredGBuffer DeferredGBuffer)
{
//if(sl.CastShadown)
// spotLightEffect.Parameters["xShadowMap"].SetValue(shadowMap);
//else
// spotLightEffect.Parameters["xShadowMap"].SetValue(blank);
if (sl.CastShadown)
render.device.Textures[3] = shadowMap;
else
render.device.Textures[3] = blank;
spotLightEffect.Parameters["shadowBufferSize"].SetValue(shadownBufferSize);
spotLightEffect.Parameters["BIAS"].SetValue(sl.SHADOWBIAS);
//spotLightEffect.Parameters["colorMap"].SetValue(DeferredGBuffer[GBufferTypes.COLOR]);
//spotLightEffect.Parameters["normalMap"].SetValue(DeferredGBuffer[GBufferTypes.NORMAL]);
//spotLightEffect.Parameters["depthMap"].SetValue(DeferredGBuffer[GBufferTypes.DEPH]);
render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);
SamplerState s3 = render.SetSamplerState(SamplerState.PointClamp, 3);
spotLightEffect.Parameters["xLightViewProjection"].SetValue(sl.ViewMatrix * sl.ProjMatrix);
spotLightEffect.Parameters["View"].SetValue(camera.View);
spotLightEffect.Parameters["Projection"].SetValue(camera.Projection);
spotLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
spotLightEffect.Parameters["shadown"].SetValue(sl.CastShadown);
spotLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));
spotLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
spotLightEffect.Parameters["lightPosition"].SetValue(sl.Position);
spotLightEffect.Parameters["lightDirection"].SetValue(sl.Direction);
spotLightEffect.Parameters["lightRadius"].SetValue(sl.LightRadius);
spotLightEffect.Parameters["lightDecayExponent"].SetValue(sl.ConeDecay);
spotLightEffect.Parameters["Color"].SetValue(sl.Color.ToVector3());
spotLightEffect.Parameters["lightAngleCosine"].SetValue(sl.LightAngleCosine);
spotLightEffect.Parameters["lightIntensity"].SetValue(sl.LightIntensity);
render.PushDepthStencilState(DepthStencilState.None);
render.RenderFullScreenQuadVertexPixel(spotLightEffect);
render.PopDepthStencilState();
render.SetSamplerState(s2, 2);
render.SetSamplerState(s3, 3);
}
示例6: DrawScene
public void DrawScene(GameTime gameTime, IWorld world, IDeferredGBuffer gbuffer, IDeferredLightMap lightmap, RenderHelper render)
{
render.PushDepthStencilState(DepthStencilState.None);
PambientColor.SetValue(ambientColor.ToVector3());
render.device.Textures[0] = lightmap[DeferredLightMapType.LIGHTMAP];
SamplerState s0 = render.SetSamplerState(SamplerState.PointClamp, 0);
render.device.Textures[1] = gbuffer[GBufferTypes.Extra1];
render.device.Textures[2] = gbuffer[GBufferTypes.COLOR];
//PEXTRA1.SetValue(gbuffer[GBufferTypes.Extra1]);
//PcolorMap.SetValue(gbuffer[GBufferTypes.COLOR]);
//PlightMap.SetValue(lightmap[DeferredLightMapType.LIGHTMAP]);
render.RenderFullScreenQuadVertexPixel(finalCombineEffect);
render.SetSamplerState(s0, 0);
if (saveToTexture)
{
render.PopRenderTarget();
}
render.PopDepthStencilState();
}
示例7: PreDraw
protected override void PreDraw(RenderHelper render, GameTime gt, ref Matrix activeView, ref Matrix activeProjection)
{
if (!enable || Cube == null)
return;
Matrix viewIT = Matrix.Invert(Matrix.Transpose(activeView));
Vector3 position = new Vector3(viewIT.M14, viewIT.M24, viewIT.M34);
this.Position = position + PositionOffset;
Effect.View = activeView;
Effect.Projection = activeProjection;
Effect.World = Matrix.CreateTranslation(this.Position);
render.PushDepthStencilState(new DepthStencilState() { DepthBufferEnable = false });
render.PushRasterizerState(new RasterizerState() { CullMode = CullMode.None });
var graphics = Effect.GraphicsDevice;
graphics.SetVertexBuffer(VertexBuffer);
graphics.Indices = IndexBuffer;
Effect.Texture = CubeFaces[0];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 0, 2);
Effect.Texture = CubeFaces[1];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 6, 2);
Effect.Texture = CubeFaces[2];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 12, 2);
Effect.Texture = CubeFaces[3];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 18, 2);
Effect.Texture = CubeFaces[4];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 24, 2);
Effect.Texture = CubeFaces[5];
Effect.CurrentTechnique.Passes[0].Apply();
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertices.Count, 30, 2);
render.PopDepthStencilState();
render.PopRasterizerState();
}
示例8: DrawLights
public void DrawLights(GameTime gameTime, IWorld world, IDeferredGBuffer deferredGBuffer, RenderHelper render)
{
render.Clear(Color.Black,ClearOptions.Target);
render.PushBlendState(_lightAddBlendState);
render.PushDepthStencilState(DepthStencilState.None);
DrawDirectionalLight(world.CameraManager.ActiveCamera, world.Lights, deferredGBuffer,render);
DrawPointLight(world.CameraManager.ActiveCamera, world.Lights, deferredGBuffer,render);
DrawnSpotLight(world.CameraManager.ActiveCamera, world.Lights, deferredGBuffer,render);
render.PopBlendState();
render.PopDepthStencilState();
}
示例9: DrawnSpotLight
protected void DrawnSpotLight(ICamera camera, IList<ILight> lights, IDeferredGBuffer DeferredGBuffer,RenderHelper render)
{
render.PushRasterizerState(RasterizerState.CullNone);
render.PushDepthStencilState(DepthStencilState.None);
render.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
render.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);
spotLightEffect.Parameters["View"].SetValue(camera.View);
spotLightEffect.Parameters["Projection"].SetValue(camera.Projection);
spotLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
ApplyFrustumCorners(directionalLightEffect.Parameters["FrustumCorners"], -Vector2.One, Vector2.One);
foreach (ILight item in lights)
{
if (item.LightType == LightType.Deferred_Spot && item.Enabled == true)
{
SpotLightPE sl = item as SpotLightPE;
Vector3 viewSpaceLPos = Vector3.Transform(sl.Position, camera.View);
Vector3 viewSpaceLDir = Vector3.Transform(sl.Direction, camera.View);
spotLightEffect.Parameters["lightPosition"].SetValue(viewSpaceLPos);
spotLightEffect.Parameters["lightDirection"].SetValue(viewSpaceLDir);
spotLightEffect.Parameters["lightRadius"].SetValue(sl.LightRadius);
spotLightEffect.Parameters["lightDecayExponent"].SetValue(sl.ConeDecay);
spotLightEffect.Parameters["Color"].SetValue(sl.Color.ToVector3());
spotLightEffect.Parameters["lightAngleCosine"].SetValue(sl.LightAngleCosine);
spotLightEffect.Parameters["lightIntensity"].SetValue(sl.LightIntensity);
render.RenderFullScreenQuadVertexPixel(spotLightEffect);
}
}
render.PopDepthStencilState();
render.PopRasterizerState();
render.SetSamplerState(s2, 2);
}
示例10: ExecuteTechnic
protected override void ExecuteTechnic(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render, IWorld world)
{
ICamera camera = world.CameraManager.ActiveCamera;
Matrix view = world.CameraManager.ActiveCamera.View;
Matrix projection = world.CameraManager.ActiveCamera.Projection;
ComputeFrustumCorners(camera);
world.Culler.StartFrame(ref view, ref projection, world.CameraManager.ActiveCamera.BoundingFrustum);
List<IObject> AllnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(null);
List<IObject> DeferrednotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.DEFERRED);
List<IObject> ForwardnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.FORWARD);
foreach (IObject item in AllnotCulledObjectsList)
{
if (item.Material.IsVisible)
item.Material.PreDrawnPhase(gameTime, world, item, world.CameraManager.ActiveCamera, world.Lights, render);
}
render.PushRenderTargetBinding(_gBufferBinding);
render.Clear(Color.Black,ClearOptions.DepthBuffer | ClearOptions.Stencil, 1.0f, 0);
render.PushDepthStencilState(DepthStencilState.None);
render.PushRasterizerState(RasterizerState.CullNone);
render.RenderFullScreenQuadVertexPixel(_clearGBuffer);
render.PopDepthStencilState();
render.PopRasterizerState();
foreach (IObject item in DeferrednotCulledObjectsList)
{
if (item.Material.IsVisible)
item.Material.Drawn(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
}
render.PopRenderTarget();
render[PrincipalConstants.DephRT] = _depthBuffer;
render[PrincipalConstants.normalRt] = _normalBuffer;
//render.PushRenderTargetBinding(_lightAccumBinding);
render.Clear(new Color(0, 0, 0, 0));
render.PushDepthStencilState(DepthStencilState.None);
//draw using additive blending.
//At first I was using BlendState.additive, but it seems to use alpha channel for modulation,
//and as we use alpha channel as the specular intensity, we have to create our own blend state here
render.PushBlendState(_lightAddBlendState);
RenderLights(camera,world,render,ginfo);
//render[PrincipalConstants.lightRt] = render.PopRenderTarget()[0].RenderTarget as Texture2D;
render.PopDepthStencilState();
render.PopBlendState();
return;
render.PushRenderTarget(_outputTexture);
render.Clear(Color.Black);
foreach (IObject item in AllnotCulledObjectsList)
{
if (item.Material.IsVisible)
item.Material.PosDrawnPhase(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
}
if (world.PhysicWorld.isDebugDraw)
{
//world.PhysicWorld.iDebugDrawn(render, gameTime, world.CameraManager.ActiveCamera);
}
if (world.ParticleManager != null)
{
//world.ParticleManager.iDraw(gameTime, world.CameraManager.ActiveCamera.View, world.CameraManager.ActiveCamera.Projection, render);
//render.ResyncStates();
}
ForwardPass.Draw(gameTime, world, render, DeferrednotCulledObjectsList, ForwardnotCulledObjectsList);
render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);
render[PrincipalConstants.CurrentImage] = render.PopRenderTargetAsSingleRenderTarget2D();
for (int i = 0; i < PostEffects.Count; i++)
{
if (PostEffects[i].Enabled)
{
render.PushRenderTarget(PostEffectTarget);
render.Clear(Color.Black);
PostEffects[i].Draw(render[PrincipalConstants.CurrentImage], render, gameTime, ginfo, world, true);
Texture2D tex = render.PopRenderTarget()[0].RenderTarget as Texture2D;
System.Diagnostics.Debug.Assert(tex != null);
render[PrincipalConstants.CurrentImage] = tex;
SwapTargetBuffers();
}
}
render.Clear(Color.Black);
render.RenderTextureComplete(render[PrincipalConstants.CurrentImage], Color.White, ginfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.PointClamp);
render.RenderPosComponents(gameTime, ref view, ref projection);
//.........这里部分代码省略.........
示例11: iDraw
/// <summary>
/// Draw
/// </summary>
/// <param name="gt">The gt.</param>
/// <param name="obj">The obj.</param>
/// <param name="render">The render.</param>
/// <param name="cam">The cam.</param>
/// <param name="lights">The lights.</param>
public void iDraw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<ILight> lights)
{
if (OcclusionQuery != null)
{
while (OcclusionQuery.Tag == null && OcclusionQuery.IsComplete == false) { }
if ( (OcclusionQuery.Tag == null && OcclusionQuery.PixelCount > 0) || obj.PhysicObject.BoundingBox == null)
{
PixelsRendered = OcclusionQuery.PixelCount;
//Enable rendering to screen.
//Enable or disable writing to depth buffer (depends on whether the object is translucent or opaque).
//Render the object itself.
OcclusionQuery.Begin();
this.Draw(gt, obj, render, cam, lights);
OcclusionQuery.End();
}
else
{
//Disable rendering to screen.
//Disable writing to depth buffer.
//"Render" the object's bounding box.
PixelsRendered = 0;
OcclusionQuery.Begin();
render.PushBlendState(BlendState);
render.PushDepthStencilState(DepthStencilState.DepthRead);
BoundingBox BoundingBox = obj.PhysicObject.BoundingBox.Value;
BasicEffect.View = cam.View;
BasicEffect.Projection = cam.Projection;
Vector3 centerPos = obj.PhysicObject.Position;
Vector3 scale = BoundingBox.Max - BoundingBox.Min;
Matrix world = Matrix.CreateScale(scale);
world.Translation = centerPos;
BasicEffect.World = world;
render.RenderBatch(Modelo.GetBatchInformation(0)[0], BasicEffect);
OcclusionQuery.End();
render.PopDepthStencilState();
render.PopBlendState();
OcclusionQuery.Tag = null;
}
}
else
{
PixelsRendered = 0;
this.Draw(gt, obj, render, cam, lights);
}
}