More Rendering Complexity – Shaders and Cameras

Tutorial 3

9 Responses to “More Rendering Complexity – Shaders and Cameras”

  1. ketelsb says:

    I can’t get it to work properly. The image keeps resizing when I resize the window, so i asume it’s not using the camera as viewport.

    I noticed this in the PDF at page 8. Could that be the problem?

    // In HMGame
    using HMEngine.HMCameras;
    protected override void LoadContent()
    HMObjectManager.Root.LoadContent(GraphicsDevice, Content);
    HMShaderManager.LoadContent(GraphicsDevice, Content);


    What is this HMObjectManager.Root?

    Do I need to set an active camera?


  2. mikeschuld says:

    Have you tried looking at the svn source code? There may be slight issues in the PDF that could be the issue. Also, if you are changing the resolution or the size of the window, the image is supposed to be shrinking. The framework scales the final rendered output to the new window size. If you wanted to make it exactly the same no matter the window size, you’d need to play with the focal distance of the lens, which is accomplished by messing with the fieldOfView parameter in the Update function. The other thing you could try is visiting the forums and asking around there. A few hundred more eyes on the problem might help as well if it really is a problem :)

  3. ketelsb says:

    I’m sorry to bother you again, but where do i find the source for the tutorials?
    I tried to search the forum and there’s much talk of source code, but not much links to the source.

  4. ketelsb says:

    Never mind. I found, downloaded TurtoiseSVN and checked the Trunk out :)
    I will find the problem with this working example.

  5. ketelsb says:

    I overlooked these lines in the PDF at page 9:
    if (null != myEffect.Parameters[“World”]) myEffect.Parameters[“World”].SetValue(World);
    if (null != myEffect.Parameters[“View”]) myEffect.Parameters[“View”].SetValue(HMCameraManager.ActiveCamera.View);
    if (null != myEffect.Parameters[“Project”]) myEffect.Parameters[“Project”].SetValue(HMCameraManager.ActiveCamera.Projection);

    That fixed it! (and makes much more sense too)

  6. jnbutler says:

    Should I be using VS2008? I did not have any problems with the code until I came to this:
    myVertices = new[] {
    new VertexPositionColorTexture(new Vector3(-0.5f, 0.5f, 0), myColor, new Vector2(0, 0)),
    new VertexPositionColorTexture(new Vector3(0.5f, 0.5f, 0), myColor, new Vector2(1, 0)),
    new VertexPositionColorTexture(new Vector3(-0.5f, -0.5f, 0), myColor, new Vector2(0, 1)),
    new VertexPositionColorTexture(new Vector3(0.5f, -0.5f, 0), myColor, new Vector2(1, 1))

    myIndexes = new[] { 0, 1, 2, 1, 3, 2 };

    I’m getting syntax error value expected at the square brackets in VS 2005 Pro.
    I guess I will have to download VS 2008 Express huh?

  7. mikeschuld says:

    jnbutler, The new[]{}; syntax is a part of C# 3.0 and will probably need .Net 3.5 and VS2008 to compile correctly. You could use syntax like

    new VertexPositionColorTexture[]{ … }

    as well to alleviate this issue.

  8. jnbutler says:

    I went ahead and installed C# Express 2008 and XNA 3.0. Now I can open the svn source! Cool! Great tutorials Mike, thanks.

  9. M0RPh1N3 says:

    Hiya hazymind! After talking at you on #xna @ Efnet I finally found time to stop in an check these new tutorial version out. I found that going through them a second time almost a year or so later, I understand them alot more.
    These are really nice. Idk if they are for complete beginners though lol. I love these because they show how to actually tie a game neatly together instead of hard code everything.
    These were really what I needed to hit up again because I found myself stumbling over adding managers and object isolation.
    I documented you general process and am using the steps to write my terrain components woot!

    Thanks m@e

Leave a Reply

You must be logged in to post a comment.

Do NOT follow this link or you will be banned from the site!