Pixel shaders: programming the GPUBy: Venkata Nanda Kishore
What is a Shader?Set of Software InstructionsDegree of FlexibilityTraits of an entity
Entities,Traits And DegreeEntities:	Pixels	Vertices	Geometric shapesTraits:	Pixels: z-buffer, alpha values etc.Vertices: Texture co-ordinates, Color
Types of ShadersInitially, Shaders are just pixel shadersTypes of Shaders:Pixel Shaders
Vertex Shaders
Geometric ShadersBut the name remained as it was!
GRAPHICS PIPELINEGeometric ShadersRasteriserVertexShadersPixel Shaders
Effect of ShadersReplaced hard coded effectsGives a programmable alternativeFixed Function PipelineProgrammable Function Pipeline3.Parallel Programming
Programming ShadersHLSL (Direct 3d)GLSL (OpenGl)Cg(Nvidia + Microsoft)
CgWhat is Cg?Is it similar to C?Is it the right question?Can we use it as a general programming language?
Background of CgUse of Assembly level languageWhat is assembly level?What is high level,low level and middle level?How easy is it?
Example of assembly level languagefib: movedx, [esp+8]cmpedx, 0 ja @f moveax, 0 ret@@: cmpedx, 2 ja @fmoveax, 1ret @@: push ebxmovebx, 1movecx, 1 @@: lea eax, [ebx+ecx] cmpedx, 3 jbe @f movebx, ecxmovecx, eaxdecedxjmp@b@@: pop ebx ret
Advantage of CgPortableEasyOptimize the code
Games that Use CgHIT MAN :  Blood MoneyBATTLE FIELD 2FAR CRYRACERAnd many more
Syntax and Semantics(1)Data Types:int, float, half, fixed, bool, sampler*Operators: Arithmetic and logical operators as in CAdditional: arithmetic operations for vector and matrix operrations
Syntax and Semantics(2)Functions and Control Structures: Similar to CStandard Cg Library: Specialised GPU programming tasksEg. Texture Mapping functions tex1D and tex2DCg Runtime Library:Can be used with OpenGl or DirectX
Example ShaderstructVertIn			    //Input vertex{ float4 pos : POSITION; float4 color : COLOR0; };            // output vertexstructVertOut{ float4 pos : POSITION; float4 color : COLOR0; }; // vertex shader main entryVertOutmain(VertIn IN, uniform float4x4 modelViewProj) { VertOut OUT; OUT.pos= mul(modelViewProj, IN.pos); //positionOUT.color= IN.color; // copy input color to outputOUT.color.z= 1.0f; // blue component of color = 1.0freturn OUT;	 }
Loading Pixel Shaders in OpenGL1.Loading extensions:glEnable(GL_FRAGMENT_PROGRAM_ARB);2.Create Shader Number:glGenProgramsARB(1, &shader_num); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader_num);
Actually Loading the ShaderglProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(program_string), program_string);glDisable(GL_FRAGMENT_PROGRAM_ARB);http://joshbeam.com/articles/cg_pixel_shaders_in_opengl/

More Related Content

PPTX
Pixel shaders
PDF
Prefix and suffix of open gl
PPTX
Analisa Expression pada after effect menggungakan bahasa script
PPT
Unit iv
PDF
17432 object oriented programming
PDF
The Differences Between C and C++
PPT
Csc1100 lecture01 ch01-pt1
PPT
Csc1100 lecture01 ch01-pt1
Pixel shaders
Prefix and suffix of open gl
Analisa Expression pada after effect menggungakan bahasa script
Unit iv
17432 object oriented programming
The Differences Between C and C++
Csc1100 lecture01 ch01-pt1
Csc1100 lecture01 ch01-pt1

What's hot (19)

