Chapter 13: HLSL Basics
Quiz Answers
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 calledcolor
, you can use array notation (color[0]
), or you can use the namespaces for color and position (color.r
orcolor.x
).
What is swizzling?
The term swizzling refers to accessing multiple elements of a
float4
or similar dataype at the same time by using two or more elements from the color or position namespaces (e.g.,color.rb
orcolor.xyz
).
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 aVertexShader
and/or aPixelShader
by providing thecompile
keyword followed by a shader version. For vertex shaders, you usevs_1_1
syntax, and for pixel shaders, you useps_1_1
syntax.
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
mul
function 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, ...
Get Learning XNA 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.