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.


Chr0n1x

Member Since 14 Jul 2010
Offline Last Active Aug 23 2011 06:18 PM

Posts I've Made

In Topic: What about multiple objects?

28 January 2011 - 12:28 AM

XNA 4.0 doesn't actually have Begin/End methods, you just use Apply, however for the purposes of XNA 3.1, see below.

When you say "Nested", do you mean calling Begin/End inside the Begin/End of another effect?
Effects technically cannot be nested in that way, however in certain cases you can nest effects to apply some tricks. (more later)

The Effect object is simply a nice representation (and manager) for the two shaders that you use to render, the Vertex Shader and the Pixel Shader. When you call Effect.Begin, it applies those shaders to the graphics device, and when you begin each pass, it commits the parameters you may have specified to the shader on the GPU, ready to draw the geometry.

You can make as many draw calls inside a pass as you want, however if you change the state, for example changing the Texture or another parameter, you need to call Pass.CommitChanges before drawing.
If you are outside of a pass, you do not need to call CommitChanges; only when you are inside a pass. Calling Begin on an EffectPass will automatically commit the parameters.

You probably shouldn't change effects a lot, that does has performance implications - especially if you do not need to. So as a direct answer, Begin/End can be expensive, and you're better off batching every model that uses the effect into a single Begin/End, and then changing parameters and calling CommitChanges as required.

If you nest Effects, you simply override the shader objects on the graphics device with the ones in the child effect. This can be useful when you have say, just a Pixel Shader in an effect, and want to override the pixel shader specified by SpriteBatch without touching the Vertex Shader.

One other thing, as far as I know, changing textures on the graphics device itself (GraphicsDevice.Textures[x]), rather than through the Effect interface, shouldn't require a call to CommitChanges.

XNA 4.0 doesn't actually use Begin/End for both the Effect and the Pass. Instead it uses the Apply method for each pass.

In Topic: Transformations and the "World" matrix

28 January 2011 - 12:06 AM

Think of spaces as frames of reference. When we move a point from one space to another, we change the origin, and as a result the point "moves". To keep things simple, objects have a "local" or "model" space, where the origin <0,0,0> is usually the center of the model. (It does not have to be, but it is usually nearby) This allows the artist to create individual models around <0,0,0> in their editor.

In the game, we obviously cannot have each model sitting right next to, or on, <0,0,0>; we want them to be spread out in the world. So to do this, we need to apply some Transformations to the model vertices to move them where they need to go. By applying these transformations, we "move" the vertices away from the origin, and now the vertices are in World Space.

Matrices simply provide a nice and easy way to apply these transformations to many points. Remember that if you were to transform a complex model with many many points/vertices, you would need to apply the transformation to each one. If you wanted to Translate (move), Rotate and Scale your model, you would need to do 3 different things to each point. So instead you can combine the different transformations into a single Matrix that will do it all at once. Then the graphics card (or cpu) has a nice "pre-made" matrix that it can multiply by every point to apply all of the transformations.

In Topic: 3D Math

27 January 2011 - 11:52 PM

If you are on a budget, the Khan Academy provides a lot of great information for free, in an easy to learn format. (All video lessons)

http://www.khanacademy.org/#Linear Algebra

I have found that a lot of the videos from the Khan Academy are really well done and easy to understand.

Be sure to brush up on your Trigonometry as well if you haven't done that in a while.

The MIT OpenCourseWare is also an excellent source of information as Chris posted, and not just for maths.

Having a strong understanding of Vectors and Matrices will really help a lot with most areas of game development - also remember that most graphics theory books and physics programming books (Real-Time Rendering etc) will also have a section on the maths needed, including Linear Algebra.

In Topic: XNA 4.0 Workshop - Week 1 (Ch. 1-3)

17 January 2011 - 05:37 PM

Sorry if I missed it up above but I don't see it anywhere....what was the name and author of the book again?

Thanks,
Todd


http://www.amazon.com/Microsoft-XNA-Game-Studio-Unleashed/dp/0672330229/

In Topic: XNA 4.0 Workshop - Week 1 (Ch. 1-3)

17 January 2011 - 05:20 PM

I know it was said that big-endian vs. little-endian isnt relevant yet, but could someone elaborate on that a little more? Maybe a general synopsis of the concept.

Thanks!


Endianness refers to the order in which bytes are arranged in memory.

For example in a little-endian machine (x86) a 4-byte integer would be stored with the least significant byte first, so when viewing the four bytes (A,B,C,D) you would see it as D,B,C,A, where D is the least significant byte, and A is the most significant byte.

The 360 on the other hand is big-endian, and so it stores its bytes with the most significant byte first (or A,B,C,D) - when communicating between the PC and the XBOX over a network - or when sending files, you need to reverse the byte order to ensure the PC (or Xbox) reads the data correctly.

Here is a visual example that might help: http://en.wikipedia....0C0Dh_in_memory

If you are only working on one platform, or you are not communicating between them then you do not need to worry, however it is always good to know and remember in case you want to do this in future. Some nice little tricks can be used for development on the XBOX if you setup a system to communicate between PC and XBOX (or even WP7)

PARTNERS