You are previewing HLSL and Pixel Shaders for XAML Developers.
O'Reilly logo
HLSL and Pixel Shaders for XAML Developers

Book Description

Pixel shaders are some of the more powerful graphic tools available for XAML programmers, but shader development bears little resemblance to traditional .NET programming. With this hands-on book, you’ll not only discover how to use existing shaders in your Windows Presentation Foundation (WPF) and Silverlight applications, you’ll also learn how create your own effects with XAML and Microsoft’s HLSL shading language.

Table of Contents

  1. HLSL and Pixel Shaders for XAML Developers
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Preface
    1. Who This Book Is For
    2. What You Need to Use This Book
    3. Contents of This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
  4. Foreword
  5. 1. Shader 101
    1. Why Should XAML Developers Learn HLSL?
    2. The Tale of the Shader
    3. HLSL and DirectX
    4. Understanding the Graphics Pipeline
    5. XAML and Shaders
    6. Summary
  6. 2. Getting Started
    1. Setting Up Your Development Computer
      1. Silverlight Development
      2. WPF Development
      3. Expression Blend 4
    2. Choosing a Shader Compiler
      1. DirectX Compiler
      2. WPF Build Task
      3. Shazzam Shader Editor
    3. Other Tools to Consider
      1. FX Composer
      2. NShader
      3. Visual Studio 2012
    4. A First Shader Project
      1. Using Prebuilt Effects
      2. Adding Effects
      3. Debrief
    5. Custom Shader
      1. Create a Shader Algorithm
      2. Compile the HLSL Code
      3. Add to Visual Studio XAML Project
      4. Create a .NET Wrapper Class
      5. Compile the Project
      6. Instantiate the Shader
    6. Summary
  7. 3. Commonplace Pixel Shaders
    1. A Word About Pseudocode
      1. Our Sample Image
    2. Color Modification
      1. Common Techniques
      2. Black, White, and Gray
        1. Black-White
        2. Grayscale
      3. Color Replacement
      4. Color Enhancement and Correction
      5. Distinctive Effects
    3. Distortion and Displacement
      1. Magnify
      2. Embossed
      3. Testing Distortion Effects
      4. Other Displacement Effects
    4. Blurs
      1. Motion Blur
      2. Zoom Blur
      3. Sharpening
    5. Generative Effects
    6. Multiple Inputs
    7. Sampler Transition
    8. Texture Map
    9. Color Combination
      1. Photoshop Blend Modes
      2. Darken Modes
      3. Lighten Modes
      4. Contrast Modes
      5. Comparative Modes
      6. Other Modes
      7. Blend Modes in HLSL
    10. Practical Uses for Shader Effects
      1. Motion Blur in Moving Parts
      2. Blurs to Emphasize UI Focus
      3. Desaturate for Emphasis
    11. Summary
  8. 4. How WPF and Silverlight Use Shaders
    1. Framework Effects
      1. BlurEffect
      2. DropShadowEffect
    2. Nested Effects
      1. Multiple Effects on One Element
    3. Expression Blend Effects
      1. Using a Blend Effect
    4. Custom Effects
      1. Creating a Custom ShaderEffect
        1. Loading the .ps file
        2. Using the ShaderEffect
      2. Working with Samplers
        1. Implicit input from ShaderEffect
        2. Explicit input from ShaderEffect
        3. Pipeline trivia
        4. Explicit input revisited
      3. Multi-Input Shaders
      4. Understanding Sampler Size
      5. Creating Parameterized Effects
        1. UpdateShaderValue
        2. Property Types
      6. Padding
      7. Effect Mapping
        1. GeneralTransform class
        2. GeneralTransform and EffectMapping property
    5. Summary
  9. 5. Using Expression Blend and Visual Studio with Shaders
    1. Creating a Project
      1. New Project
      2. Adding Assets
      3. Adding Effects
      4. Setting Effect Properties
    2. Visual Studio Editor
    3. Using Custom Effects in Blend
      1. Multi-Input Effects
        1. Setting brushes with Property window
    4. Transition Effects in Blend
      1. Create a State Group
      2. Add the States
      3. Set the Properties
      4. Adding a Transition Effect
    5. Summary
  10. 6. Using the Shazzam Shader Editor
    1. UI Tour
    2. Create a Custom Shader
      1. Exploring the HLSL Code Editor
      2. Compiling and Testing the Shader
      3. Editor Status Bar
      4. Exploring the Generated Code
      5. Changing Options
      6. Working with HLSL Parameters
      7. Testing Parameters
      8. Default Values for Parameters
        1. Changing the test harness values
      9. Shazzam Tags
      10. Input Parameter Types
      11. Influencing the .NET Type
      12. Multi-Input Shaders
      13. Shader Loader
        1. Your Folder tab
        2. Sample Shaders tab
        3. The Tutorial tab
      14. More Shazzam Tools
        1. Fullscreen mode
        2. Take a screenshot
      15. Copying the Files into a Visual Studio Project
    3. Summary
  11. 7. HLSL in Detail
    1. Parallel Processing in Shaders
      1. Parallelism and the GPU
      2. One-Pixel-at-a-Time Algorithm
    2. The Relationship Between DirectX and the GPU
    3. Understanding Registers
    4. Basic Structure of an HLSL Program
      1. User-Defined Functions
      2. Semantics
      3. Data Types
        1. Scalar type
        2. Array type
        3. Vector type
          1. Initializing a vector
          2. Swizzling
        4. Matrix type
        5. Object type
        6. Custom type
    5. Type Casting
      1. Local Variables
    6. Shader Inputs
      1. TEXCOORD Input
      2. Global Variables
      3. Global Inputs
      4. Texture and Sampler Input
      5. Sampler Declarations
        1. Other texture declarations
    7. Other Code Constructs
      1. Flow Control—Branching
        1. The trouble with float
        2. Parallel programming and branches
      2. Flow Control—Loops
      3. Operators
    8. Built-in Functions
      1. Texture Functions
      2. Math Functions
      3. Useful Built-in Functions
        1. Clamp and saturate
        2. Lerp
    9. Summary
  12. 8. The Zen of Shader Programming
    1. Zen of Pixel Programming
      1. Sampling a Pixel Color
      2. Sampling a Color from Another Texture
    2. Colors
      1. Color Channel Manipulation
      2. Conditional Colors
        1. Preserving the alpha channel
      3. Replace a Color
      4. Other Color Modifier Examples
        1. Grayscale
        2. Cartoon shader
        3. Gloom shader
        4. The premultiplied alpha dilemma
      5. Coordinates
        1. Drawing a vertical line
        2. Pixelate
        3. Convolution kernels
        4. Defining a weighting matrix
        5. Building a convolution effect
      6. Distortion and Displacement Effects
      7. Random Values
      8. Noise Textures
        1. Creating static texture map
        2. Sampling the static map
      9. Perlin Noise in Shaders
        1. Noise lookup in a distortion shader
        2. Noise lookup in a lighting shader
    3. Summary
  13. A. Resources
    1. Books
    2. Programming
    3. Premultiplied Alpha Blending
    4. Convolution
    5. Noise
    6. Tools
  14. B. Shazzam Settings
  15. About the Author
  16. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  17. Copyright