SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Lighting & Material CS3241 Lab
Objectives Render illuminated objects by defining the desired light sources and lighting model Define the material properties of the objects being illuminated Manipulate the matrix stack to control the position of light sources
Resource Lec7_code ObjectMaterials.c ObjectMaterials2.c
Lighting Enable lighting  glEnable(GL_LIGHTING);  Turn on a light source (0-7) glEnable(GL_LIGHT0…7); Turn off a light source (0…7) glDisable(GL_LIGHT0…7); Setting up light properties 		e.g. glLightfv(GL_LIGHT0, GL_POSITION, pos);
Properties Color GL_AMBIENT GL_DIFFUSE GL_SPECULAR Position GL_POSITION Attenuation  (apply to positional light source only) GL_CONSTANT_ATTENUTATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION
Point Light E.g. light bulb Positional light Creating Point light (setup a point light at [0,0,0]) Specify by setting position.w = 1 GLfloat position[] = { 0.0, 0.0, 0.0, 1.0 };  glLightfv(GL_LIGHT0, GL_POSITION, position);  x, y, z denote its position in 3D space
Directional Light Directional Light Light rays are shot in specified direction from infinite location E.g. Sun Creating Directional light Specify by setting position.w = 0 GLfloat position[] = { 1.0, 1.0, 1.0, 0.0 };  glLightfv(GL_LIGHT0, GL_POSITION, position);  x, y, z denote its direction
Spot light Positional light source Creating a spot light Glfloat position[] = { 0, 1.0, 0, 1.0 };  GLfloatspot_direction[] = { -1.0, -1.0, 0.0 };  glLightfv(GL_LIGHT1, GL_POSITION, position);  glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0);  Properties GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF
Moving a light #1: Setting its position value E.g. glLightfv(GL_LIGHT0, GL_POSITION, light_position);  #2: Using Transformation Matrix E.g. glTranslate(), glRotate() Glfloat position[4] = {0,0,0,0}; glPushMatrix(); glRotatef(rotL, 0, 1, 0); glTranslatef(1.5, 1.5, 0); glLightfv(GL_LIGHT1, GL_POSITION, position);  glPopMatrix();
Task 1 Starting Point: ObjectMaterials.c Task 1.1 Turn off light0 by pressing spacebar Hint: glDisable(GL_LIGHT0); Task 1.2 Add a new point light source (light1) at [0,0,0] Hint: GLfloat position[] = { 0.0, 0.0, 0.0, 1.0 };  glLightfv(GL_LIGHT1, GL_POSITION, position); glEnable(GL_LIGHT1);
Task 1 Task 1.3 Make light1 hover overhead (in a circular motion) Hint: Glfloat position[4] = {0,0,0,0}; glPushMatrix(); glRotatef(rotL, 0, 1, 0); glTranslatef(1.5, 1.5, 0); glLightfv(GL_LIGHT1, GL_POSITION, position);  glPopMatrix();
Material
Material Properties GL_AMBIENT ambient color of material GL_DIFFUSE diffuse color of material GL_AMBIENT_AND_DIFFUSE  ambient and diffuse color of material GL_SPECULAR specular color of material GL_SHININESS specular exponent GL_EMISSION emissive color of material
Material Using a material Setup material 	e.g. glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);  Using material OpenGL is a state machine Following draw call will use the material specified Example glPushMatrix();  		// setup material glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 	 		// draw sphere glutSolidSphere(1.0, 16, 16);  glPopMatrix();
Task 2 Set the teapot material to Ruby Ruby Ambient: (0.1745, 0.01175, 0.01175, 0.55) Diffuse: (0.61424, 0.04136, 0.04136, 0.55) Specular: (0.727811, 0.626959, 0.626959, 0.55) Shininess: 76.8 Solution in ObjectMaterials2.c
Reference OpenGL Red book http://www.glprogramming.com/red/chapter05.html Material http://www.cs.utk.edu/~kuck/materials_ogl.htm

