本文整理汇总了C#中RenderHelper.PopRenderTargetAsSingleRenderTarget2D方法的典型用法代码示例。如果您正苦于以下问题:C# RenderHelper.PopRenderTargetAsSingleRenderTarget2D方法的具体用法?C# RenderHelper.PopRenderTargetAsSingleRenderTarget2D怎么用?C# RenderHelper.PopRenderTargetAsSingleRenderTarget2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderHelper
的用法示例。
在下文中一共展示了RenderHelper.PopRenderTargetAsSingleRenderTarget2D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Texture2D ImageToProcess,RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
{
rHelper.PushRenderTarget(renderTarget1);
Saturate.Parameters["current"].SetValue(ImageToProcess);
Saturate.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
if(useFloatingBuffer)
rHelper.RenderFullScreenQuadVertexPixel(Saturate,SamplerState.PointClamp);
else
rHelper.RenderFullScreenQuadVertexPixel(Saturate, SamplerState.LinearClamp);
Texture2D t = rHelper.PopRenderTargetAsSingleRenderTarget2D();
rHelper.PushRenderTarget(renderTarget0);
gaussian.Draw(t, rHelper, gt, GraphicInfo, world,useFloatingBuffer);
Texture2D x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
rHelper.Clear(Color.Black);
Combine.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
Combine.Parameters["base"].SetValue(ImageToProcess);
Combine.Parameters["last"].SetValue(x);
if (useFloatingBuffer)
rHelper.RenderFullScreenQuadVertexPixel(Combine , SamplerState.PointClamp);
else
rHelper.RenderFullScreenQuadVertexPixel(Combine, GraphicInfo.SamplerState);
}
示例2: Draw
public override void Draw(Microsoft.Xna.Framework.Graphics.Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
{
//mix with last frame downsampled
if (tex != null)
{
rHelper.PushRenderTarget(rtend);
rHelper.RenderTextureComplete(tex, Color.FromNonPremultiplied(255, 255, 255, 255), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
rHelper.RenderTextureComplete(ImageToProcess, Color.FromNonPremultiplied(255, 255, 255, Amount), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp, BlendState.AlphaBlend);
end = rHelper.PopRenderTargetAsSingleRenderTarget2D();
}
//DownSample
rHelper.PushRenderTarget(rt);
rHelper.Clear(Color.Black);
if (end == null)
{
rHelper.RenderTextureComplete(ImageToProcess, Color.White, rt.Bounds, Matrix.Identity, ImageToProcess.Bounds, true, SpriteSortMode.Deferred, SamplerState.AnisotropicClamp);
}
else
{
rHelper.RenderTextureComplete(end, Color.White, rt.Bounds, Matrix.Identity, ImageToProcess.Bounds, true, SpriteSortMode.Deferred, SamplerState.AnisotropicClamp);
}
tex = rHelper.PopRenderTargetAsSingleRenderTarget2D();
if(end!=null)
rHelper.RenderTextureComplete(end, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
else
rHelper.RenderTextureComplete(ImageToProcess, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
}
示例3: DownColorTexture
/// <summary>
/// DownSample a Color Texture (using hardware Linear filtering, cant be used on Single/float Textures)
/// </summary>
/// <param name="render">The render.</param>
/// <param name="Texture2D">The texture2 D.</param>
/// <param name="SamplerState">State of the sampler.</param>
/// <returns></returns>
public Texture2D DownColorTexture(RenderHelper render, Texture2D Texture2D, SamplerState SamplerState)
{
render.PushRenderTarget(RenderTarget2D);
render.RenderTextureComplete(Texture2D, Color.White,
Rectangle, Matrix.Identity, Texture2D.Bounds,
true, SpriteSortMode.Deferred, SamplerState);
return render.PopRenderTargetAsSingleRenderTarget2D();
}
示例4: DownShaderBilinearTexture
/// <summary>
/// DownSample a texture using bilinear filtering implemented in Shader.
/// </summary>
/// <param name="render">The render.</param>
/// <param name="Texture2D">The texture2 D.</param>
/// <returns></returns>
public Texture2D DownShaderBilinearTexture(RenderHelper render, Texture2D Texture2D)
{
effect.CurrentTechnique = effect.Techniques[1];
effect.Parameters["PixelSize"].SetValue(new Vector2(1f / Texture2D.Width, 1f / Texture2D.Height));
effect.Parameters["HalfPixel"].SetValue(new Vector2(0.5f / Rectangle.Width, 0.5f / Rectangle.Height));
render.Textures[0] = Texture2D;
SamplerState s0 = render.SetSamplerState(SamplerState.PointClamp, 0);
render.PushRenderTarget(RenderTarget2D);
render.RenderFullScreenQuadVertexPixel(effect);
render.SetSamplerState(s0, 0);
return render.PopRenderTargetAsSingleRenderTarget2D();
}
示例5: Draw
public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
{
rHelper.PushRenderTarget(target);
gbp.Draw(rHelper[PrincipalConstants.extra1RT], rHelper, gt, GraphicInfo, world,false);
x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
if (doubleBlur)
{
rHelper.PushRenderTarget(target2);
gbp.Draw(x, rHelper, gt, GraphicInfo, world, false);
x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
}
effect.Parameters["intensity"].SetValue(intensity);
effect.Parameters["glowMapBlurried"].SetValue(x);
effect.Parameters["colorMap"].SetValue(ImageToProcess);
effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
if (useFloatingBuffer)
rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.PointClamp);
else
rHelper.RenderFullScreenQuadVertexPixel(effect, GraphicInfo.SamplerState);
}
示例6: Draw
public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
{
rHelper.PushRenderTarget(target);
be.Draw(ImageToProcess, rHelper, gt, GraphicInfo, world,useFloatingBuffer);
depht.Parameters["BlurScene"].SetValue(rHelper.PopRenderTargetAsSingleRenderTarget2D());
depht.Parameters["FarPlane"].SetValue(world.CameraManager.ActiveCamera.FarPlane);
depht.Parameters["D1M"].SetValue(rHelper[PrincipalConstants.DephRT]);
rHelper.Clear(Color.Black,ClearOptions.Target);
SetShaderParameters(distance, range, world.CameraManager.ActiveCamera.NearPlane, world.CameraManager.ActiveCamera.FarPlane);
if (useFloatingBuffer)
rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, depht, GraphicInfo.FullScreenRectangle, SamplerState.PointClamp);
else
rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, depht, GraphicInfo.FullScreenRectangle, GraphicInfo.SamplerState);
}
示例7: 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);
}
示例8: Draw
public override void Draw(Microsoft.Xna.Framework.Graphics.Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
{
Matrix v = world.CameraManager.ActiveCamera.View;
Matrix p = world.CameraManager.ActiveCamera.Projection;
if (firstTime)
{
oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;
firstTime = false;
}
rHelper.PushRenderTarget(rt);
rHelper.Clear(Color.Black);
rHelper.RenderSceneWithCustomMaterial(effectvelocity,
(effect, obj, bi,ti,s,er,wvp) =>
{
Matrix w1 = Matrix.Multiply(obj.WorldMatrix, bi.ModelLocalTransformation);
effect.Parameters["wvp"].SetValue(w1 * wvp);
effect.Parameters["oldwvp"].SetValue(w1 * oldViewProjection);
}, world, gt, null, ref v, ref p, false, true);
Texture2D tex = rHelper.PopRenderTargetAsSingleRenderTarget2D();
eff.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
eff.Parameters["numSamples"].SetValue(NumSamples);
eff.Parameters["velocity"].SetValue(tex);
eff.Parameters["cena"].SetValue(ImageToProcess);
eff.Parameters["Attenuation"].SetValue(Attenuation);
oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;
if (useFloatBuffer)
rHelper.RenderFullScreenQuadVertexPixel(eff, SamplerState.PointClamp);
else
rHelper.RenderFullScreenQuadVertexPixel(eff, GraphicInfo.SamplerState);
}
示例9: BlurHV
private Texture2D BlurHV(RenderHelper rHelper, Texture2D input, RenderTarget2D target)
{
String baseTechniqueName = "GaussianBlur";
// Do horizontal pass first
fULLGPUBlur.CurrentTechnique = fULLGPUBlur.Techniques[baseTechniqueName + "X"];
fULLGPUBlur.Parameters["g_fSigma"].SetValue(blurSigma);
fULLGPUBlur.Parameters["SourceTexture0"].SetValue(input);
fULLGPUBlur.Parameters["g_vSourceDimensions"].SetValue(new Vector2(input.Width, input.Height));
fULLGPUBlur.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(target.Width, target.Height));
rHelper.PushRenderTarget(target);
rHelper.RenderFullScreenQuadVertexPixel(fULLGPUBlur);
Texture2D pass1 = rHelper.PopRenderTargetAsSingleRenderTarget2D();
// Now the vertical pass
IntermediateRenderTarget t2 = factory.GetRenderTargetFromPool(target.Width, target.Height, SurfaceFormat.Color);
fULLGPUBlur.CurrentTechnique = fULLGPUBlur.Techniques[baseTechniqueName + "Y"];
fULLGPUBlur.Parameters["SourceTexture0"].SetValue(pass1);
rHelper.PushRenderTarget(t2.RenderTarget);
rHelper.RenderFullScreenQuadVertexPixel(fULLGPUBlur);
Texture2D tex = rHelper.PopRenderTargetAsSingleRenderTarget2D();
t2.InUse = false;
return tex;
}
示例10: RenderShadowMap
private void RenderShadowMap(GameTime gt, RenderHelper render, ref Matrix view, ref Matrix proj, IWorld world, IDeferredGBuffer deferredGBuffer)
{
render.PushRenderTarget(shadowRT);
render.Clear(Color.Transparent,ClearOptions.Target | ClearOptions.DepthBuffer,1,0);
render.RenderSceneDepth(world, gt, ref view, ref proj, true);
shadowMap = render.PopRenderTargetAsSingleRenderTarget2D();
}
示例11: 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();
}
//.........这里部分代码省略.........
示例12: Draw
public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
{
//if (Keyboard.GetState().IsKeyDown(Keys.Space))
//{
// rHelper.RenderTextureComplete(ImageToProcess);
// return;
//}
rHelper.PushRenderTarget(rt0);
rHelper.Clear(Color.Transparent);
if (mLAntiAliasingEdgeDetectionMode == MLAntiAliasingEdgeDetectionMode.Color)
effect.CurrentTechnique = effect.Techniques["ColorEdgeDetection"];
else
{
effect.CurrentTechnique = effect.Techniques["DepthEdgeDetection"];
effect.Parameters["depthTex"].SetValue(rHelper[PrincipalConstants.DephRT]);
}
effect.Parameters["PIXEL_SIZE"].SetValue(GraphicInfo.HalfPixel * 2);
effect.Parameters["colorTex"].SetValue(rHelper[PrincipalConstants.CombinedImage]);
effect.Parameters["threshold"].SetValue(0.0008f);
rHelper.RenderFullScreenQuadVertexPixel(effect);
Texture edges = rHelper.PopRenderTargetAsSingleRenderTarget2D();
rHelper.PushRenderTarget(rt1);
rHelper.Clear(Color.Transparent);
effect.CurrentTechnique = effect.Techniques["BlendWeightCalculation"];
effect.Parameters["areaTex"].SetValue(tex);
effect.Parameters["edgesTex"].SetValue(edges);
effect.Parameters["MAX_SEARCH_STEPS"].SetValue(16);
effect.Parameters["MAX_DISTANCE"].SetValue(65);
rHelper.RenderFullScreenQuadVertexPixel(effect);
Texture2D tt = rHelper.PopRenderTargetAsSingleRenderTarget2D();
rHelper.Clear(Color.Transparent);
pass.Parameters["cena"].SetValue(ImageToProcess);
//if (Keyboard.GetState().IsKeyDown(Keys.RightAlt))
//{
// rHelper.RenderTextureComplete(tt);
// return;
//}
//else
//{
//pass.Parameters["cena"].SetValue(ImageToProcess);
rHelper.RenderFullScreenQuadVertexPixel(pass);
//}
effect.CurrentTechnique = effect.Techniques["NeighborhoodBlending"];
effect.Parameters["colorTex"].SetValue(ImageToProcess);
effect.Parameters["blendTex"].SetValue(tt);
rHelper.RenderFullScreenQuadVertexPixel(effect);
}
示例13: Luminance
private Texture2D Luminance(RenderHelper rHelper, Texture2D input,RenderTarget2D target,String techniqueName)
{
luminance.CurrentTechnique = luminance.Techniques[techniqueName];
luminance.Parameters["SourceTexture0"].SetValue(input);
luminance.Parameters["g_vSourceDimensions"].SetValue(new Vector2(input.Width, input.Height));
luminance.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(target.Width, target.Height));
rHelper.PushRenderTarget(target);
rHelper.RenderFullScreenQuadVertexPixel(luminance);
return rHelper.PopRenderTargetAsSingleRenderTarget2D();
}
示例14: DownScale
private Texture2D DownScale(RenderHelper rHelper, Texture2D input, RenderTarget2D downscaleTarget, String technichName, bool useFloatingBuffer)
{
effect.CurrentTechnique = effect.Techniques[technichName];
effect.Parameters["SourceTexture0"].SetValue(input);
effect.Parameters["g_vSourceDimensions"].SetValue(new Vector2(input.Width, input.Height));
effect.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(downscaleTarget.Width, downscaleTarget.Height));
rHelper.PushRenderTarget(downscaleTarget);
if (useFloatingBuffer)
rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.PointClamp);
else
rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.LinearClamp);
return rHelper.PopRenderTargetAsSingleRenderTarget2D();
}
示例15: Draw
public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
{
if (firstTime)
{
rHelper.PushRenderTarget(lastFrameAdaptedLuminance);
rHelper.Clear(Color.White,ClearOptions.Target);
rHelper.PopRenderTargetAsSingleRenderTarget2D();
firstTime = false;
}
long time = stopwatch.ElapsedMilliseconds;
dt = (time - lastTime) / 1000.0f;
lastTime = time;
Texture2D d4 = DownScale(rHelper, ImageToProcess, 4, SurfaceFormat.HalfVector4, "Downscale4", useFloatingBuffer);
Texture2D d16 = DownScale(rHelper, d4, 4, SurfaceFormat.HalfVector4, "Downscale4", useFloatingBuffer);
Texture2D tex = Luminance(rHelper, d16, luminanceChain[0], "Luminance");
for (int i = 1; i < luminanceChain.Length; i++)
tex = DownScale(rHelper, tex, luminanceChain[i], "Downscale4", useFloatingBuffer); //possivelmente mudar para o efeito Downscale4Luminance
// Final downscale
tex = DownScale(rHelper, tex, currentFrameLuminance, "Downscale4Luminance", useFloatingBuffer);
// Adapt the luminance, to simulate slowly adjust exposure
luminance.Parameters["g_fDT"].SetValue(dt);
luminance.Parameters["fTau"].SetValue(fTau);
luminance.Parameters["SourceTexture1"].SetValue(lastFrameAdaptedLuminance);
tex = Luminance(rHelper, tex, currentFrameAdaptedLuminance, "CalcAdaptedLuminance");
//Bloom
IntermediateRenderTarget thresholdTex = factory.GetRenderTargetFromPool(d16.Width, d16.Height, SurfaceFormat.HalfVector4);
threshold.CurrentTechnique = threshold.Techniques["Threshold"];
threshold.Parameters["g_fThreshold"].SetValue(bloomThreshold);
threshold.Parameters["g_fMiddleGrey"].SetValue(toneMapKey);
threshold.Parameters["g_fMaxLuminance"].SetValue(maxLuminance);
threshold.Parameters["SourceTexture0"].SetValue(d16);
threshold.Parameters["SourceTexture1"].SetValue(tex);
threshold.Parameters["g_vSourceDimensions"].SetValue(new Vector2(d16.Width, d16.Height));
threshold.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(thresholdTex.RenderTarget.Width, thresholdTex.RenderTarget.Height));
rHelper.PushRenderTarget(thresholdTex.RenderTarget);
rHelper.RenderFullScreenQuadVertexPixel(threshold);
Texture2D blom = rHelper.PopRenderTargetAsSingleRenderTarget2D();
IntermediateRenderTarget postBlur = factory.GetRenderTargetFromPool(d16.Width, d16.Height, SurfaceFormat.Color);
Texture2D blur = BlurHV(rHelper, blom, postBlur.RenderTarget);
thresholdTex.InUse = false;
IntermediateRenderTarget upscale1 = factory.GetRenderTargetFromPool(GraphicInfo.BackBufferWidth / 8, GraphicInfo.BackBufferHeight / 8, SurfaceFormat.Color);
DownScale(rHelper, postBlur.RenderTarget, upscale1.RenderTarget, "ScaleHW", useFloatingBuffer);
postBlur.InUse = false;
IntermediateRenderTarget upscale2 = factory.GetRenderTargetFromPool(GraphicInfo.BackBufferWidth / 4, GraphicInfo.BackBufferHeight / 4, SurfaceFormat.Color);
DownScale(rHelper, upscale1.RenderTarget, upscale2.RenderTarget, "ScaleHW", useFloatingBuffer);
upscale1.InUse = false;
IntermediateRenderTarget bloom = factory.GetRenderTargetFromPool(GraphicInfo.BackBufferWidth / 2, GraphicInfo.BackBufferHeight / 2, SurfaceFormat.Color);
Texture2D resp = DownScale(rHelper, upscale2.RenderTarget, bloom.RenderTarget, "ScaleHW",useFloatingBuffer);
upscale2.InUse = false;
//toScreen.Parameters["SourceTexture0"].SetValue(resp);
//toScreen.Parameters["g_vSourceDimensions"].SetValue(new Vector2(resp.Width, resp.Height));
//toScreen.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(GraphicInfo.BackBufferWidth, GraphicInfo.BackBufferHeight));
//rHelper.RenderFullScreenQuadVertexPixel(toScreen);
// Now do tone mapping on the main source image, and add in the bloom
tone.CurrentTechnique = tone.Techniques["Tone"];
tone.Parameters["g_fMiddleGrey"].SetValue(toneMapKey);
tone.Parameters["g_fMaxLuminance"].SetValue(maxLuminance);
tone.Parameters["g_fBloomMultiplier"].SetValue(bloomMultiplier);
tone.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(GraphicInfo.BackBufferWidth, GraphicInfo.BackBufferHeight));
tone.Parameters["SourceTexture0"].SetValue(ImageToProcess);
tone.Parameters["SourceTexture1"].SetValue(currentFrameAdaptedLuminance);
tone.Parameters["SourceTexture2"].SetValue(resp);
rHelper.RenderFullScreenQuadVertexPixel(tone);
//// Flip the luminance textures
Swap(ref currentFrameAdaptedLuminance, ref lastFrameAdaptedLuminance);
bloom.InUse = false;
}