O'Reilly logo

Learning XNA 4.0 by Aaron Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13: HLSL Basics

Quiz Answers

  1. In HLSL, how can you access the first element in a float4 object?

    If you want to access the first element in a float4 object called color, you can use array notation (color[0]), or you can use the namespaces for color and position (color.r or color.x).

  2. What is swizzling?

    The term swizzling refers to accessing multiple elements of a float4 or similar datatype at the same time by using two or more elements from the color or position namespaces (e.g., color.rb or color.xyz).

  3. In HLSL, how do you specify which vertex and pixel shader versions to use?

    In the pass block of the technique for an HLSL effect file, you specify a VertexShader and/or a PixelShader by providing the compile keyword followed by a shader version. For vertex shaders, you use vs_2_0 syntax, and for pixel shaders, you use ps_2_0 syntax.

  4. What does HLSL do for you that you can’t accomplish without it?

    HLSL allows developers to access hardware functions that aren’t available via the XNA Framework. The reason: graphics hardware has become more and more complex, and if the XNA Framework were expanded to handle all capabilities of graphics cards, the framework would be enormous. Instead, HLSL works with XNA and allows you to write code for the graphics card itself.

  5. How do you multiply two matrices together in HLSL?

    The mul function in HLSL will multiply together two matrices.

  6. What is the role of a semantic in HLSL?

    A semantic marks a variable as being used for a certain purpose. For input parameters, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required