本文整理汇总了C#中RenderHelper.PushBlendState方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.PushBlendState方法的具体用法?C# RenderHelper.PushBlendState怎么用?C# RenderHelper.PushBlendState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.PushBlendState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: PosDrawPhase
public override void PosDrawPhase(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<ILight> lights)
{
render.PushRasterizerState(cullMode);
render.PushBlendState(BlendState.NonPremultiplied);
for (int i = 0; i < obj.Modelo.MeshNumber; i++)
{
BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
for (int j = 0; j < bi.Count(); j++)
{
_shader.Parameters["colorMap"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,i,j));
Matrix w1 = Matrix.Multiply(obj.WorldMatrix, bi[j].ModelLocalTransformation);
_shader.Parameters["wvp"].SetValue(w1 * cam.ViewProjection);
_shader.Parameters["alpha"].SetValue(transparencyLevel);
_shader.Parameters["useTextureAlpha"].SetValue(useTextureAlpha);
render.RenderBatch(bi[j], _shader);
}
}
render.PopBlendState();
render.PopRasterizerState();
}
示例3: 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();
}
示例4: 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);
//.........这里部分代码省略.........
示例5: BasicDraw
/// <summary>
/// Draw the object in a simple way (WITH MINIMUM EFFECTS,....)
/// USED IN RELECTIONS, REFRACTION .....
/// </summary>
/// <param name="gt">The gt.</param>
/// <param name="obj">The obj.</param>
/// <param name="view">The view.</param>
/// <param name="projection">The projection.</param>
/// <param name="lights">The lights.</param>
/// <param name="render">The render.</param>
/// <param name="clippingPlane">The clipping plane.</param>
/// <param name="useAlphaBlending">if set to <c>true</c> [use alpha blending].</param>
public virtual void BasicDraw(GameTime gt, IObject obj, ref Matrix view, ref Matrix projection, IList<ILight> lights, RenderHelper render,Plane? clippingPlane, bool useAlphaBlending = false)
{
Matrix wld = obj.WorldMatrix;
if (clippingPlane.HasValue)
{
Vector4 plane = new Vector4(clippingPlane.Value.Normal, clippingPlane.Value.D);
basicDraw.Parameters["clippingPlane"].SetValue(plane);
basicDraw.Parameters["isClip"].SetValue(true);
}
else
{
basicDraw.Parameters["isClip"].SetValue(false);
}
if(useAlphaBlending)
render.PushBlendState(BlendState.AlphaBlend);
SamplerState s0 = render.SetSamplerState(BasicDrawSamplerState,0);
for (int i = 0; i < obj.Modelo.MeshNumber; i++)
{
BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
for (int j = 0; j < bi.Count(); j++)
{
//basicDraw.Parameters["diffuse"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,i,j));
render.device.Textures[0] = obj.Modelo.getTexture(TextureType.DIFFUSE, i, j);
Matrix w1 = Matrix.Multiply(wld, bi[j].ModelLocalTransformation);
this.basicDraw.Parameters["WVP"].SetValue(w1 * view * projection);
render.RenderBatch(bi[j], basicDraw);
}
}
if(useAlphaBlending)
render.PopBlendState();
render.SetSamplerState(s0, 0);
}
示例6: 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);
}
}