computer graphics 1, spring 2005 may 2, 2005 global ... · computer graphics 1, spring 2005 may 2,...
TRANSCRIPT
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 1
Global Rendering and Hidden Surface Removal
������������ ������� ������
������� �
��������� ���������������� ��������
The rendering equation
� �� �! � ��������� ������"����� ���!# ������"������ "��"$��������������������
� ������ "� ��#%�� �������#
� &��$������ �"����� ���!�����!���#$��!#��� �����!����
� &��� �� �$ �������� �"����� ��� !�����!���#$ � !!������!����
Global effects of the rendering equation
translucent surface
shadow
multiple reflection
Local vs global rendering
������������ ����'� �����#�"�#��#��#�� �� �%�#% ���##�"(��������### �����������)������� "#�* ������ ��# ������#*� ��������������#$��� ����������#$+#���#������ ��,
�-�*�%��� �������������� �������� �##$���#�� ������� ���*��������$ !�� ���.#��/� ���0� �����1 �����$����� '���!�������1 ��� ���#�"�#�!!����
Light-material interaction
�� ���������� /�����"(��� ����� �##$�"���"��������� �##$���������+��!#�����,
� ����������!#����������� ��������#�����"� ��������!����"(���
� ����!#�����# ��� ���������� ��������������������������������������� ����� ���!������!���
Ambient light only
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 2
Diffuse light
2 !!������� �� �"����������� �� ��#��������# ���� �����
���!����!���"(���*����������#�"��*���������!��������#������%�����!������
�������� �������# ��� �#����
Source:www.2tothex.com/raytracing/
Camera light source: no shadows
Shadows
�����*����� ��#���������� ����$�������&�� �� � ������* !���$!��������� �������# ��������� ������������"(����
Source:www.2tothex.com/raytracing/
���� ���! �������� ���!���$�������"(�������#����$"�����#��#���� �����������#$� !!������� ���
Distant light source: parallel rays
Point light source: see shadows Spotlight: cone angle 30, high contrast
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 3
Spotlight - soft shadows Effect of distance - no attenuation
Effect of distance - attenuation
1/distance
Effect of distance – more attenuation
1/(distance)2
Global illumination
� 3�$���� ��
� 3�� �� �$
� )����������� �����$ �������
� �����44***���%��$����
� �����44***� �������
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 4
Ray tracing
�������������
��������� �� ���
)����� �$��#��#�� ���)5)#���# 6/� 7)��!#����� 6/� 7)������ ����
)��!#����� ���)������ ����
�����#��#���������� %�#$
��� ����������� �������8��&���#������
Advantages and disadvantagesAdvantages and disadvantages
� 3�$���� �� �������� %�"������
� �����*������!#��� ��������� #$ �����������
� 3�$���� �� ��1���� %�"������
� ��������!������ ����$��"(��� �������� ��� �%��$� ��
Reflections
3�!#��� ����������������� ����$���� ���)����## !����� ������� ���!# ���* �����!#��� %��"(�����������!�##�*��
���# ����������� ��������������������## ��* �����"������!!�"(����+���������$ ��"���"�����*������#���,
8�����������%�# �������$�
Ray tracing paths form a ray tree
Ra
A
DC
B
PRP
Ra
Rc
RbTa
Tc
Tc
Ta
Rc
Rd
Ra
Rb
A
BC
D
9������� %� 3�!������ 9� ��
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 5
Bounding volumesBounding volumes
� :��#����������!�"(���� ��� ��#�"���� ��%�#���+��������"�1,
� ���!�� �������� ����� ���"���� ��%�#���
� !�� �������� ���������$������� ���������"(����* �� ����"���� ��%�#���
� ! �������� �������������������� ��������"(��� �����
How do we subdivide space?How do we subdivide space?
� ;�� ��� ������� ���� � �� ��
� <� ##������� ��2� /��*���'�������
= ���� % ������� ���!������ ���
��������"���!�"(����
�������� ��
)!���� ������� �����"(������"� % ����� �
���� ���������� ! ��#�%�#�!��"� % � ��
OctreeOctree
&���������������������* ���������������#��%���!������������ � ��+����!�##$,����##���"���!�"(�����������$
� � ��'������� > �82�*���"� % ��
�����"� ���?����� ������� ����������
Ray tracing through octreeRay tracing through octree
<�����������$!�����"��� �� ����"��� �����#$���!��� �� �������� �������!��������##
���"���!�"(���� ������"��� ��
= �������� ������������ ��
������������ ��� �����$!�� �������� ���* ����$�"(�����
)!�����! �������1���� ��>
"$��#��#�� �� �������� ��* �������� ��"������ ���&�%����������*�$ �����1���� ��� ��$�� ������
= �������� ������ ��#���� ������ ������� ����
Finding region containing (x,y,z)Finding region containing (x,y,z)
<������������� ��#����������� ������� � �� ������������ ������������� ��#����������� ���*� ���!
���?+�!��'�������,��� ������������ ������� ���9��������*����������� ##��!������������
Binary space partitioningBinary space partitioning
� &��#������ %���������� �����# ��������� ����*�����������
� �������� ���#��� ��$� ��##$��������� % ���������� ������ ����!�'��#����#�1 �$
� @��*���A ���$�����9��� � �� ��+A�9,�����
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 6
Octrees vs BSP trees
� �������
� ����!��������*�������� �$�!�"(����%�� ��* ��#$
� ���� "#�����%����##�"(���� �#������� ���
� ����� ��!������ ������� ���#�*"�����������������"���"�#�����
� ���������
� ������!�������##"����������"�#�����
� �����$�����#�*��
� %� ���������##��
The POVRAY Teapot
Hidden surface removal/Visible surface determination
Hidden surface
We do not wish to see things that are hidden behind other objects
Two main types of HSR
� ;"(����������������
� <��/����"(���#�%�#������� ���"(����* �����������
� 9� ����B��#��� ���
� 2��������
� )����4� 1�#�������������
� <��/���� 1�##�%�#������� ��� 1�#%�#���
� ��"�!!���#��� ���
� 3�$����� ��4��$����� ��
Painter’s algorithmWorks like a painter
� �����##�"(���������� ������� �� ��� � ��
� 2��*���!��������"(���! ����������#�����#���+���� "#$������!������,
� ;"(���"����C���������"(����* �����������
� -����� ��#����� ��� ��# ��!��� ��
� D�/��'� �����$������
� <����*����������$��#$����� ���� ���!�#����������# �� �!���
+3����"��"�""#������!���"�� ��������EF,
Computer Graphics 1, Spring 2005 May 2, 2005
Ingela Nyström 7
z-buffer algorithmfill z-buffer with infinite distancefor all polygons
for each pixelcalculate z-value if z(x,y) is closer than z-buffer(x,y)
draw pixelz-buffer(x,y)=z(x,y)
endend
end
z-buffer algorithm
� When calculating the z-value you must interpolate q=1/z
to get a correct result from a perspective view
� Image/pixel space
� Easy to implement in a pipeline structure (hardware)
� Always correct result
Culling
COPn
v
v * n > 0
Back-face culling
� <�* ##��%��������0 �� ��0�!��# ��"(����C����� ��������������*���"��/� ����!���
!�����#$����
� <��������/ !*�������!����� ���!���#$���"$����/ �� !������#�"��*�����������#������%������� �� ����*��������"���%�� ����##������G��������
� &!���% �*�����!����� ������������� %�
� ����� ����� �� ��#$"�����������/�!���������� �����!��������#%�����