SlideShare a Scribd company logo
1 of 20
Compositing and Blending
Objectives
• Learn to use the A component in RGBA color for
• Blending for translucent surfaces
• Compositing images
• Antialiasing
2
Opacity and Transparency
•Opaque surfaces permit no light to pass through
•Transparent surfaces permit all light to pass
•Translucent surfaces pass some light
translucency = 1 – opacity (α)
3
opaque surface α =1
Physical Models
•Dealing with translucency in a physically correct
manner is difficult due to
• the complexity of the internal interactions of light and matter
• Using a pipeline renderer
4
Writing Model
•Use A component of RGBA (or RGBα) color to store
opacity
•During rendering we can expand our writing model to
use RGBA values
5
Color Buffer
destination
component
blend
destination blending
factor
source blending factor
source
component
Blending Equation
•We can define source and destination blending factors
for each RGBA component
s = [sr, sg, sb, sα]
d = [dr, dg, db, dα]
Suppose that the source and destination colors are
b = [br, bg, bb, bα]
c = [cr, cg, cb, cα]
Blend as
c’ = [brsr+ crdr, bgsg+ cgdg, bb sb+ cbdb , bαsα+ cαdα]
6
OpenGL Blending and Compositing
•Must enable blending and pick source and destination
factors
glEnable(GL_BLEND)
glBlendFunc(source_factor,
destination_factor)
•Only certain factors supported
• GL_ZERO, GL_ONE
• GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
• GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA
• See Redbook for complete list
7
Example
•Suppose that we start with the opaque background
color (R0,G0,B0,1)
• This color becomes the initial destination color
•We now want to blend in a translucent polygon with
color (R1,G1,B1,α1)
•Select GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA
as the source and destination blending factors
R’
1= α1 R1+(1- α1) R0,……
•Note this formula is correct if polygon is either opaque
or transparent
8
Clamping and Accuracy
• All the components (RGBA) are clamped and stay in the range (0,1)
• However, in a typical system, RGBA values are only stored to 8 bits
• Can easily loose accuracy if we add many components together
• Example: add together n images
• Divide all color components by n to avoid clamping
• Blend with source factor = 1, destination factor = 1
• But division by n loses bits
9
Order Dependency
• Is this image correct?
• Probably not
• Polygons are rendered
in the order they pass
down the pipeline
• Blending functions
are order dependent
10
Opaque and Translucent Polygons
•Suppose that we have a group of polygons some of
which are opaque and some translucent
•How do we use hidden-surface removal?
•Opaque polygons block all polygons behind them and
affect the depth buffer
•Translucent polygons should not affect depth buffer
• Render with glDepthMask(GL_FALSE) which makes
depth buffer read-only
•Sort polygons first to remove order dependency
11
Fog
•We can composite with a fixed color and have the
blending factors depend on depth
• Simulates a fog effect
•Blend source color Cs and fog color Cfby
Cs’=f Cs + (1-f) Cf
•f is the fog factor
• Exponential
• Gaussian
• Linear (depth cueing)
12
Fog Functions
13
OpenGL Fog Functions
GLfloat fcolor[4] = {……}:
glEnable(GL_FOG);
glFogf(GL_FOG_MODE, GL_EXP);
glFogf(GL_FOG_DENSITY, 0.5);
glFOgv(GL_FOG, fcolor);
14
Line Aliasing
• Ideal raster line is one pixel wide
• All line segments, other than vertical and horizontal segments,
partially cover pixels
• Simple algorithms color
only whole pixels
• Lead to the “jaggies”
or aliasing
• Similar issue for polygons
15
Antialiasing
•Can try to color a pixel by adding a fraction of its color
to the frame buffer
• Fraction depends on percentage of pixel covered by fragment
• Fraction depends on whether there is overlap
16
no overlap overlap
Area Averaging
•Use average area α1+α2-α1α2 as blending factor
17
OpenGL Antialiasing
• Can enable separately for points, lines, or polygons
18
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Accumulation Buffer
•Compositing and blending are limited by resolution of
the frame buffer
• Typically 8 bits per color component
•The accumulation buffer is a high resolution buffer
(16 or more bits per component) that avoids this
problem
•Write into it or read from it with a scale factor
•Slower than direct compositing into the frame buffer
19
Applications
• Compositing
• Image Filtering (convolution)
• Whole scene antialiasing
• Motion effects
20

