PostProcess doubles width of all lines
by Steven Durham · in Torque X 2D · 10/31/2008 (5:22 pm) · 0 replies
This is turning into a month long part time research project!
I apologize in advance for my ignorance
Why does this happen?
If I draw a Rect after the post processing (just hack it into the engine source code), it draws a nice sharp 1 px line.
But all lines drawn before postprocess are 2 pixels and slightly dimmer.
Does the simple effect blur everything slightly?
I would think simple effect would basically do nothing...
In TorqueEngineComponent.cs:
public override void Draw(GameTime gameTime)
{
Profiler.Instance.StartBlock("TorqueEngineComponent.Draw");
// set up post processing
bool postProcess = !(_mainRenderTarget.IsNull || _mainRenderTarget.IsInvalid) && EnableBackBufferEffects && (_postProcessor != null);
if (postProcess)
{
_currentRenderTarget = _mainRenderTarget.Instance;
GFXDevice.Instance.Device.SetRenderTarget(0, _mainRenderTarget.Instance);
ClearRenderTarget();
}
// render
GUICanvas.Instance.RenderFrame();
////////////////////////////////////////////////////////////////
/// THIS ONE DRAWS as 2 pixel lines, kinda "blurry"
DrawUtil.Rect(new RectangleF(20.0f, 20.0f, 800.0f, 800.0f), Color.Red);
////////////////////////////////////////////////////////////////
// clear post processing
if (postProcess)
{
// resolve the texture and reset the back buffer
GFXDevice.Instance.Device.SetRenderTarget(0, null);
Texture2D texture = _mainRenderTarget.Instance.GetTexture();
_currentRenderTarget = null;
// run the post processor
Vector2 size = new Vector2((float)GFXDevice.Instance.CurrentVideoMode.BackbufferWidth, (float)GFXDevice.Instance.CurrentVideoMode.BackbufferHeight);
_postProcessor.Run(texture, Vector2.Zero, size);
}
////////////////////////////////////////////////////////////////
/// THIS ONE DRAWS razor sharp 1 pixel...
DrawUtil.Rect(new RectangleF(30.0f, 30.0f, 900.0f, 900.0f), Color.Red);
////////////////////////////////////////////////////////////////
// sanity check to avoid memory leaks.
GFXDevice.Instance.FlushAndLockVolatileBuffers();
GFXDevice.Instance.UnlockVolatileBuffers();
Profiler.Instance.EndBlock("TorqueEngineComponent.Draw");
}
I apologize in advance for my ignorance
Why does this happen?
If I draw a Rect after the post processing (just hack it into the engine source code), it draws a nice sharp 1 px line.
But all lines drawn before postprocess are 2 pixels and slightly dimmer.
Does the simple effect blur everything slightly?
I would think simple effect would basically do nothing...
In TorqueEngineComponent.cs:
public override void Draw(GameTime gameTime)
{
Profiler.Instance.StartBlock("TorqueEngineComponent.Draw");
// set up post processing
bool postProcess = !(_mainRenderTarget.IsNull || _mainRenderTarget.IsInvalid) && EnableBackBufferEffects && (_postProcessor != null);
if (postProcess)
{
_currentRenderTarget = _mainRenderTarget.Instance;
GFXDevice.Instance.Device.SetRenderTarget(0, _mainRenderTarget.Instance);
ClearRenderTarget();
}
// render
GUICanvas.Instance.RenderFrame();
////////////////////////////////////////////////////////////////
/// THIS ONE DRAWS as 2 pixel lines, kinda "blurry"
DrawUtil.Rect(new RectangleF(20.0f, 20.0f, 800.0f, 800.0f), Color.Red);
////////////////////////////////////////////////////////////////
// clear post processing
if (postProcess)
{
// resolve the texture and reset the back buffer
GFXDevice.Instance.Device.SetRenderTarget(0, null);
Texture2D texture = _mainRenderTarget.Instance.GetTexture();
_currentRenderTarget = null;
// run the post processor
Vector2 size = new Vector2((float)GFXDevice.Instance.CurrentVideoMode.BackbufferWidth, (float)GFXDevice.Instance.CurrentVideoMode.BackbufferHeight);
_postProcessor.Run(texture, Vector2.Zero, size);
}
////////////////////////////////////////////////////////////////
/// THIS ONE DRAWS razor sharp 1 pixel...
DrawUtil.Rect(new RectangleF(30.0f, 30.0f, 900.0f, 900.0f), Color.Red);
////////////////////////////////////////////////////////////////
// sanity check to avoid memory leaks.
GFXDevice.Instance.FlushAndLockVolatileBuffers();
GFXDevice.Instance.UnlockVolatileBuffers();
Profiler.Instance.EndBlock("TorqueEngineComponent.Draw");
}
About the author