Your SlideShare is downloading. ×
0
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Pixel shaders
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Pixel shaders

492

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

×