PDF
[C++ korea] effective modern c++ study item 4 - 6 신촌
PPT
C++ Introduction
PDF
[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...
PDF
Tricks
PPT
History of c++
DOCX
Ai unit3 planing
PPT
PPTX
Shader Programming With Unity
PPTX
Unit 1 of c++ part 1 basic introduction
PDF
Sen17513 summer2015-question-paper
PPT
3D Geo-standaarden workshop
PPTX
Introduction to c programming language
PPTX
Using FME for Interoperability between GIS and non-GIS Systems
PPTX
Creating Domain Specific Languages in F#
PDF
Comparing PGQL, G-Core and Cypher
PDF
Haxe vs Unicode (en)
PDF
Challenges for advanced domain-specific frameworks
DOCX
Assignment 4
PPTX
Direct Acyclic Graph (DAG)
[C++ korea] effective modern c++ study item 4 - 6 신촌
C++ Introduction
[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...
Tricks
History of c++
Ai unit3 planing
Shader Programming With Unity
Unit 1 of c++ part 1 basic introduction
Sen17513 summer2015-question-paper
3D Geo-standaarden workshop
Introduction to c programming language
Using FME for Interoperability between GIS and non-GIS Systems
Creating Domain Specific Languages in F#
Comparing PGQL, G-Core and Cypher
Haxe vs Unicode (en)
Challenges for advanced domain-specific frameworks
Assignment 4
Direct Acyclic Graph (DAG)
Ad

Viewers also liked (17)

PPTX
Spark Data Streaming Pipeline
PDF
Big Data Logging Pipeline with Apache Spark and Kafka
PDF
Email Classifier using Spark 1.3 Mlib / ML Pipeline
ODP
PPTX
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
PPT
Geometry Shader-based Bump Mapping Setup
PDF
Shaders - Claudia Doppioslash - Unity With the Best
PPTX
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
PDF
Unity Surface Shader for Artist 02
PDF
Advanced Spark and TensorFlow Meetup 08-04-2016 One Click Spark ML Pipeline D...
PPTX
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
PDF
Building Scalable Big Data Pipelines
PPTX
Building a unified data pipeline in Apache Spark
PPTX
R&D to Product Pipeline Using Apache Spark in AdTech: Spark Summit East talk ...
PPTX
Working with Shader with Unity
PPTX
Aws overview
PDF
Unity道場11 Shader Forge 101 ~ShaderForgeをつかって学ぶシェーダー入門~ 基本操作とよく使われるノード編
Spark Data Streaming Pipeline
Big Data Logging Pipeline with Apache Spark and Kafka
Email Classifier using Spark 1.3 Mlib / ML Pipeline
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Geometry Shader-based Bump Mapping Setup
Shaders - Claudia Doppioslash - Unity With the Best
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Unity Surface Shader for Artist 02
Advanced Spark and TensorFlow Meetup 08-04-2016 One Click Spark ML Pipeline D...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
Building Scalable Big Data Pipelines
Building a unified data pipeline in Apache Spark
R&D to Product Pipeline Using Apache Spark in AdTech: Spark Summit East talk ...
Working with Shader with Unity
Aws overview
Unity道場11 Shader Forge 101 ~ShaderForgeをつかって学ぶシェーダー入門~ 基本操作とよく使われるノード編
Ad

Similar to Pixel shaders (20)

PPT
CS 354 Programmable Shading
PPT
OpenGL 3.2 and More
PPTX
Opengl lec 3
PPTX
Graphics Libraries
PPTX
OpenGL Shading Language
PPT
NVIDIA's OpenGL Functionality
PPT
Introduction to 2D/3D Graphics
PDF
Unity advanced computer graphics week 02
PPT
OpenGL ES based UI Development on TI Platforms
PDF
Gdc 14 bringing unreal engine 4 to open_gl
PPT
Hardware Shaders
PPTX
Chapter02 graphics-programming
PDF
Computer Graphics - Lecture 01 - 3D Programming I
PDF
CG3_ch3+ch4computergraphicsbreesenhan.pdf
PPT
OpenGL 4 for 2010
PPT
CS 354 Pixel Updating
PPT
openGL basics for sample program.ppt
PPT
openGL basics for sample program (1).ppt
PPTX
2GKS, Open GL and IGES_Video Lect Given by Renjin.pptx
PDF
Opengl basics
CS 354 Programmable Shading
OpenGL 3.2 and More
Opengl lec 3
Graphics Libraries
OpenGL Shading Language
NVIDIA's OpenGL Functionality
Introduction to 2D/3D Graphics
Unity advanced computer graphics week 02
OpenGL ES based UI Development on TI Platforms
Gdc 14 bringing unreal engine 4 to open_gl
Hardware Shaders
Chapter02 graphics-programming
Computer Graphics - Lecture 01 - 3D Programming I
CG3_ch3+ch4computergraphicsbreesenhan.pdf
OpenGL 4 for 2010
CS 354 Pixel Updating
openGL basics for sample program.ppt
openGL basics for sample program (1).ppt
2GKS, Open GL and IGES_Video Lect Given by Renjin.pptx
Opengl basics

Pixel shaders