Chapter 13: HLSL Basics
Quiz Answers
In HLSL, how can you access the first element in a
float4object?If you want to access the first element in a
float4object calledcolor, you can use array notation (color[0]), or you can use the namespaces for color and position (color.rorcolor.x).
What is swizzling?
The term swizzling refers to accessing multiple elements of a
float4or similar dataype at the same time by using two or more elements from the color or position namespaces (e.g.,color.rborcolor.xyz).
In HLSL, how do you specify which vertex and pixel shader versions to use?
In the
passblock of the technique for an HLSL effect file, you specify aVertexShaderand/or aPixelShaderby providing thecompilekeyword followed by a shader version. For vertex shaders, you usevs_1_1syntax, and for pixel shaders, you useps_1_1syntax.
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.
How do you multiply two matrices together in HLSL?
The
mulfunction in HLSL will multiply together two matrices.
What is the role of a semantic in HLSL?
A semantic marks a variable as being used for a certain purpose. For input parameters, ...