• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Pixel shaders
 

Pixel shaders

on

  • 677 views

 

Statistics

Views

Total Views
677
Views on SlideShare
677
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Pixel shaders Pixel shaders Presentation Transcript

    • Pixel shaders: programming the GPU
      By: Venkata Nanda Kishore
    • What is a Shader?
      Set of Software Instructions
      Degree of Flexibility
      Traits of an entity
    • Entities,Traits And Degree
      • Entities:
      Pixels
      Vertices
      Geometric shapes
      • Traits:
      Pixels: z-buffer, alpha values etc.
      Vertices: Texture co-ordinates, Color
    • Types of Shaders
      Initially, Shaders are just pixel shaders
      Types of Shaders:
      • Pixel Shaders
      • Vertex Shaders
      • Geometric Shaders
      But the name remained as it was!
    • Effect of Shaders
      Replaced hard coded effects
      Gives a programmable alternative
      Fixed Function PipelineProgrammable Function Pipeline
      3.Parallel Programming
    • Programming Shaders
      HLSL (Direct 3d)
      GLSL (OpenGl)
      Cg(Nvidia + Microsoft)
    • Cg
      What is Cg?
      Is it similar to C?
      Is it the right question?
      Can we use it as a general programming language?
    • Background of Cg
      Use of Assembly level language
      What is assembly level?
      What is high level,low level and middle level?
      How easy is it?
    • Example of assembly level language
      fib: movedx, [esp+8]
      cmpedx, 0 ja @f
      moveax, 0
      ret
      @@:
      cmpedx, 2 ja @f
      moveax, 1
      ret
      @@:
      push ebx
      movebx, 1
      movecx, 1
      @@: lea eax, [ebx+ecx]
      cmpedx, 3 jbe @f movebx, ecx
      movecx, eax
      decedx
      jmp@b
      @@:
      pop ebx
      ret
    • Advantage of Cg
      Portable
      Easy
      Optimize the code
    • Syntax and Semantics(1)
      Data Types:
      int, float, half, fixed, bool, sampler*
      Operators: Arithmetic and logical operators as in C
      Additional: arithmetic operations for vector and matrix operrations
    • Syntax and Semantics(2)
      Functions and Control Structures: Similar to C
      Standard Cg Library: Specialised GPU programming tasks
      Eg. Texture Mapping functions tex1D and tex2D
      Cg Runtime Library:Can be used with OpenGl or DirectX
    • Example Shader
      // input vertexstructVertIn
      { float4 pos : POSITION;
      float4 color : COLOR0; };
      // output vertexstructVertOut
      { float4 pos : POSITION; float4 color : COLOR0; };
      // vertex shader main entry
      VertOutmain(VertIn IN, uniform float4x4 modelViewProj)
      { VertOut OUT;
      OUT.pos= mul(modelViewProj, IN.pos); // calculate output coords
      OUT.color = IN.color; // copy input color to output
      OUT.color.z= 1.0f; // blue component of color = 1.0f
      return OUT; }
    • Games that Use Cg
      HIT MAN : Blood Money
      BATTLE FIELD 2
      FAR CRY
      RACER
      And many more
    • How to use Pixel Shaders?