8. Effect of Shaders Replaced hard coded effects Gives a programmable alternative Fixed Function PipelineProgrammable Function Pipeline 3.Parallel Programming
14. Games that Use Cg HIT MAN : Blood Money BATTLE FIELD 2 FAR CRY RACER And many more
15. 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
16. 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
17. Example Shader structVertIn //Input vertex { float4 pos : POSITION; float4 color : COLOR0; }; // output vertex structVertOut { float4 pos : POSITION; float4 color : COLOR0; }; // vertex shader main entry VertOutmain(VertIn IN, uniform float4x4 modelViewProj) { VertOut OUT; OUT.pos= mul(modelViewProj, IN.pos); //position OUT.color= IN.color; // copy input color to output OUT.color.z= 1.0f; // blue component of color = 1.0f return OUT; }