SlideShare una empresa de Scribd logo
1 de 22
Welcome to the hell!!!3d프로그래밍의 이해 2011.4.23. 민성기
진행 순서 ,[object Object]
정점변환의 마술 행렬. 그리고 벡터.
OpenGL 초기화
첫 삼각형과 만남
원근투영과 이동행렬 맛보기
회전행렬 맛보기
행렬 스텍 다루기
z버퍼
빛이 있으라!!
텍스처 바르기,[object Object]
3D란 무엇일까 나는야 화면버퍼라네~~ 픽셀의 집합이지~~ 짜잔~~!
가장 빨리 삼각형을 그리는 방법은??? 3D란 무엇일까 모델뷰 변환 픽셀 셰이더 버텍스셰이더 프로젝션 뷰볼륨-1 ~ 1 화면버퍼에 래스터라이징
정점변환의 마술. 행렬. ,[object Object]
수학자들이 오랜 세월 고민해 만들어준 물건
우리는 쓰기만 하면 됨. 행렬 정점 P 생각하기 편하게 2차원에서 살펴보자. 정점 P’
정점변환의 마술. 행렬. ,[object Object],𝑆𝑥00𝑆𝑦    𝑥𝑦   = 𝑥′𝑦′   𝑥′=𝑥∙𝑆𝑥𝑦′=𝑦∙𝑆𝑦  
정점변환의 마술. 행렬. ,[object Object],𝑐𝑜𝑠𝜃𝑠𝑖𝑛𝜃−𝑠𝑖𝑛𝜃𝑐𝑜𝑠𝜃    𝑥𝑦   = 𝑥′𝑦′   𝑥′=𝑥∙𝑐𝑜𝑠𝜃 −𝑦∙𝑠𝑖𝑛𝜃𝑦′=𝑦∙𝑠𝑖𝑛𝜃+𝑥∙𝑐𝑜𝑠𝜃  
정점변환의 마술. 행렬. ,[object Object],𝑥′=𝑥+𝑇𝑥𝑦′=𝑦+𝑇𝑦   100010𝑇𝑥𝑇𝑦1    𝑥𝑦1   = 𝑥′𝑦′1   𝑆𝑥000𝑆𝑦0001    𝑐𝑜𝑠𝜃𝑠𝑖𝑛𝜃0−𝑠𝑖𝑛𝜃𝑐𝑜𝑠𝜃0001    크기 동차행렬 회전 동차행렬
정점변환의 마술. 행렬. ,[object Object],있어 보여서. 남들 다 쓰니까. 가학성향 변태라서.  행렬의 결합법칙 덕 좀 보려고 𝑃∙𝑇1∙𝑅1∙𝑆1∙𝑇2=𝑃′   100010001   𝑃∙𝑀=𝑃′   𝑃′∙𝑇2−1∙𝑆1−1∙𝑅1−1∙𝑇1−1=𝑃   𝑃′∙𝑀−1=𝑃  
종이의 도형을 컴퓨터 화면으로. (Px, Py) (0, 0) P1 P1’ (SCx, SCy) (PCx, PCy) P2 P2’ P3 P3’ ×100010𝑆𝐶𝑥𝑆𝐶𝑦1   × 100010−𝑃𝐶𝑥−𝑃𝐶𝑦1   (0, 0) (Sx, Sy) ×𝐸000−𝐸0001   =𝑃′   𝑃   𝑃×𝐸000−𝐸0−𝑃𝐶𝑥∙𝐸+𝑆𝐶𝑥𝑃𝐶𝑦∙𝐸+𝑆𝐶𝑦1=𝑃′   𝑥′=𝑥∙𝐸−𝑃𝐶𝑥∙𝐸+𝑆𝐶𝑥𝑦′=−𝑦∙𝐸−𝑃𝐶𝑦∙𝐸+𝑆𝐶𝑦  
그렇다면 3D에서는?? ,[object Object],10     0001     0000     10𝑇𝑥𝑇𝑦   𝑇𝑧1   𝑆𝑥0     000𝑆𝑦     0000     𝑆𝑧000       01   𝑐𝑜𝑠𝜃𝑠𝑖𝑛𝜃     00−𝑠𝑖𝑛𝜃𝑐𝑜𝑠𝜃  0000        0000       01   ,[object Object]

Más contenido relacionado

Último

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 

Último (6)

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 

Destacado

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
 

