Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Techniques and Passes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 zee_ola05   Members   -  Reputation: 325

Like
0Likes
Like

Posted 25 February 2011 - 11:31 AM

I know that these concept will come up later in the workshop, but maybe someone can tell us what techniques and passes are.

effect.View = view;
effect.Projection = projection;

Matrix world = Matrix.Identity;
effect.World = world;
effect.EnableDefaultLighting();

foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
	pass.Apply();
	graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1,
		VertexPositionNormalTexture.VertexDeclaration);
}

What does the foreach part in the code actually mean? Thanks! :)

Sponsor:

#2 JWalsh   Moderators   -  Reputation: 463

Like
0Likes
Like

Posted 26 February 2011 - 04:37 PM

Hi Zee,

Within any Effect (or corresponding HLSL file), there can be multiple techniques. Think of a technique as a specific style of drawing. Each technique is made up of one or more passes. Most of the Effects you'll be using as a beginning programmer will have only one technique in it, and the techniques you'll be using as a beginning programmer will likely have only a single pass - meaning your geometry will only be drawn once. However as your rendering code gets more complex, you may have more textures to draw than can be sent to the video card in a single pass, or you may be attempting some other technique that requires your geometry to be drawn multiple times. In this case, you frequently take advantage of frame buffer alpha in order to blend each of the pass together.

That foreach loop reads exactly as it is written. For each pass in the current technique, apply the vertex and pixel shader and then draw the Geometry.

As you're probably using BasicEffect, which has only a single pass, it's also safe to just say:

effect.CurrentTechnique.Passes[0].Apply();

graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1,
                VertexPositionNormalTexture.VertexDeclaration);

Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

#3 zee_ola05   Members   -  Reputation: 325

Like
0Likes
Like

Posted 27 February 2011 - 01:08 AM

Is there a way to change the number of Passes in a BasicEffect? If not, then I can say that I can use this code whenever I'm just using basic effect. Am I correct? Thanks JWalsh! :)

effect.CurrentTechnique.Passes[0].Apply();

graphics
.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1,
VertexPositionNormalTexture.VertexDeclaration);


#4 JWalsh   Moderators   -  Reputation: 463

Like
0Likes
Like

Posted 27 February 2011 - 12:09 PM

Is there a way to change the number of Passes in a BasicEffect? If not, then I can say that I can use this code whenever I'm just using basic effect. Am I correct? Thanks JWalsh! :)

effect.CurrentTechnique.Passes[0].Apply();

graphics
.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1, VertexPositionNormalTexture.VertexDeclaration);


Zee,

You are correct. Both the Techniques collection as well as Pass collection on an Effect object is read-only. You cannot change the number of techniques or passes in a technique for any given effect. So any time you know you're using BasicEffect, it's safe to just apply Passes[0].
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS