Hi,
Since 3.3 (and at least dev builds up last Tuesday or Wednesday), the following code is producing unexpected results:
...
effect.CurrentTechnique = effect.Techniques[0];
effect.Parameters["sk_ratio"].SetValue(sk_ratio);
effect.Parameters["sk_jitter"].SetValue(sk_jitter);
effect.Parameters["sk_texture"].SetValue(sk_texture);
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, effect);
spriteBatch.Draw(title_rendertarget, title_position, null, Color.White * Alpha, 0, title_origin, 1.4f, SpriteEffects.None, 0);
spriteBatch.End();
...
with the pixel shader code is:
#include "Macros.fxh"
#ifdef SM4
#define TECHNIQUE_FRAGMENT_ONLY(name, psname) \
technique name { pass { PixelShader = compile ps_4_0_level_9_3 psname(); } }
#else
#define TECHNIQUE_FRAGMENT_ONLY(name, psname ) \
technique name { pass { PixelShader = compile ps_2_0 psname(); } }
#endif
DECLARE_TEXTURE(sb_texture, 0);
DECLARE_TEXTURE(sk_texture, 1);
BEGIN_CONSTANTS
float2 sk_ratio;
float2 sk_jitter;
float2 rgb_displacement;
END_CONSTANTS
float4 SketchPixelShader(float4 position : SV_Position, float4 color : COLOR0, float2 tex_coord : TEXCOORD0) : SV_Target0 {
float4 color1 = SAMPLE_TEXTURE(sb_texture, tex_coord);
float4 color2 = SAMPLE_TEXTURE(sk_texture, (tex_coord + sk_jitter) * sk_ratio);
return color1 * color2;
}
TECHNIQUE_FRAGMENT_ONLY(SketchTechnique, SketchPixelShader );
It appears that the texture sk_texture in sampler 1 isn’t getting correctly passed to the device resulting in nothing being rendered.
By adding the following line:
GraphicsDevice.Textures[1] = null;
After the:
effect.Parameters["sk_texture"].SetValue(sk_texture);
The shader with the correct textures is correctly rendered. I suspect that some kind of dirty flag isn’t being properly set within the Effect.SetValue(…)
I can reproduce the issue with ATI/AMD and nVidia cards using WinDX, didn’t had time to try it on GL and Windows Phone