Destacado (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
 

3D 프로그래밍의 이해. 2011.4.23

Notas del editor

  1. 웰컴투더 헬!! 저녁은 지옥에서 먹읍시다. 3D 공부는치매예방에 탁월.어려운 계산은 수학자들이 다 해둠. 깨알만한 지식으로 빼먹기만 하면 됨.
  2. 세미나 순서. 3D란 무엇일까. 행렬과 벡터에 대한 깨알만큼의 지식. 예제 살펴보기.
  3. 모델러가 삼각형을 모아 만든 물체. 관찰자가 모델을 바라봄. 정점을 관찰자의 시점 좌표계와 일치시키고 평면에 투영.
  4. 투영된 결과를 화면 버퍼에 뿌려주는 일련의 과정.
  5. 삼각형을 모아 모델. 삼각형의 정점을 각 모델뷰와프로젝션 변환에 던져넣어뷰볼륨에 정규화. 화면버퍼에 삼각형을 스캔한 뒤 한땀한땀 찍어준다. 이를 고정파이프라인. 그럼 가변파이프라인은?버텍스셰이더, 픽셀셰이더 언급. 가장 빨리 삼각형을 그리는 방법은? 그리지 않는 것. BSP, 포털, 옥트리등의씬그래프 개념 설명.
  6. 3D에서 행렬의 개념은 간단. 정점 P를 넣어 변환된 정점 P’를 얻는다.
  7. 크기변환 행렬. 풀어보면 간단. 왜 행렬을 쓰는지 의문이 들 정도.
  8. 회전변환 행렬. 다음은 2차원에서 회전행렬입니다. 마찬가지로 x, y 좌표를 넣으면 z축을 기준으로 𝜃만큼 회전된 점 x’ y’를 토해냅니다. 행렬을 풀어보면 이렇게 생겼습니다. 그런데 문제는 이동을 표현하기 위한 행렬에서 생깁니다.
  9. 이동변환 행렬은 2*2로 표시 불가. 머리좋은 수학자들이 3*3을 해법으로 내놓음. 이를 동차행렬이라 함.
  10. 굳이 이렇게까지 해서 행렬을 쓰는 이유는? 결합법칙 때문에. 점 P에 여러 단계의 변환이 걸려있을 때. 점은 하나가 아니라 수천, 수만개. 행렬을 결합해 계산 비용을 낮춤. 변환행렬의 역행렬 설명. 행렬의 항등원 설명.
  11. 종이의 도형 좌표를 화면으로. 종이는 좌하단 원점, 화면은 좌상단 원점. 종이의 중점이 원점이 되도록 이동. 종이와 화면의 비율만큼 크기 변환. 이 때 Y좌표 뒤집기. 화면좌표계의 정점으로 각 정점을 이동. 행렬들을 풀어 계산OpenGL이나 D3D같은 그래픽 API를 이용할 때는 이 최종행렬을 설정하고 정점을 공급한다고 이해하자. A4 용지에 그려진 삼각형을 컴퓨터 화면에 옮기는 예를 통해 행렬에 대해 살펴봅시다. A4 용지상의 원점은 종이 좌하단, 그리고 화면상의 원점은 좌상단에 위치합니다. 종이위의 정점 P1, P2, P3 를 화면의 정점 P1’, P2’, P3’ 로 옮기려면 다음과 같은 과정을 거치게 됩니다. 종이좌표계의 중점을 (PCx, PCy). 화면좌표계의 중점을 (SCx, SCy) 라고 합시다. "여기에 수식을 입력하십시오."종이좌표계의중점이 원점이 되도록 정점들을 이동. 종이와 화면의 크기비율을 계산, (Px와 Cx, 또는 Py와 Cy의 비율 = E)각 정점 크기변환. Y좌표 뒤집기. 화면좌표계의 중점으로 각 정점을 이동. 행렬들을 풀어 계산하면 다음과 같다.OpenGL이나 D3D같은 그래픽 API를 이용할 때는 이 최종행렬을 설정하고 정점을 공급한다고 이해하면 된다.
  12. 정점의 축이 하나 더 늘어난 3D에서의 행렬은?2차원의 변환을 위해 3*3 행렬이 쓰인 것 처럼 3차원 변환을 위해서는 4*4 행렬을 사용. OpenGL의 경우 모델뷰, 프로젝션, 그리고 텍스쳐의 세가지 행렬모드가 존재D3D에는 여기에 추가로 카메라행렬도 있다. 모델뷰를 쪼개서 조금 더 관리를 편하게 하려고 만들어짐. 각 행렬 상태마다 스텍이 있어 원하는 행렬 상태를 저장했다 복원할 수 있음. OpenGL은 열기준 행렬을 사용합니다. 행렬곱이 행-열 이 아닌 열-행이라는 이야기.연산방향이 반대임을 기억하자.
  13. 벡터의 정의. 길이와 노멀(단위, 유닛)합과 차, 곱 (내적, 외적)의 성질
  14. OepnGL의 초기화. 목적은 랜더링컨텍스트를 얻는 것. DC가 윈도 프로그래머에게 장치를 추상화한 개념을 제공하듯 OpenGL 역시 RC라고 하는 추상화된 객체를 제공한다. 각 OS별로 RC를 얻기 위한 별개의 API셋을 제공. 윈도는 wgl… 계열의 위글 함수들을 제공.
  15. CW방향의 삼각형 그리기. 뷰, 프로젝션 행렬 설정. 기본값인 항등행렬을 사용. glBegin() ~ glEnd() 의 즉각모드 보여주고 장점 설명. 그려진 결과 분석. 화면 중심을 기준으로 -1 ~ 1 사이의 좌표를 보여준다는 것을 말하자. z축또한 동일한 결과임을 보여주자. 이 볼륨이 뷰볼륨이며3D란 공간상의 좌표를 가진 삼각형을 뷰볼륨으로 정규화하고 화면에 표시하는 것임을 다시 정리해준다. 정규화의 과정이 TnL, 화면에 표시되는 과정이 래스터라이징타이머를 올려 계속 갱신되도록 함. 윈도의 확대, 축소시 문제를 통해 뷰포트 개념 추가. glViewport() 사용으로 적절한 뷰포트 설정. 삼각형의 Z값이 뷰볼륨을 넘어가도록 해봄.
  16. 시야각45도, 근단면0.1, 원단면100짜리 원근투영행렬 설정. gluPerspective(). 결과는 안보임. 이 모델과 설정된 뷰프러스텀의 관계를 이미지로 보여주고 삼각형이 화면에 들어오려면 어떻게 해야하는지를 물음. 모델뷰행렬에 적절한 이동값을 설정. 화면에 표시한다. glTranslatef()참고로… gl함수는 gl과 glu가 있음. u가 붙은 것은 유틸리티 함수로 계산을 좀 더 편하게 해주는 용도. gluPerspective에 의해 설정된 행렬은 위쪽이 잘린 피라미드 형태의 도형에 맞추어 정점을 투영하는 행렬. glLoadMatrix() 등의 함수로 계산에 의해 직접 행렬값을 설정해도 마찬가지 결과가 됨.
  17. 스크롤바X, Y 이동에 따라 뷰 행렬이 3인칭으로 회전하도록 해보자. 삼각형은 현재 시간값에 따라 자전하도록 해보자. 각 정점에 적절한 색을 넣어본다. 화면컬링을 켜서 뒤집한 면이 안보이는 것도 보여줌. 
  18. OpenGL에 존재하는 편리한 행렬상태 저장도구인 스텍의 예를 보임. 회전하는 삼각형은 옆으로 적당히 옮기고 사각박스를 추가하자. 와이어프레임을 표시. 스케일 설정으로 사각박스가 꿈찔거리게 해봄. 
  19. 사각박스의 각 면색상을 변경. 화면을 돌려 삼각형과 겹쳐봄. 뭔가 그리기 순서가 이상하다는 것을 보임. z버퍼의 개념 설명. z버퍼를 켜서 마무리. 
  20. 광원모델에 직선광원, 스팟, 점광원을 설명한 뒤 이 세미나에서는 직선광원만 사용함을 알림. 직선 광원 추가. 꺼멓게 보임엠비언트, 디퓨즈 언급. 스파큘러는 있다는 얘기만 하자.앰비언트와디퓨즈를설정해보임. 모델그리기에노멀값 추가. 디퓨즈에 영향을 받는다는 것을 보임. 광원은 우클릭으로 이동하도록 해보자. 모델의 칼라가 광원과 섞일 수 있다는 것을 보임. glEnable(GL_COLOR_MATERIAL)
  21. OpenGL 객체에 대한 설명. GLUint로 대별되는 불투명객체. glGenTexture, glBindTexture, glDeleteTexture, glTex... Image2D, SubImage2D 등에 대해 설명. 이미지는 2의 승수여야 함을 알림. 32BIT DIB 비트맵의 메모리구조 설명. 이 ScanLine을 가져다 텍스쳐로 사용. 모델에 텍스쳐 좌표 추가. 삼각과 사각에 다른 텍스쳐 사용. 간단한 행렬 설정으로 적용된 텍스쳐가 움직이게 해봄. 
  22. 질문 및 토론 시간