More Related Content

What's hot

Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Adwait Hegde
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringShajun Nisha
 
Compututer Graphics - Color Modeling And Rendering
Compututer Graphics - Color Modeling And RenderingCompututer Graphics - Color Modeling And Rendering
Compututer Graphics - Color Modeling And RenderingPrince Soni
 
10 color image processing
10 color image processing10 color image processing
10 color image processingbabak danyal
 
Graph Coloring and Its Implementation
Graph Coloring and Its ImplementationGraph Coloring and Its Implementation
Graph Coloring and Its ImplementationIJARIIT
 
OpenCV presentation series- part 3
OpenCV presentation series- part 3OpenCV presentation series- part 3
OpenCV presentation series- part 3Sairam Adithya
 
Tutorial on Object Detection (Faster R-CNN)
Tutorial on Object Detection (Faster R-CNN)Tutorial on Object Detection (Faster R-CNN)
Tutorial on Object Detection (Faster R-CNN)Hwa Pyung Kim
 
OpenCV presentation series- part 2
OpenCV presentation series- part 2OpenCV presentation series- part 2
OpenCV presentation series- part 2Sairam Adithya
 
(slides 3) Visual Computing: Geometry, Graphics, and Vision
(slides 3)  Visual Computing: Geometry, Graphics, and Vision(slides 3)  Visual Computing: Geometry, Graphics, and Vision
(slides 3) Visual Computing: Geometry, Graphics, and VisionFrank Nielsen
 
Paper Presentation (Graph)
Paper Presentation (Graph)Paper Presentation (Graph)
Paper Presentation (Graph)Falguni Roy
 
Edge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringEdge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringDr. Abdul Ahad Abro
 
Kernel Descriptors for Visual Recognition
Kernel Descriptors for Visual RecognitionKernel Descriptors for Visual Recognition
Kernel Descriptors for Visual RecognitionPriyatham Bollimpalli
 
Scope and Issues in Alpha Compositing Technology
Scope and Issues in Alpha Compositing TechnologyScope and Issues in Alpha Compositing Technology
Scope and Issues in Alpha Compositing TechnologyAM Publications
 

What's hot (20)

Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filtering
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Compututer Graphics - Color Modeling And Rendering
Compututer Graphics - Color Modeling And RenderingCompututer Graphics - Color Modeling And Rendering
Compututer Graphics - Color Modeling And Rendering
 
10 color image processing
10 color image processing10 color image processing
10 color image processing
 
Graph Coloring and Its Implementation
Graph Coloring and Its ImplementationGraph Coloring and Its Implementation
Graph Coloring and Its Implementation
 
OpenCV presentation series- part 3
OpenCV presentation series- part 3OpenCV presentation series- part 3
OpenCV presentation series- part 3
 
Tutorial on Object Detection (Faster R-CNN)
Tutorial on Object Detection (Faster R-CNN)Tutorial on Object Detection (Faster R-CNN)
Tutorial on Object Detection (Faster R-CNN)
 
OpenCV presentation series- part 2
OpenCV presentation series- part 2OpenCV presentation series- part 2
OpenCV presentation series- part 2
 
Color models
Color modelsColor models
Color models
 
(slides 3) Visual Computing: Geometry, Graphics, and Vision
(slides 3)  Visual Computing: Geometry, Graphics, and Vision(slides 3)  Visual Computing: Geometry, Graphics, and Vision
(slides 3) Visual Computing: Geometry, Graphics, and Vision
 
Color models
Color modelsColor models
Color models
 
Paper Presentation (Graph)
Paper Presentation (Graph)Paper Presentation (Graph)
Paper Presentation (Graph)
 
Edge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringEdge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloring
 
Image pyramid
Image pyramidImage pyramid
Image pyramid
 
Kernel Descriptors for Visual Recognition
Kernel Descriptors for Visual RecognitionKernel Descriptors for Visual Recognition
Kernel Descriptors for Visual Recognition
 
Gamma and Colour Space
Gamma and Colour SpaceGamma and Colour Space
Gamma and Colour Space
 
Scope and Issues in Alpha Compositing Technology
Scope and Issues in Alpha Compositing TechnologyScope and Issues in Alpha Compositing Technology
Scope and Issues in Alpha Compositing Technology
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Graphics Libraries
Graphics LibrariesGraphics Libraries
Graphics Libraries
 

