Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:35:23+00:00 2026-06-16T13:35:23+00:00

I just started using pixel shaders with xna, but I can’t wrap my head

  • 0

I just started using pixel shaders with xna, but I can’t wrap my head around several things, and it seems there is no clear answer anywhere…

I use spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); and I would like to apply shaders to a particular sprite I’m drawing and then cancel it back to a default shader or no shader.

So, can you help me with following?

  • If I have several techniques in an effect file – how do I call a particular one? Because at the moment what I do is: shaders.CurrentTechnique.Passes[0].Apply(); and it works for one technique but I would like to have many.

  • If technique has several passes how do I apply all of them?

  • If I already applied a shader how do I cancel it? I can end the current sprite batch of course and start another one. But I don’t really know if that’s how it should be done for most efficiency.

Any other tips for working with pixel shaders?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:35:24+00:00Added an answer on June 16, 2026 at 1:35 pm

    You can define different techniques in your effects file like this:

    // shading code ...
    
    technique Technique1
    {
        pass Pass1
        {
            // VertexShader = ...
            // PixelShader = ...
        }
    
        pass Pass2
        {
            // VertexShader = ...
            // PixelShader = ...
        }
    
        // more passes if you want
    }
    
    technique Technique2
    {
        pass Pass1
        {
            // VertexShader = ...
            // PixelShader = ...
        }
    
        // more Passes if you want ...
    }
    

    From your C# code use your effects file as follows:

    // declar your variable by loading the effect file from the content pipeline
    Effect effect = ContentManager.Load<Effect>("NameOfMyEffectFile");
    
    // use a particular technique
    effect.CurrentTechnique = effect.Techniques["Technique1"];
    
    // apply a particular pass
    effect.CurrentTechnique.Passes[1].Apply();
    
    // begin some drawing
    effect.Begin();
    
    // draw ...
    
    // end some drawing
    effect.End();
    

    If you want to apply multiple passes, simply iterate over all of them like this:

    foreach(EffectPass p in effect.CurrentTechnique.Passes)
    {
        // begin some drawing
        p.Begin();
    
        // draw ...
    
        // end some drawing
        p.End();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started using log4net and trying to get my head around the config and
Just started using App Engine's webapp framework, but I can't figure out what's wrong
I just started using Eclipse but already I have a small problem. At first
I just started using the new project type SQL Server 2008 Database. I can
Just started using fadein/fadeout - it's functioning but with problems. I have a set
I just started using the Memory Analyzer Tool (MAT) to see if I can
I just started using ctags and greatly appreciate the tool but the way I
I just started using AutoTest. As far as i can tell i have everything
I just started using the TPL, and I want to make several calls to
Just started using carrierwave with Rails and things have been going smoothly with one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.