Weitere ähnliche Inhalte

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

CS3241 Lab7

  • 1. Lighting & Material CS3241 Lab
  • 2. Objectives Render illuminated objects by defining the desired light sources and lighting model Define the material properties of the objects being illuminated Manipulate the matrix stack to control the position of light sources
  • 4. Lighting Enable lighting glEnable(GL_LIGHTING); Turn on a light source (0-7) glEnable(GL_LIGHT0…7); Turn off a light source (0…7) glDisable(GL_LIGHT0…7); Setting up light properties e.g. glLightfv(GL_LIGHT0, GL_POSITION, pos);
  • 5. Properties Color GL_AMBIENT GL_DIFFUSE GL_SPECULAR Position GL_POSITION Attenuation (apply to positional light source only) GL_CONSTANT_ATTENUTATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION
  • 6. Point Light E.g. light bulb Positional light Creating Point light (setup a point light at [0,0,0]) Specify by setting position.w = 1 GLfloat position[] = { 0.0, 0.0, 0.0, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, position); x, y, z denote its position in 3D space
  • 7. Directional Light Directional Light Light rays are shot in specified direction from infinite location E.g. Sun Creating Directional light Specify by setting position.w = 0 GLfloat position[] = { 1.0, 1.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_POSITION, position); x, y, z denote its direction
  • 8. Spot light Positional light source Creating a spot light Glfloat position[] = { 0, 1.0, 0, 1.0 }; GLfloatspot_direction[] = { -1.0, -1.0, 0.0 }; glLightfv(GL_LIGHT1, GL_POSITION, position); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0); Properties GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF
  • 9. Moving a light #1: Setting its position value E.g. glLightfv(GL_LIGHT0, GL_POSITION, light_position); #2: Using Transformation Matrix E.g. glTranslate(), glRotate() Glfloat position[4] = {0,0,0,0}; glPushMatrix(); glRotatef(rotL, 0, 1, 0); glTranslatef(1.5, 1.5, 0); glLightfv(GL_LIGHT1, GL_POSITION, position); glPopMatrix();
  • 10. Task 1 Starting Point: ObjectMaterials.c Task 1.1 Turn off light0 by pressing spacebar Hint: glDisable(GL_LIGHT0); Task 1.2 Add a new point light source (light1) at [0,0,0] Hint: GLfloat position[] = { 0.0, 0.0, 0.0, 1.0 }; glLightfv(GL_LIGHT1, GL_POSITION, position); glEnable(GL_LIGHT1);
  • 11. Task 1 Task 1.3 Make light1 hover overhead (in a circular motion) Hint: Glfloat position[4] = {0,0,0,0}; glPushMatrix(); glRotatef(rotL, 0, 1, 0); glTranslatef(1.5, 1.5, 0); glLightfv(GL_LIGHT1, GL_POSITION, position); glPopMatrix();
  • 13. Material Properties GL_AMBIENT ambient color of material GL_DIFFUSE diffuse color of material GL_AMBIENT_AND_DIFFUSE  ambient and diffuse color of material GL_SPECULAR specular color of material GL_SHININESS specular exponent GL_EMISSION emissive color of material
  • 14. Material Using a material Setup material e.g. glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); Using material OpenGL is a state machine Following draw call will use the material specified Example glPushMatrix(); // setup material glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); // draw sphere glutSolidSphere(1.0, 16, 16); glPopMatrix();
  • 15. Task 2 Set the teapot material to Ruby Ruby Ambient: (0.1745, 0.01175, 0.01175, 0.55) Diffuse: (0.61424, 0.04136, 0.04136, 0.55) Specular: (0.727811, 0.626959, 0.626959, 0.55) Shininess: 76.8 Solution in ObjectMaterials2.c
  • 16. Reference OpenGL Red book http://www.glprogramming.com/red/chapter05.html Material http://www.cs.utk.edu/~kuck/materials_ogl.htm