-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
I'm not sure if my code/effect is broken or render-target support is, but still I'm using a sample effect from XNA-catalog, so still wanted report this to get you ideas & feedback.
The effect is from the Non-Realisting Rendering sample - the sketch effect.
First of all here's the screenshot of XNA version demonstrating the effect;
And here's output from MonoGame-Metro counterpart;
Actually the effect file included with XNA sample has multiple effects in it, so I trimmed it down as;
sampler SceneSampler : register(s0) = sampler_state
{
Texture = SceneTexture;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
texture SketchTexture;
sampler SketchSampler : register(s2) = sampler_state
{
Texture = SketchTexture;
AddressU = Wrap;
AddressV = Wrap;
};
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
{
float3 scene = tex2D(SceneSampler, texCoord);
float3 saturatedScene = saturate((scene - SketchThreshold) * 2);
float3 sketchPattern = tex2D(SketchSampler, texCoord + SketchJitter);
float3 negativeSketch = (1 - saturatedScene) * (1 - sketchPattern);
float sketchResult = dot(1 - negativeSketch, SketchBrightness);
scene *= sketchResult;
return float4(scene, 1);
}
technique ColorSketch
{
pass P0
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}For monogame-metro, I instead use;
technique ColorSketch
{
pass P0
{
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
}
}And i compile it as;
2MGFX.exePostprocessEffect.Metro.fx PostprocessEffect.Metro.mgfxo /DEBUG /DX11My basic render-target & effect code;
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.SetRenderTarget(sceneRenderTarget);
GraphicsDevice.Clear(Color.CornflowerBlue);
this.spriteBatch.Begin();
//this.spriteBatch.Draw(this._sample,this.GraphicsDevice.PresentationParameters.Bounds,Color.White);
this.spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
ApplyPostprocess();
base.Draw(gameTime);
}
private void ApplyPostprocess()
{
EffectParameterCollection parameters = _postprocessEffect.Parameters;
// Set effect parameters controlling the pencil sketch effect.
parameters["SketchThreshold"].SetValue(SketchThreshold);
parameters["SketchBrightness"].SetValue(SketchBrightness);
parameters["SketchJitter"].SetValue(_sketchJitter);
parameters["SketchTexture"].SetValue(_sketchTexture);
// Activate the appropriate effect technique.
_postprocessEffect.CurrentTechnique = _postprocessEffect.Techniques["ColorSketch"];
// Draw a fullscreen sprite to apply the postprocessing effect.
spriteBatch.Begin(0, BlendState.AlphaBlend, null, null, null, _postprocessEffect);
spriteBatch.Draw(sceneRenderTarget, Vector2.Zero, Color.White);
spriteBatch.End();
}So chances that either render-target support is broken for WP8/Metro or the effect isn't working all good with MonoGame - or I'm doing something horrible with my code :)
- I've uploaded a sample project that both has XNA and MonoGame-Metro version included for easier testing purposes.
- Note: I'm using develop branch (and also tried the stable 3.0 release).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