Similar to Compositing and Blending

CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
Image enhancement in the spatial domain1
Image enhancement in the spatial domain1Image enhancement in the spatial domain1
Image enhancement in the spatial domain1shabanam tamboli
 
Image Enhancement in the Spatial Domain1.ppt
Image Enhancement in the Spatial Domain1.pptImage Enhancement in the Spatial Domain1.ppt
Image Enhancement in the Spatial Domain1.pptShabanamTamboli1
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
Edge detection-based post-processing in Warlords of Draenor
Edge detection-based post-processing in Warlords of DraenorEdge detection-based post-processing in Warlords of Draenor
Edge detection-based post-processing in Warlords of DraenorGael Hofemeier
 
Curves and surfaces in OpenGL
Curves and surfaces in OpenGLCurves and surfaces in OpenGL
Curves and surfaces in OpenGLSyed Zaid Irshad
 
Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene GraphsSyed Zaid Irshad
 
Order independent transparency
Order independent transparencyOrder independent transparency
Order independent transparencyDaosheng Mu
 
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptCharlesMatu2
 
CS 354 Understanding Color
CS 354 Understanding ColorCS 354 Understanding Color
CS 354 Understanding ColorMark Kilgard
 
Shading for Computer Topics in Burapha University
Shading for Computer Topics in Burapha UniversityShading for Computer Topics in Burapha University
Shading for Computer Topics in Burapha UniversityMao Sararith
 
Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)Igalia
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.pptSKILL2021
 

Similar to Compositing and Blending (20)

Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Image enhancement in the spatial domain1
Image enhancement in the spatial domain1Image enhancement in the spatial domain1
Image enhancement in the spatial domain1
 
Image Enhancement in the Spatial Domain1.ppt
Image Enhancement in the Spatial Domain1.pptImage Enhancement in the Spatial Domain1.ppt
Image Enhancement in the Spatial Domain1.ppt
 
september11.ppt
september11.pptseptember11.ppt
september11.ppt
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
OpenGL Texture Mapping
OpenGL Texture MappingOpenGL Texture Mapping
OpenGL Texture Mapping
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Edge detection-based post-processing in Warlords of Draenor
Edge detection-based post-processing in Warlords of DraenorEdge detection-based post-processing in Warlords of Draenor
Edge detection-based post-processing in Warlords of Draenor
 
Curves and surfaces in OpenGL
Curves and surfaces in OpenGLCurves and surfaces in OpenGL
Curves and surfaces in OpenGL
 
Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene Graphs
 
Deferred shading
Deferred shadingDeferred shading
Deferred shading
 
Inferred lighting
Inferred lightingInferred lighting
Inferred lighting
 
Order independent transparency
Order independent transparencyOrder independent transparency
Order independent transparency
 
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
 
CS 354 Understanding Color
CS 354 Understanding ColorCS 354 Understanding Color
CS 354 Understanding Color
 
Shading for Computer Topics in Burapha University
Shading for Computer Topics in Burapha UniversityShading for Computer Topics in Burapha University
Shading for Computer Topics in Burapha University
 
Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 

More from Syed Zaid Irshad

More from Syed Zaid Irshad (20)

Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
DBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionDBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_Solution
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Professional Issues in Computing
Professional Issues in ComputingProfessional Issues in Computing
Professional Issues in Computing
 
Reduce course notes class xi
Reduce course notes class xiReduce course notes class xi
Reduce course notes class xi
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
C Language
C LanguageC Language
C Language
 
Flowchart
FlowchartFlowchart
Flowchart
 
Algorithm Pseudo
Algorithm PseudoAlgorithm Pseudo
Algorithm Pseudo
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
ICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionICS 2nd Year Book Introduction
ICS 2nd Year Book Introduction
 
Security, Copyright and the Law
Security, Copyright and the LawSecurity, Copyright and the Law
Security, Copyright and the Law
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Data Communication
Data CommunicationData Communication
Data Communication
 
Information Networks
Information NetworksInformation Networks
Information Networks
 
Basic Concept of Information Technology
Basic Concept of Information TechnologyBasic Concept of Information Technology
Basic Concept of Information Technology
 
Introduction to ICS 1st Year Book
Introduction to ICS 1st Year BookIntroduction to ICS 1st Year Book
Introduction to ICS 1st Year Book
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 

