Pixel shaders

  • 470 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
470
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Pixel shaders: programming the GPU
    By: Venkata Nanda Kishore
  • 2. What is a Shader?
    Set of Software Instructions
    Degree of Flexibility
    Traits of an entity
  • 3. Entities,Traits And Degree
    • Entities:
    Pixels
    Vertices
    Geometric shapes
    • Traits:
    Pixels: z-buffer, alpha values etc.
    Vertices: Texture co-ordinates, Color
  • 4. Types of Shaders
    Initially, Shaders are just pixel shaders
    Types of Shaders:
    • Pixel Shaders
    • 5. Vertex Shaders
    • 6. Geometric Shaders
    But the name remained as it was!
  • 7. Effect of Shaders
    Replaced hard coded effects
    Gives a programmable alternative
    Fixed Function PipelineProgrammable Function Pipeline
    3.Parallel Programming
  • 8. Programming Shaders
    HLSL (Direct 3d)
    GLSL (OpenGl)
    Cg(Nvidia + Microsoft)
  • 9. Cg
    What is Cg?
    Is it similar to C?
    Is it the right question?
    Can we use it as a general programming language?
  • 10. 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?
  • 11. 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
  • 12. Advantage of Cg
    Portable
    Easy
    Optimize the code
  • 13. 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
  • 14. 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
  • 15. 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; }
  • 16. Games that Use Cg
    HIT MAN : Blood Money
    BATTLE FIELD 2
    FAR CRY
    RACER
    And many more
  • 17. How to use Pixel Shaders?