SlideShare a Scribd company logo
1 of 51
Download to read offline
Христо	ЛесевRaytracing - новият	helloworld
Raytracing – новият	helloworld
Христо	Лесев
DiaDraw.com
Христо	ЛесевRaytracing - новият	helloworld
$	whoami
Живее	и	диша компютърна графика.
DiaDraw
We help developers build cross-platform applications.
Христо	Лесев
Съосновател	на
Христо	ЛесевRaytracing - новият	helloworld
Raytracing 101
Христо	ЛесевRaytracing - новият	helloworld
Нужда	от	реалистични	изображения
Христо	ЛесевRaytracing - новият	helloworld
Филми,	архитектура,	реклами	и	още...
Христо	ЛесевRaytracing - новият	helloworld
Снимка или CG?
Христо	ЛесевRaytracing - новият	helloworld
Успяхте ли да ги разпознаете?
Photo Photo
Photo
CG
CG
CG
Христо	ЛесевRaytracing - новият	helloworld
Нужда	и	от	нереалистични	изображения
Христо	ЛесевRaytracing - новият	helloworld
Кой	и	как	генерира	изображения?
Христо	ЛесевRaytracing - новият	helloworld
Рендерът	превръща	описанието	на	геометрията	на	сцената	и	
нейните	свойства	в	изображение
Христо	ЛесевRaytracing - новият	helloworld
Как	се	случва	в	природата?
Христо	ЛесевRaytracing - новият	helloworld
Изстрелваме	лъчи	през	изображението
Христо	ЛесевRaytracing - новият	helloworld
Лъчите	определят,	какво	вижда	всеки	пиксел
Христо	ЛесевRaytracing - новият	helloworld
Намиране	на	пресечните	точки	на	лъч	с	обекти	от	сцената
• Избираме	най-близката	пресечна	точка	до	началото	на	лъча
1
2
3
Христо	ЛесевRaytracing - новият	helloworld
Избор	на	нова	посока	за	продължаване	на	пътя
• Посоката	на	новия	лъч	се	определя	от	материала	на	обекта
Христо	ЛесевRaytracing - новият	helloworld
Достигане	до	светлинен	източник
• Стремим	се	да	достигнем	до	обект,	зареден	със	светлинна	енергия
Христо	ЛесевRaytracing - новият	helloworld
“Бомбардираме”	сцената	с	лъчи
• Нужни	са	милиарди	лъчи,	за	генериране	на	красива	картинка
Христо	ЛесевRaytracing - новият	helloworld
Ще	споделя	една	история
Христо	ЛесевRaytracing - новият	helloworld
Далечната	92-ра
Христо	ЛесевRaytracing - новият	helloworld
Далечната	92-ра
Христо	ЛесевRaytracing - новият	helloworld
Начинаещ	програмист		или		
искам	да	науча	нова	технология:
От	къде	да	започна?
Христо	ЛесевRaytracing - новият	helloworld
Намираме	подходящ	пример	и	започваме	да	кодираме
Христо	ЛесевRaytracing - новият	helloworld
Класиката	в	tutorials жанра:
Програма за	поддръжка на	книжна библиотека
Христо	ЛесевRaytracing - новият	helloworld
Тайната	на	програмиста
Христо	ЛесевRaytracing - новият	helloworld
Изисквания:	или	от	какво	се	вълнува	библиотекарят
• Да	записва	и	изтрива	книга
• Да	търси	книги	по	заглавие,	автор,	ISBN….
• Нямам	никаква	представа	от	какво	друго	???
• Може	би	от	годишната	сбирка	на	библиотекарите?
Христо	ЛесевRaytracing - новият	helloworld
Изисквания:	от	какво	се	вълнува	програмистът
• Как	да	се	докосна	до	повече	аспекти	от	избраните	технологии?
• Как	да	си	построя	архитектурата?	Какви	ще	са	модулите?
• Как	ще	предавам	данни	между	отделните	модули?
• Трябва	ли	да	ползвам	DB ?
• Какъв	ще	е	интерфейсът	– web,	native,	console?
• Може	ли	да	е	разпределено,	многонишково,	и	т.н.	?
• И	други...
Христо	ЛесевRaytracing - новият	helloworld
или
Какво	е	по-лесно	да	си	направим?
Христо	ЛесевRaytracing - новият	helloworld
От	базовите	изисквания...
1. Двигател	с	витло	– придвижва	самолета	напред
2. “Крила”	– подемна	сила	и	управление
3. Колесник – за	да	има	второ	излитане
1
2
3
Христо	ЛесевRaytracing - новият	helloworld
...	до	комплексната	система
Христо	ЛесевRaytracing - новият	helloworld
Raytracer – самолетът	в	програмирането
100	реда	C++ ChaosGroup V-Ray
Христо	ЛесевRaytracing - новият	helloworld
Raytracing в	99	реда	C++	код
• smallpt – Kevin	Beason
• Сцена	изградена	изцяло	от	сфери
• Глобално	осветяване	!!!
• Три	вида	материали
– Дифузен
– Отражателен
– Прозрачен
Христо	ЛесевRaytracing - новият	helloworld
Raytracing в	99	реда	C++	код
Тримерен	вектор	и	цвятVec
Ray
Sphere
MAIN
intersect
radiance
Лъч
Геометричен	обект,	пресичане	с	лъч
Управление	на	сцена
Пресмятане	на	глобалното	осветяване
Христо	ЛесевRaytracing - новият	helloworld
Първото	нещо,	което	трябва	да	си	припомним
Христо	ЛесевRaytracing - новият	helloworld
Безкрайните	часове	математика	в	университета
• Вектори
• Матрици
• Цветова	алгебра	– цветови	пространства
• Геометрия
• Статистика
• Числени	методи
• Дискретна	математика
Христо	ЛесевRaytracing - новият	helloworld
“Клиентски”	изисквания	към	raytracer-a
1. Да	поддържа	голям	набор	от	обекти	и	материали
2. Да	бъде	бърз
Христо	ЛесевRaytracing - новият	helloworld
1.	Голям	набор	от	обекти	и	
материали
Христо	ЛесевRaytracing - новият	helloworld
Голям	набор	от	обекти	и	материали
• Прилична	софтуерна	архитектура
• Изграждане	на	йерархия
• Понятие	за	сцена
• Парсър на	сцена
• Разделяне	на	алгоритъма	от	данните
• Плъгини
Geometry
Sphere Triangle	Mesh
Material
BRDF
Христо	ЛесевRaytracing - новият	helloworld
2.	Скорост
Христо	ЛесевRaytracing - новият	helloworld
Ускорителни	структури
• Геометрични	бази	от	данни
• Търсене	в	пространството,	заявки:
– Intersect
– Range	search
• Идват	във	всякакви	разновидности:
– Kd-tree,	BVH,	Octree,	BSP,	Grid,	…....
Христо	ЛесевRaytracing - новият	helloworld
Още	скорост...
Христо	ЛесевRaytracing - новият	helloworld
Паралелно	трасиране	с	“нишки”	
• Raytracing– синоним	за	
паралелен	алгоритъм
• Всяка	“нишка”	работи	с	данните	
на	сцената,	но	пресмята	
резултати	от	различни	лъчи
Христо	ЛесевRaytracing - новият	helloworld
Още	повече	скорост...
Христо	ЛесевRaytracing - новият	helloworld
Пресмятане	на	части	от	картинката	на	други	машини
• Мрежова	комуникация
• Предаване	на	сцената	и	ресурси
• Връщане	на	част	от	изображението
• Сглобяване	на	цялото	изображение
Христо	ЛесевRaytracing - новият	helloworld
Practice	what	you	preach
Христо	ЛесевRaytracing - новият	helloworld
Пример	1
Христо	ЛесевRaytracing - новият	helloworld
Пример	1:	Node.js +	C++
smallpt.cpp
Web					Sockets
Web	browser
Async callback
Христо	ЛесевRaytracing - новият	helloworld
Пример	2
Христо	ЛесевRaytracing - новият	helloworld
Пример	2:	js raytracing,	изцяло	в	браузър
worker
Web	browser
worker worker
raytracer
scene
raytracer
scene
raytracer
scene
Христо	ЛесевRaytracing - новият	helloworld
Пример	3
http://diadraw-rt.herokuapp.com
Христо	ЛесевRaytracing - новият	helloworld
Пример 3:	разпределен	raytracing
Web	browser
Monitor
Web	browser
Render	node
w w w w w
Web	browser
Render	node
w w w w w
Web	browser
Render	node
w w w w w
WebSockets
WebSo ckets
Христо	ЛесевRaytracing - новият	helloworld
Demos’	Repo
https://github.com/hlesev?tab=repositories

More Related Content

Featured

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
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

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
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Raytracing - the new helloworld