Recently uploaded

Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 

Recently uploaded (20)

Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 

Compositing and Blending

  • 2. Objectives • Learn to use the A component in RGBA color for • Blending for translucent surfaces • Compositing images • Antialiasing 2
  • 3. Opacity and Transparency •Opaque surfaces permit no light to pass through •Transparent surfaces permit all light to pass •Translucent surfaces pass some light translucency = 1 – opacity (α) 3 opaque surface α =1
  • 4. Physical Models •Dealing with translucency in a physically correct manner is difficult due to • the complexity of the internal interactions of light and matter • Using a pipeline renderer 4
  • 5. Writing Model •Use A component of RGBA (or RGBα) color to store opacity •During rendering we can expand our writing model to use RGBA values 5 Color Buffer destination component blend destination blending factor source blending factor source component
  • 6. Blending Equation •We can define source and destination blending factors for each RGBA component s = [sr, sg, sb, sα] d = [dr, dg, db, dα] Suppose that the source and destination colors are b = [br, bg, bb, bα] c = [cr, cg, cb, cα] Blend as c’ = [brsr+ crdr, bgsg+ cgdg, bb sb+ cbdb , bαsα+ cαdα] 6
  • 7. OpenGL Blending and Compositing •Must enable blending and pick source and destination factors glEnable(GL_BLEND) glBlendFunc(source_factor, destination_factor) •Only certain factors supported • GL_ZERO, GL_ONE • GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA • GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA • See Redbook for complete list 7
  • 8. Example •Suppose that we start with the opaque background color (R0,G0,B0,1) • This color becomes the initial destination color •We now want to blend in a translucent polygon with color (R1,G1,B1,α1) •Select GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA as the source and destination blending factors R’ 1= α1 R1+(1- α1) R0,…… •Note this formula is correct if polygon is either opaque or transparent 8
  • 9. Clamping and Accuracy • All the components (RGBA) are clamped and stay in the range (0,1) • However, in a typical system, RGBA values are only stored to 8 bits • Can easily loose accuracy if we add many components together • Example: add together n images • Divide all color components by n to avoid clamping • Blend with source factor = 1, destination factor = 1 • But division by n loses bits 9
  • 10. Order Dependency • Is this image correct? • Probably not • Polygons are rendered in the order they pass down the pipeline • Blending functions are order dependent 10
  • 11. Opaque and Translucent Polygons •Suppose that we have a group of polygons some of which are opaque and some translucent •How do we use hidden-surface removal? •Opaque polygons block all polygons behind them and affect the depth buffer •Translucent polygons should not affect depth buffer • Render with glDepthMask(GL_FALSE) which makes depth buffer read-only •Sort polygons first to remove order dependency 11
  • 12. Fog •We can composite with a fixed color and have the blending factors depend on depth • Simulates a fog effect •Blend source color Cs and fog color Cfby Cs’=f Cs + (1-f) Cf •f is the fog factor • Exponential • Gaussian • Linear (depth cueing) 12
  • 14. OpenGL Fog Functions GLfloat fcolor[4] = {……}: glEnable(GL_FOG); glFogf(GL_FOG_MODE, GL_EXP); glFogf(GL_FOG_DENSITY, 0.5); glFOgv(GL_FOG, fcolor); 14
  • 15. Line Aliasing • Ideal raster line is one pixel wide • All line segments, other than vertical and horizontal segments, partially cover pixels • Simple algorithms color only whole pixels • Lead to the “jaggies” or aliasing • Similar issue for polygons 15
  • 16. Antialiasing •Can try to color a pixel by adding a fraction of its color to the frame buffer • Fraction depends on percentage of pixel covered by fragment • Fraction depends on whether there is overlap 16 no overlap overlap
  • 17. Area Averaging •Use average area α1+α2-α1α2 as blending factor 17
  • 18. OpenGL Antialiasing • Can enable separately for points, lines, or polygons 18 glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  • 19. Accumulation Buffer •Compositing and blending are limited by resolution of the frame buffer • Typically 8 bits per color component •The accumulation buffer is a high resolution buffer (16 or more bits per component) that avoids this problem •Write into it or read from it with a scale factor •Slower than direct compositing into the frame buffer 19
  • 20. Applications • Compositing • Image Filtering (convolution) • Whole scene antialiasing • Motion effects 20