本文整理汇总了C#中RenderHelper.DettachBindedTextures方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.DettachBindedTextures方法的具体用法?C# RenderHelper.DettachBindedTextures怎么用?C# RenderHelper.DettachBindedTextures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.DettachBindedTextures方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLights
public void DrawLights(GameTime gameTime, IWorld world, IDeferredGBuffer deferredGBuffer, RenderHelper render)
{
render.Clear(Color.Transparent, ClearOptions.Target);
foreach (ILight light in world.Lights.Where((a) => a.CastShadown == true && a.Enabled == true))
{
switch (light.LightType)
{
case LightType.Deferred_Directional:
DirectionalLightPE dl = light as DirectionalLightPE;
shadowMap = shadow.Render(gameTime, render, ginfo, dl, world.CameraManager.ActiveCamera, world, deferredGBuffer);
render.PushBlendState(_lightAddBlendState);
DrawDirectionalLight(render, ginfo, world.CameraManager.ActiveCamera, dl, deferredGBuffer);
render.PopBlendState();
break;
case LightType.Deferred_Point:
#if WINDOWS
System.Diagnostics.Debug.Fail("Point Light Shadow not supported, in production no error will be created, the light just wont cast any shadow");
#endif
render.PushBlendState(_lightAddBlendState);
DrawPointLight(render, ginfo, world.CameraManager.ActiveCamera, light as PointLightPE, deferredGBuffer, true);
render.PopBlendState();
break;
case LightType.Deferred_Spot:
SpotLightPE sl = light as SpotLightPE;
Matrix v = sl.ViewMatrix;
Matrix p =sl.ProjMatrix;
RenderShadowMap(gameTime, render, ref v, ref p, world, deferredGBuffer);
render.PushBlendState(_lightAddBlendState);
DrawnSpotLight(render, ginfo, world.CameraManager.ActiveCamera, sl, deferredGBuffer);
render.PopBlendState();
break;
default:
throw new Exception("Light type Unexpected");
}
}
render.DettachBindedTextures();
render.SetSamplerStates(ginfo.SamplerState);
render.PushBlendState(_lightAddBlendState);
foreach (ILight light in world.Lights.Where((a) => a.CastShadown != true && a.Enabled == true))
{
switch (light.LightType)
{
case LightType.Deferred_Directional:
DirectionalLightPE dl = light as DirectionalLightPE;
DrawDirectionalLight(render,ginfo, world.CameraManager.ActiveCamera, dl, deferredGBuffer);
break;
case LightType.Deferred_Point:
DrawPointLight(render,ginfo, world.CameraManager.ActiveCamera, light as PointLightPE, deferredGBuffer,true);
break;
case LightType.Deferred_Spot:
SpotLightPE sl = light as SpotLightPE;
DrawnSpotLight(render,ginfo, world.CameraManager.ActiveCamera, sl, deferredGBuffer);
break;
default:
throw new Exception("Light type Unexpected");
}
}
render.PopBlendState();
}
示例2: 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();
}
//.........这里部分代码省略.........
示例3: 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();
}
示例4: 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++)
//.........这里部分代码省略.........