本文整理汇总了C#中RenderHelper.ValidateSamplerStates方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.ValidateSamplerStates方法的具体用法?C# RenderHelper.ValidateSamplerStates怎么用?C# RenderHelper.ValidateSamplerStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.ValidateSamplerStates方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearGBuffer
public void ClearGBuffer(RenderHelper render)
{
render.ValidateSamplerStates();
render.PushDepthStencilState(DepthStencilState.None);
render.RenderFullScreenQuadVertexPixel(clearBufferEffect);
render.PopDepthStencilState();
render.ValidateSamplerStates();
}
示例2: DrawScene
public void DrawScene(GameTime gameTime, IWorld world, RenderHelper render, GraphicInfo ginfo, List<IObject> objectsToDraw)
{
render.ValidateSamplerStates();
Matrix view = world.CameraManager.ActiveCamera.View;
Matrix projection = world.CameraManager.ActiveCamera.Projection;
if (render.RenderPreComponents(gameTime, ref view, ref projection) > 0)
{
render.SetSamplerStates(ginfo.SamplerState);
}
System.Diagnostics.Debug.Assert(render.PeekBlendState() == BlendState.Opaque);
System.Diagnostics.Debug.Assert(render.PeekDepthState() == DepthStencilState.Default);
System.Diagnostics.Debug.Assert(render.PeekRasterizerState() == RasterizerState.CullCounterClockwise);
render.DettachBindedTextures(5);
foreach (IObject item in objectsToDraw)
{
if(item.Material.IsVisible)
item.Material.Drawn(gameTime,item, world.CameraManager.ActiveCamera, world.Lights, render);
}
render.ValidateSamplerStates();
}
示例3: PreDrawScene
public void PreDrawScene(GameTime gameTime, IWorld world, RenderHelper render, GraphicInfo ginfo, List<IObject> objectsToPreDraw)
{
render.ValidateSamplerStates();
foreach (IObject item in objectsToPreDraw)
{
if(item.Material.IsVisible)
item.Material.PreDrawnPhase(gameTime,world, item,world.CameraManager.ActiveCamera, world.Lights, render);
}
render.ValidateSamplerStates();
}
示例4: PreDrawPhase
public override void PreDrawPhase(GameTime gt, IWorld world, IObject obj, RenderHelper render, ICamera cam)
{
render.ValidateSamplerStates();
Matrix view = cam.View;
Matrix projection = cam.Projection;
//REFRACAO
Plane refractionClipPlane;
if (cam.Position.Y > -plane.D)
{
refractionClipPlane = CreateReflectionPlane(plane.D, ref plane.Normal, ref view, ref projection, true);
}
else
{
refractionClipPlane = CreateReflectionPlane(plane.D, ref plane.Normal, ref view, ref projection, false);
}
render.PushRenderTarget(refractionRT);
render.Clear(Color.Black);
render.RenderSceneReflectionRefration(world, gt, new List<IObject>() { obj }, ref view, ref projection, true, true,refractionClipPlane);
refractionMap = render.PopRenderTarget()[0].RenderTarget as Texture2D;
//REFLEXAO
Matrix m = Matrix.CreateReflection(plane);
Vector3 pos;
Vector3 target;
Vector3 up;
pos = Vector3.Transform(cam.Position, m);
target = Vector3.Transform(cam.Target, m);
up = Vector3.Transform(cam.Up, m);
reflectiveViewMatrix = Matrix.CreateLookAt(pos, target, up);
Plane reflectionClipPlane = CreateReflectionPlane(plane.D, ref plane.Normal, ref reflectiveViewMatrix, ref projection, false);
render.PushRenderTarget(reflectionRT);
render.Clear(Color.Black);
render.PushRasterizerState(RasterizerState.CullClockwise);
render.RenderSceneReflectionRefration(world, gt, new List<IObject>() { obj }, ref reflectiveViewMatrix, ref projection, true, true,reflectionClipPlane);
render.PopRasterizerState();
reflectionMap = render.PopRenderTarget()[0].RenderTarget as Texture2D;
}
示例5: Draw
/// <summary>
/// Draws the specified game time.
/// </summary>
/// <param name="gameTime">The game time.</param>
/// <param name="world">The world.</param>
/// <param name="render">The render.</param>
protected void Draw(GameTime gameTime, IWorld world, RenderHelper render)
{
Matrix view = world.CameraManager.ActiveCamera.View;
Matrix projection = world.CameraManager.ActiveCamera.Projection;
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);
if (desc.OrderAllObjectsBeforeDraw != null)
AllnotCulledObjectsList = desc.OrderAllObjectsBeforeDraw(AllnotCulledObjectsList);
if (desc.OrderDeferredObjectsBeforeDraw != null)
DeferrednotCulledObjectsList = desc.OrderDeferredObjectsBeforeDraw(DeferrednotCulledObjectsList);
if (desc.OrderForwardObjectsBeforeDraw != null)
ForwardnotCulledObjectsList = desc.OrderForwardObjectsBeforeDraw(ForwardnotCulledObjectsList);
render.SetSamplerStates(ginfo.SamplerState);
render.DettachBindedTextures();
deferredGBuffer.PreDrawScene(gameTime, world, render, ginfo, AllnotCulledObjectsList);
render.SetSamplerStates(ginfo.SamplerState);
render.DettachBindedTextures();
deferredGBuffer.SetGBuffer(render);
deferredGBuffer.ClearGBuffer(render);
deferredGBuffer.DrawScene(gameTime, world, render, ginfo, DeferrednotCulledObjectsList);
deferredGBuffer.ResolveGBuffer(render);
render[PrincipalConstants.DephRT] = deferredGBuffer[GBufferTypes.DEPH];
render[PrincipalConstants.normalRt] = deferredGBuffer[GBufferTypes.NORMAL];
render.DettachBindedTextures();
render.ValidateSamplerStates();
deferredLightMap.SetLightMap(render);
deferredLightMap.DrawLights(gameTime, world, deferredGBuffer, render);
deferredLightMap.ResolveLightMap(render);
render[PrincipalConstants.lightRt] = deferredLightMap[DeferredLightMapType.LIGHTMAP];
render.DettachBindedTextures(5);
render.ValidateSamplerStates();
render.PushRenderTarget(scenerender);
render.Clear(desc.BackGroundColor);
foreach (IObject item in AllnotCulledObjectsList)
{
if (item.Material.IsVisible)
item.Material.PosDrawnPhase(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
}
render.DettachBindedTextures(3);
render.ValidateSamplerStates();
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();
render.SetSamplerStates(ginfo.SamplerState);
}
render.DettachBindedTextures(6);
render.ValidateSamplerStates();
render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);
render.DettachBindedTextures(6);
render.ValidateSamplerStates();
render[PrincipalConstants.colorRT] = scenerender;
render[PrincipalConstants.normalRt] = deferredGBuffer[GBufferTypes.NORMAL];
render[PrincipalConstants.lightRt] = deferredLightMap[DeferredLightMapType.LIGHTMAP];
render[PrincipalConstants.DephRT] = deferredGBuffer[GBufferTypes.DEPH];
render[PrincipalConstants.extra1RT] = deferredGBuffer[GBufferTypes.Extra1];
render[PrincipalConstants.CurrentImage] = render[PrincipalConstants.CombinedImage] = 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;
render[PrincipalConstants.CurrentImage] = tex;
SwapTargetBuffers();
}
//.........这里部分代码省略.........
示例6: Draw
/// <summary>
/// Draws the specified game time.
/// </summary>
/// <param name="gameTime">The game time.</param>
/// <param name="world">The world.</param>
/// <param name="render">The render.</param>
protected void Draw(GameTime gameTime, IWorld world, RenderHelper render)
{
Matrix view = world.CameraManager.ActiveCamera.View;
Matrix projection = world.CameraManager.ActiveCamera.Projection;
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, CullerComparer.ComparerFrontToBack,world.CameraManager.ActiveCamera.Position);
List<IObject> ForwardnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.FORWARD, CullerComparer.ComparerBackToFront, world.CameraManager.ActiveCamera.Position);
if (desc.OrderAllObjectsBeforeDraw != null)
AllnotCulledObjectsList = desc.OrderAllObjectsBeforeDraw(AllnotCulledObjectsList,world);
if (desc.OrderDeferredObjectsBeforeDraw != null)
DeferrednotCulledObjectsList = desc.OrderDeferredObjectsBeforeDraw(DeferrednotCulledObjectsList, world);
if (desc.OrderForwardObjectsBeforeDraw != null)
ForwardnotCulledObjectsList = desc.OrderForwardObjectsBeforeDraw(ForwardnotCulledObjectsList, world);
render.SetSamplerStates(ginfo.SamplerState);
render.DettachBindedTextures();
deferredGBuffer.PreDrawScene(gameTime, world, render, ginfo, AllnotCulledObjectsList);
render.SetSamplerStates(ginfo.SamplerState);
render.DettachBindedTextures();
deferredGBuffer.SetGBuffer(render);
deferredGBuffer.ClearGBuffer(render);
deferredGBuffer.DrawScene(gameTime, world, render, ginfo, DeferrednotCulledObjectsList);
deferredGBuffer.ResolveGBuffer(render);
render.DettachBindedTextures();
render.ValidateSamplerStates();
deferredLightMap.SetLightMap(render);
deferredLightMap.DrawLights(gameTime, world, deferredGBuffer, render);
deferredLightMap.ResolveLightMap(render);
render.DettachBindedTextures(5);
render.ValidateSamplerStates();
deferredFinalCombination.SetFinalCombination(render);
deferredFinalCombination.DrawScene(gameTime, world, deferredGBuffer, deferredLightMap,render);
render.DettachBindedTextures(3);
render.ValidateSamplerStates();
if (desc.ExtraForwardPass)
{
render[PrincipalConstants.colorRT] = deferredGBuffer[GBufferTypes.COLOR];
render[PrincipalConstants.normalRt] = deferredGBuffer[GBufferTypes.NORMAL];
render[PrincipalConstants.lightRt] = deferredLightMap[DeferredLightMapType.LIGHTMAP];
render[PrincipalConstants.DephRT] = deferredGBuffer[GBufferTypes.DEPH];
render[PrincipalConstants.extra1RT] = deferredGBuffer[GBufferTypes.Extra1];
render[PrincipalConstants.CombinedImage] = deferredFinalCombination[GBufferTypes.FINALIMAGE];
render[PrincipalConstants.CurrentImage] = deferredFinalCombination[GBufferTypes.FINALIMAGE];
if (desc.RestoreDepthOption == RestoreDepthOption.BEFORE_POSTEFFECT)
{
restoreDepth.PerformForwardPass(render[PrincipalConstants.CombinedImage], render[PrincipalConstants.DephRT], render,ginfo);
render.DettachBindedTextures(2);
render.ValidateSamplerStates();
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();
render.SetSamplerStates(ginfo.SamplerState);
}
render.DettachBindedTextures(6);
render.ValidateSamplerStates();
forwardPass.Draw(gameTime, world, render,DeferrednotCulledObjectsList,ForwardnotCulledObjectsList);
render.DettachBindedTextures(6);
render.ValidateSamplerStates();
render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);
render.DettachBindedTextures(6);
render.ValidateSamplerStates();
render[PrincipalConstants.CurrentImage] = restoreDepth.EndForwardPass(render);
render[PrincipalConstants.CombinedImage] = render[PrincipalConstants.CurrentImage];
for (int i = 0; i < PostEffects.Count; i++)
//.........这里部分代码省略.........