Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

SpriteBatch does not use custom Effect #30

Closed
gitfool opened this issue Sep 30, 2014 · 3 comments
Closed

SpriteBatch does not use custom Effect #30

gitfool opened this issue Sep 30, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@gitfool
Copy link

gitfool commented Sep 30, 2014

Following up from Paradox Answers.
Hack the Custom Effect Sample to use a SpriteBatch instead of a PrimitiveQuad:

private void RenderQuad(RenderContext renderContext)
{
    //GraphicsDevice.SetBlendState(GraphicsDevice.BlendStates.NonPremultiplied);
    customEffect.Parameters.Set(CustomEffectKeys.Phase, -3 * (float)this.UpdateTime.Total.TotalSeconds);
    //quad.Draw(paradoxTexture, samplingState, Color.White);
    var destination = new RectangleF(0, 0, GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height);
    spriteBatch.Begin(SpriteSortMode.Immediate, GraphicsDevice.BlendStates.NonPremultiplied, samplingState, effect: customEffect);
    spriteBatch.Draw(paradoxTexture, destination, Color.White);
    spriteBatch.End();
}

The custom effect is never applied. Stepping the code in the debugger, after spriteBatch.Begin the spriteBatch.Effect property is of type BatchDefaultEffect, not CustomEffect.

@gitfool
Copy link
Author

gitfool commented Sep 30, 2014

Digging further, BaseBatch<SpriteBatch.SpriteDrawInfo>.Begin is resetting the Effect property:

if (!resourceContextPerEffect.ContainsKey(Effect))
{
    Effect = DefaultEffect;
}

That's why I wasn't sure if it was a bug or misuse on my behalf, where I had to somehow set up this resourceContextPerEffect with my custom effect, but there was nothing obvious that I could see with Reflector.

@xoofx xoofx added the bug label Oct 1, 2014
@xoofx xoofx self-assigned this Oct 1, 2014
@xoofx xoofx added this to the alpha10 milestone Oct 1, 2014
@xoofx
Copy link

xoofx commented Oct 1, 2014

This should be fixed for alpha10

@gitfool
Copy link
Author

gitfool commented Oct 9, 2014

For the record, I updated Xamarin tools today (beta channel), so I'm now using Xamarin 3.8.13.0, Xamarin.Android 4.18.0.34 and Xamarin iOS 8.2.0.0.

This works fine on Windows, but fails on Android and iOS, rendering a blank screen.

stride-bot pushed a commit that referenced this issue Jan 20, 2017
…h to master

[Editor] Fix text search for the add component dropdown

* commit 'd203296b8ce3ac4434da6812f7b64440c13e865b':
  [GameStudio] Allow text search and confirmation with Enter key on the 'Add Component' dropdown in the entity property grid
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants