├── .gitignore
├── .travis.yml
├── Build
├── DirectX.props
├── DirectXMesh.props
├── VS2012
│ ├── Tootle.sln
│ ├── TootleLib.vcxproj
│ ├── TootleLib.vcxproj.filters
│ ├── TootleLibSoftware.vcxproj
│ ├── TootleLibSoftware.vcxproj.filters
│ ├── TootleSample.vcxproj
│ ├── TootleSample.vcxproj.filters
│ ├── TootleSampleSoftware.vcxproj
│ └── TootleSampleSoftware.vcxproj.filters
├── VS2013
│ ├── Tootle.sln
│ ├── TootleLib.vcxproj
│ ├── TootleLib.vcxproj.filters
│ ├── TootleLibSoftware.vcxproj
│ ├── TootleLibSoftware.vcxproj.filters
│ ├── TootleSample.vcxproj
│ ├── TootleSample.vcxproj.filters
│ ├── TootleSampleSoftware.vcxproj
│ └── TootleSampleSoftware.vcxproj.filters
├── VS2015 - DX11_1
│ ├── Tootle.sln
│ ├── TootleLib.vcxproj
│ ├── TootleLib.vcxproj.filters
│ ├── TootleSample_DX11_1.vcxproj
│ └── TootleSample_DX11_1.vcxproj.filters
└── VS2015
│ ├── Tootle.sln
│ ├── TootleLib.vcxproj
│ ├── TootleLib.vcxproj.filters
│ ├── TootleLibSoftware.vcxproj
│ ├── TootleLibSoftware.vcxproj.filters
│ ├── TootleSample.vcxproj
│ ├── TootleSample.vcxproj.filters
│ ├── TootleSampleSoftware.vcxproj
│ └── TootleSampleSoftware.vcxproj.filters
├── LICENSE
├── README.md
├── Scripts
└── FetchDependencies.py
├── appveyor.yml
├── bin
└── runTest.bat
├── docs
├── tootle-i3d2006-paper.pdf
├── tootle-i3d2006-talk.pdf
├── tootle2-siggraph2007-paper.pdf
└── tootle2-siggraph2007-talk.pdf
├── lib
└── EMPTY.txt
├── meshes
├── Torus2.obj
├── bolt.obj
├── bolt2.obj
├── bunny.obj
├── cactus.obj
└── fandisk.obj
└── src
├── CMakeLists.txt
├── TootleLib
├── CMakeLists.txt
├── RayTracer
│ ├── JRT
│ │ ├── JRTBoundingBox.cpp
│ │ ├── JRTBoundingBox.h
│ │ ├── JRTCamera.cpp
│ │ ├── JRTCamera.h
│ │ ├── JRTCommon.h
│ │ ├── JRTCore.cpp
│ │ ├── JRTCore.h
│ │ ├── JRTCoreUtils.cpp
│ │ ├── JRTCoreUtils.h
│ │ ├── JRTH2KDTreeBuilder.cpp
│ │ ├── JRTH2KDTreeBuilder.h
│ │ ├── JRTHeuristicKDTreeBuilder.cpp
│ │ ├── JRTHeuristicKDTreeBuilder.h
│ │ ├── JRTKDTree.cpp
│ │ ├── JRTKDTree.h
│ │ ├── JRTKDTreeBuilder.cpp
│ │ ├── JRTKDTreeBuilder.h
│ │ ├── JRTMesh.cpp
│ │ ├── JRTMesh.h
│ │ ├── JRTOrthoCamera.cpp
│ │ ├── JRTOrthoCamera.h
│ │ ├── JRTPPMImage.cpp
│ │ ├── JRTPPMImage.h
│ │ ├── JRTTriangleIntersection.cpp
│ │ └── JRTTriangleIntersection.h
│ ├── Math
│ │ ├── JML.h
│ │ ├── JMLFuncs.cpp
│ │ ├── JMLFuncs.h
│ │ ├── JMLMatrix.h
│ │ ├── JMLSSEVec.h
│ │ ├── JMLScalar.h
│ │ ├── JMLVec2.h
│ │ └── JMLVec3.h
│ ├── TootleRaytracer.cpp
│ ├── TootleRaytracer.h
│ └── makefile
├── Stripifier.cpp
├── Stripifier.h
├── Timer.cpp
├── Timer.h
├── TootlePCH.h
├── aligned_malloc.cpp
├── aligned_malloc.h
├── bbox.h
├── cloud.h
├── clustering.cpp
├── clustering.h
├── color.h
├── d3doverdrawwindow.cpp
├── d3doverdrawwindow.h
├── d3dwindow.h
├── d3dwm.cpp
├── d3dwm.h
├── error.c
├── error.h
├── feedback.cpp
├── feedback.h
├── fit.cpp
├── fit.h
├── gdiwindow.h
├── gdiwm.cpp
├── gdiwm.h
├── heap.c
├── heap.h
├── include
│ └── tootlelib.h
├── makefile
├── matrix.h
├── mesh.h
├── option.h
├── overdraw.cpp
├── overdraw.h
├── quaternion.h
├── scalar.h
├── soup.cpp
├── soup.h
├── souptomesh.cpp
├── souptomesh.h
├── tootlelib.cpp
├── triorder.cpp
├── triorder.h
├── vector.h
├── viewpoints.h
└── window.h
└── TootleSample
├── CMakeLists.txt
├── MaterialSort.cpp
├── ObjLoader.cpp
├── ObjLoader.h
├── Timer.cpp
├── Timer.h
├── Tootle.cpp
├── makefile
└── option.h
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 | *.VC.opendb
10 |
11 | # User-specific files (MonoDevelop/Xamarin Studio)
12 | *.userprefs
13 |
14 | # Build results
15 | [Dd]ebug/
16 | [Dd]ebugPublic/
17 | [Rr]elease/
18 | [Rr]eleases/
19 | x64/
20 | x86/
21 | bld/
22 | [Bb]in/*
23 | !bin/runTest.bat
24 | [Oo]bj/
25 | lib/*
26 | !lib/EMPTY.txt
27 |
28 | # Visual Studo 2015 cache/options directory
29 | .vs/
30 | *.VC.db
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | !meshes/*.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.tmp_proj
63 | *.log
64 | *.vspscc
65 | *.vssscc
66 | .builds
67 | *.pidb
68 | *.svclog
69 | *.scc
70 |
71 | # Chutzpah Test files
72 | _Chutzpah*
73 |
74 | # Visual C++ cache files
75 | ipch/
76 | *.aps
77 | *.ncb
78 | *.opensdf
79 | *.sdf
80 | *.cachefile
81 |
82 | # Visual Studio profiler
83 | *.psess
84 | *.vsp
85 | *.vspx
86 |
87 | # TFS 2012 Local Workspace
88 | $tf/
89 |
90 | # Guidance Automation Toolkit
91 | *.gpState
92 |
93 | # ReSharper is a .NET coding add-in
94 | _ReSharper*/
95 | *.[Rr]e[Ss]harper
96 | *.DotSettings.user
97 |
98 | # JustCode is a .NET coding addin-in
99 | .JustCode
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | _NCrunch_*
109 | .*crunch*.local.xml
110 |
111 | # MightyMoose
112 | *.mm.*
113 | AutoTest.Net/
114 |
115 | # Web workbench (sass)
116 | .sass-cache/
117 |
118 | # Installshield output folder
119 | [Ee]xpress/
120 |
121 | # DocProject is a documentation generator add-in
122 | DocProject/buildhelp/
123 | DocProject/Help/*.HxT
124 | DocProject/Help/*.HxC
125 | DocProject/Help/*.hhc
126 | DocProject/Help/*.hhk
127 | DocProject/Help/*.hhp
128 | DocProject/Help/Html2
129 | DocProject/Help/html
130 |
131 | # Click-Once directory
132 | publish/
133 |
134 | # Publish Web Output
135 | *.[Pp]ublish.xml
136 | *.azurePubxml
137 | # TODO: Comment the next line if you want to checkin your web deploy settings
138 | # but database connection strings (with potential passwords) will be unencrypted
139 | *.pubxml
140 | *.publishproj
141 |
142 | # NuGet Packages
143 | *.nupkg
144 | # The packages folder can be ignored because of Package Restore
145 | **/packages/*
146 | # except build/, which is used as an MSBuild target.
147 | !**/packages/build/
148 | # Uncomment if necessary however generally it will be regenerated when needed
149 | #!**/packages/repositories.config
150 |
151 | # Windows Azure Build Output
152 | csx/
153 | *.build.csdef
154 |
155 | # Windows Store app package directory
156 | AppPackages/
157 |
158 | # Others
159 | *.[Cc]ache
160 | ClientBin/
161 | [Ss]tyle[Cc]op.*
162 | ~$*
163 | *~
164 | *.dbmdl
165 | *.dbproj.schemaview
166 | *.pfx
167 | *.publishsettings
168 | node_modules/
169 | bower_components/
170 |
171 | # RIA/Silverlight projects
172 | Generated_Code/
173 |
174 | # Backup & report files from converting an old project file
175 | # to a newer Visual Studio version. Backup files are not needed,
176 | # because we have git ;-)
177 | _UpgradeReport_Files/
178 | Backup*/
179 | UpgradeLog*.XML
180 | UpgradeLog*.htm
181 |
182 | # SQL Server files
183 | *.mdf
184 | *.ldf
185 |
186 | # Business Intelligence projects
187 | *.rdl.data
188 | *.bim.layout
189 | *.bim_*.settings
190 |
191 | # Microsoft Fakes
192 | FakesAssemblies/
193 |
194 | # Node.js Tools for Visual Studio
195 | .ntvs_analysis.dat
196 |
197 | # Visual Studio 6 build log
198 | *.plg
199 |
200 | # Visual Studio 6 workspace options file
201 | *.opt
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | os:
4 | - linux
5 |
6 | before_install:
7 | - sudo add-apt-repository ppa:george-edison55/precise-backports --yes
8 | - sudo apt-get remove -qq cmake cmake-data
9 | - sudo apt-get update -y -qq
10 | - sudo apt-get install cmake cmake-data
11 |
12 | compiler:
13 | - gcc
14 | - clang
15 |
16 | env:
17 | - CONFIGURATION=Debug
18 | - CONFIGURATION=Release
19 |
20 | script:
21 | - mkdir build
22 | - cd build
23 | - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ../src
24 | - make
25 |
--------------------------------------------------------------------------------
/Build/DirectX.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\
5 |
6 |
7 | <_ProjectFileVersion>10.0.30319.1
8 |
9 |
10 |
11 | $(DirectXSDKDir)Include;%(AdditionalIncludeDirectories)
12 |
13 |
14 | d3d9.lib;d3dx9.lib;%(AdditionalDependencies)
15 |
16 |
17 |
18 |
19 | $(DirectXSDKDir)Lib\x86\;%(AdditionalLibraryDirectories)
20 |
21 |
22 |
23 |
24 | $(DirectXSDKDir)Lib\x64\;%(AdditionalLibraryDirectories)
25 |
26 |
27 |
28 |
29 | $(DirectXSDKDir)
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Build/DirectXMesh.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ..\..\..\DirectXMesh\DirectXMesh\
5 |
6 |
7 | <_ProjectFileVersion>10.0.30319.1
8 |
9 |
10 |
11 | $(DirectXMesh);%(AdditionalIncludeDirectories)
12 |
13 |
14 | DirectXMesh.lib;%(AdditionalDependencies)
15 |
16 |
17 |
18 |
19 | $(DirectXMesh)Bin\Desktop_2015_Win10\$(Platform)\Debug\;%(AdditionalLibraryDirectories)
20 |
21 |
22 |
23 |
24 | $(DirectXMesh)Bin\Desktop_2015_Win10\$(Platform)\Release\;%(AdditionalLibraryDirectories)
25 |
26 |
27 |
28 |
29 | $(DirectXMesh)
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Build/VS2012/TootleSample.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files
30 |
31 |
32 | Header Files
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Build/VS2012/TootleSampleSoftware.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Build/VS2013/TootleSample.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files
30 |
31 |
32 | Header Files
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Build/VS2013/TootleSampleSoftware.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Build/VS2015 - DX11_1/Tootle.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TootleLib", "TootleLib.vcxproj", "{F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TootleSample", "TootleSample_DX11_1.vcxproj", "{0F3108B0-4779-4640-8891-1A1E1200A84E}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "..\..\..\DirectXMesh\DirectXMesh\DirectXMesh_Desktop_2015_Win10.vcxproj", "{6857F086-F6FE-4150-9ED7-7446F1C1C220}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug_Static_MTDLL|Win32 = Debug_Static_MTDLL|Win32
15 | Debug_Static_MTDLL|x64 = Debug_Static_MTDLL|x64
16 | Debug|Win32 = Debug|Win32
17 | Debug|x64 = Debug|x64
18 | Profile|Win32 = Profile|Win32
19 | Profile|x64 = Profile|x64
20 | Release_Static_MTDLL|Win32 = Release_Static_MTDLL|Win32
21 | Release_Static_MTDLL|x64 = Release_Static_MTDLL|x64
22 | Release|Win32 = Release|Win32
23 | Release|x64 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug_Static_MTDLL|Win32.ActiveCfg = Debug_Static_MTDLL|Win32
27 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug_Static_MTDLL|Win32.Build.0 = Debug_Static_MTDLL|Win32
28 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug_Static_MTDLL|x64.ActiveCfg = Debug_Static_MTDLL|x64
29 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug_Static_MTDLL|x64.Build.0 = Debug_Static_MTDLL|x64
30 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug|Win32.ActiveCfg = Debug_Static_MTDLL|Win32
31 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug|Win32.Build.0 = Debug_Static_MTDLL|Win32
32 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug|x64.ActiveCfg = Debug_Static_MTDLL|x64
33 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Debug|x64.Build.0 = Debug_Static_MTDLL|x64
34 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Profile|Win32.ActiveCfg = Release_Static_MTDLL|Win32
35 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Profile|Win32.Build.0 = Release_Static_MTDLL|Win32
36 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Profile|x64.ActiveCfg = Release_Static_MTDLL|x64
37 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Profile|x64.Build.0 = Release_Static_MTDLL|x64
38 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release_Static_MTDLL|Win32.ActiveCfg = Release_Static_MTDLL|Win32
39 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release_Static_MTDLL|Win32.Build.0 = Release_Static_MTDLL|Win32
40 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release_Static_MTDLL|x64.ActiveCfg = Release_Static_MTDLL|x64
41 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release_Static_MTDLL|x64.Build.0 = Release_Static_MTDLL|x64
42 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release|Win32.ActiveCfg = Release_Static_MTDLL|Win32
43 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release|Win32.Build.0 = Release_Static_MTDLL|Win32
44 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release|x64.ActiveCfg = Release_Static_MTDLL|x64
45 | {F211DAFB-4BD4-4E13-B4FD-9D431D84F4C8}.Release|x64.Build.0 = Release_Static_MTDLL|x64
46 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug_Static_MTDLL|Win32.ActiveCfg = Debug_Static_MTDLL|Win32
47 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug_Static_MTDLL|Win32.Build.0 = Debug_Static_MTDLL|Win32
48 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug_Static_MTDLL|x64.ActiveCfg = Debug_Static_MTDLL|x64
49 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug_Static_MTDLL|x64.Build.0 = Debug_Static_MTDLL|x64
50 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug|Win32.ActiveCfg = Debug_Static_MTDLL|Win32
51 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug|Win32.Build.0 = Debug_Static_MTDLL|Win32
52 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug|x64.ActiveCfg = Debug_Static_MTDLL|x64
53 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Debug|x64.Build.0 = Debug_Static_MTDLL|x64
54 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Profile|Win32.ActiveCfg = Release_Static_MTDLL|Win32
55 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Profile|Win32.Build.0 = Release_Static_MTDLL|Win32
56 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Profile|x64.ActiveCfg = Release_Static_MTDLL|x64
57 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Profile|x64.Build.0 = Release_Static_MTDLL|x64
58 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release_Static_MTDLL|Win32.ActiveCfg = Release_Static_MTDLL|Win32
59 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release_Static_MTDLL|Win32.Build.0 = Release_Static_MTDLL|Win32
60 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release_Static_MTDLL|x64.ActiveCfg = Release_Static_MTDLL|x64
61 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release_Static_MTDLL|x64.Build.0 = Release_Static_MTDLL|x64
62 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release|Win32.ActiveCfg = Release_Static_MTDLL|Win32
63 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release|Win32.Build.0 = Release_Static_MTDLL|Win32
64 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release|x64.ActiveCfg = Release_Static_MTDLL|x64
65 | {0F3108B0-4779-4640-8891-1A1E1200A84E}.Release|x64.Build.0 = Release_Static_MTDLL|x64
66 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug_Static_MTDLL|Win32.ActiveCfg = Debug|Win32
67 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug_Static_MTDLL|Win32.Build.0 = Debug|Win32
68 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug_Static_MTDLL|x64.ActiveCfg = Debug|x64
69 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug_Static_MTDLL|x64.Build.0 = Debug|x64
70 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|Win32.ActiveCfg = Debug|Win32
71 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|Win32.Build.0 = Debug|Win32
72 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.ActiveCfg = Debug|x64
73 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.Build.0 = Debug|x64
74 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|Win32.ActiveCfg = Profile|Win32
75 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|Win32.Build.0 = Profile|Win32
76 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.ActiveCfg = Profile|x64
77 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.Build.0 = Profile|x64
78 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release_Static_MTDLL|Win32.ActiveCfg = Release|Win32
79 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release_Static_MTDLL|Win32.Build.0 = Release|Win32
80 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release_Static_MTDLL|x64.ActiveCfg = Release|x64
81 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release_Static_MTDLL|x64.Build.0 = Release|x64
82 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|Win32.ActiveCfg = Release|Win32
83 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|Win32.Build.0 = Release|Win32
84 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.ActiveCfg = Release|x64
85 | {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.Build.0 = Release|x64
86 | EndGlobalSection
87 | GlobalSection(SolutionProperties) = preSolution
88 | HideSolutionNode = FALSE
89 | EndGlobalSection
90 | EndGlobal
91 |
--------------------------------------------------------------------------------
/Build/VS2015 - DX11_1/TootleSample_DX11_1.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug_Static_MTDLL
6 | Win32
7 |
8 |
9 | Release_Static_MTDLL
10 | Win32
11 |
12 |
13 | Debug_Static_MTDLL
14 | x64
15 |
16 |
17 | Release_Static_MTDLL
18 | x64
19 |
20 |
21 |
22 | TootleSample
23 | {0F3108B0-4779-4640-8891-1A1E1200A84E}
24 | TootleSample
25 | Win32Proj
26 |
27 |
28 |
29 | Application
30 | v140
31 | MultiByte
32 |
33 |
34 |
35 |
36 |
37 |
38 | $(ProjectName)
39 | ..\..\bin\
40 | obj\$(ProjectName)\$(Configuration)-$(Platform)\
41 |
42 |
43 |
44 | ..\..\src\TootleLib\include;%(AdditionalIncludeDirectories)
45 | Level3
46 | true
47 |
48 |
49 | false
50 |
51 |
52 | $(OutDir)$(TargetName)$(TargetExt)
53 | ..\..\lib;%(AdditionalLibraryDirectories)
54 | Console
55 | true
56 | $(OutDir)$(TargetName).pdb
57 | true
58 |
59 |
60 |
61 |
62 | Disabled
63 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
64 | MultiThreadedDebugDLL
65 |
66 |
67 | TootleStatic_2015_DX11_1_MTDLL_d.lib;%(AdditionalDependencies)
68 | MachineX86
69 | false
70 |
71 |
72 |
73 |
74 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
75 | MultiThreadedDLL
76 |
77 |
78 | TootleStatic_2015_DX11_1_MTDLL.lib;%(AdditionalDependencies)
79 | MachineX86
80 |
81 |
82 |
83 |
84 | Disabled
85 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
86 | MultiThreadedDebugDLL
87 |
88 |
89 | TootleStatic_2015_DX11_1_MTDLL_d64.lib;%(AdditionalDependencies)
90 | MachineX64
91 |
92 |
93 |
94 |
95 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
96 | MultiThreadedDLL
97 |
98 |
99 | TootleStatic_2015_DX11_1_MTDLL_64.lib;%(AdditionalDependencies)
100 | MachineX64
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | {f211dafb-4bd4-4e13-b4fd-9d431d84f4c8}
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/Build/VS2015 - DX11_1/TootleSample_DX11_1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files
30 |
31 |
32 | Header Files
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Build/VS2015/TootleSample.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 |
28 |
29 | Header Files
30 |
31 |
32 | Header Files
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Build/VS2015/TootleSampleSoftware.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tootle retirement
2 |
3 | amd-tootle is no longer being actively developed or supported by AMD and is being archived.
4 |
5 | # amd-tootle [](https://ci.appveyor.com/project/bpurnomo/amd-tootle) [](https://travis-ci.org/GPUOpen-Tools/amd-tootle) [](LICENSE)
6 | The amd-tootle repository includes the source code of the AMD Tootle library and an application command line tool.
7 |
8 | AMD Tootle (Triangle Order Optimization Tool) is a 3D triangle mesh optimization library that improves on existing mesh preprocessing techniques. By using AMD Tootle, developers can optimize their models for pixel overdraw as well as vertex cache performance. This can provide significant performance improvements in pixel limited situations, with no penalty in vertex-limited scenarios, and no runtime cost.
9 |
10 | # AMD Tootle Features
11 | 1. **Vertex cache optimization**: Triangles are re-ordered to optimize for the post-transform vertex cache in modern GPUs. This will yield significant performance improvements in vertex-tranform limited scenes.
12 | 2. **Overdraw optimization**: To reduce the pixel cost of rendering a mesh, the AMD Tootle library further re-orders the triangles in the mesh to reduce pixel overdraw. Significant reductions in pixel overdraw (2x or higher) can be achieved. This can yield significant performance improvements in pixel-limited scenes, and incurs no penalty in vertex-limited scenarios.
13 | 3. **Vertex prefetch cache optimization**: Triangle indices are re-indexed in the order of their occurrence in the triangle list. The vertex buffer is re-ordered to match these new indices. Thus, vertices are accessed close to each other in memory. This optimization exploits the input vertex cache because vertices are typically fetched in a cacheline (that may contains more than one vertex data).
14 |
15 | AMD Tootle supports Microsoft Windows and Linux platform.
16 |
17 | # Package Contents
18 | The amd-tootle package has the following directory structure.
19 | - *bin*: the location for the output AMD Tootle executable and DLL files
20 | - *Build*
21 | - *VS2012*: contains the AMD Tootle solution and project files for Microsoft Visual Studio 2012
22 | - *VS2013*: contains the AMD Tootle solution and project files for Microsoft Visual Studio 2013
23 | - *VS2015*: contains the AMD Tootle solution and project files for Microsoft Visual Studio 2015
24 | - *VS2015 - DX 11.1*: contains the AMD Tootle solution and project files for Microsoft Visual Studio 2015 without DirectX SDK June 2010 dependency (requires DirectXMesh project)
25 | - *DirectX.props*: the Visual Studio property file that points to the location of Microsoft DirectX SDK in the system
26 | * Update this file to point to the location of the Microsoft DirectX SDK in your system (the current support is for Microsoft DirectX SDK June 2010)
27 | - *docs*: contains tootle papers and presentations
28 | - *lib*: the location for the output AMD Tootle static library and import files
29 | - *meshes*: contains several sample meshes
30 | - *src*
31 | - *TootleLib*: contains the source code of the AMD Tootle library that can be linked to your mesh processing pipeline. There are multiple different build targets supported.
32 | - *include/tootlelib.h*: the AMD Tootle library header file
33 | - *TootleSample*: contains the source code of a sample application that reads a single material triangle mesh file *.obj* and exposes the functionality of the AMD Tootle library using a command line interface.
34 |
35 | # Build and Run Steps
36 | 1. Set up Microsoft DirectX SDK dependency (the current support is for Microsoft DirectX SDK June 2010)
37 | * [Install DirectX SDK June 2010](https://www.microsoft.com/en-us/download/details.aspx?id=6812). **To skip this step for Windows 8 and later versions, use VS2015 - DX_11.1 solution file.**
38 | 2. Clone the amd-tootle repository
39 | * `git clone https://github.com/GPUOpen-Tools/amd-tootle.git`
40 | 3. Build the AMD Tootle library and command line tool
41 | * On Windows
42 | * Open *Build/VS2015/Tootle.sln* if working with Microsoft Visual Studio 2015.
43 | * If you want to build without DirectX SDK June 2010, then
44 | * Run `python Scripts/FetchDependencies.py`
45 | * Open *Build/VS2015 - DX11_1/Tootle.sln* instead
46 | * Select the appropriate build target for AMD Tootle within Microsoft Visual Studio
47 | * Build all the projects
48 | * The output files will be generated in the *bin* and *lib* folder
49 | * A *runTest.bat* batch file is provided in the *bin* folder as an example for running the Tootle command line tool (*TootleSample.exe*)
50 | * On a Windows console window, you can run *TootleSample.exe* without any command line arguments to print the instruction for running the tool
51 | * On Linux
52 | * Build the AMD Tootle library
53 | * `cd src/TootleLib`
54 | * `make`
55 | * Build the AMD Tootle command line tool
56 | * `cd ../TootleSample`
57 | * `make`
58 | * Run the AMD Tootle command line tool
59 | * `cd ../../bin`
60 | * `./TootleSample -a 5 ../meshes/bolt.obj > out.obj`
61 | * You can run `./TootleSample` without any command line arguments to print the instruction for running the tool
62 |
63 | # References
64 | 1. Nehab, D. Barczak, J. Sander, P.V. 2006. Triangle Order Optimization for graphics hardware computation culling. In Proceedings of the ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games, pages 207-211
65 | 2. Sander, P.V., Nehab, D. Barczak, J. 2007. Fast Triangle Reordering for Vertex Locality and Reduced Overdraw. ACM Transactions of Graphics (Proc. SIGGRAPH), 26(3), August 2007.
66 |
--------------------------------------------------------------------------------
/Scripts/FetchDependencies.py:
--------------------------------------------------------------------------------
1 | #!python
2 | import os
3 | import string
4 | import subprocess
5 |
6 | # to allow the script to be run from anywhere - not just the cwd - store the absolute path to the script file
7 | scriptRoot = os.path.dirname(os.path.realpath(__file__))
8 |
9 | # Update or clone a project folder
10 | def gitclone(gitPath, tagValue, targetRelativePath):
11 | # convert projectValue to OS specific format
12 | tmppath = os.path.join(scriptRoot, targetRelativePath)
13 | # clean up path, collapsing any ../ and converting / to \ for Windows
14 | targetPath = os.path.normpath(tmppath)
15 | print("\n\nProcessing project %s"%targetPath)
16 | if os.path.isdir(targetPath):
17 | print("\nDirectory " + targetPath + " exists")
18 | else:
19 | print("\nDirectory " + targetPath + " does not exist, using 'git clone' to get latest based on tag %s"%tagValue)
20 | commandArgs = ["git", "clone", gitPath, targetPath]
21 | p = subprocess.Popen( commandArgs )
22 | p.wait()
23 | p = subprocess.Popen(["git", "checkout", "tags/" + tagValue], cwd=targetPath)
24 | p.wait();
25 |
26 | if __name__ == "__main__":
27 |
28 | gitclone("https://github.com/Microsoft/DirectXMesh.git", "apr2017", "../../DirectXMesh")
29 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | environment:
2 | matrix:
3 | - GENERATOR: "Visual Studio 11 2012"
4 | CONFIG: Debug
5 |
6 | - GENERATOR: "Visual Studio 11 2012"
7 | CONFIG: Release
8 |
9 | - GENERATOR: "Visual Studio 11 2012 Win64"
10 | CONFIG: Debug
11 |
12 | - GENERATOR: "Visual Studio 11 2012 Win64"
13 | CONFIG: Release
14 |
15 | - GENERATOR: "Visual Studio 12 2013"
16 | CONFIG: Debug
17 |
18 | - GENERATOR: "Visual Studio 12 2013"
19 | CONFIG: Release
20 |
21 | - GENERATOR: "Visual Studio 12 2013 Win64"
22 | CONFIG: Debug
23 |
24 | - GENERATOR: "Visual Studio 12 2013 Win64"
25 | CONFIG: Release
26 |
27 | - GENERATOR: "Visual Studio 14 2015"
28 | CONFIG: Debug
29 |
30 | - GENERATOR: "Visual Studio 14 2015"
31 | CONFIG: Release
32 |
33 | - GENERATOR: "Visual Studio 14 2015 Win64"
34 | CONFIG: Debug
35 |
36 | - GENERATOR: "Visual Studio 14 2015 Win64"
37 | CONFIG: Release
38 |
39 | build_script:
40 | - mkdir _cibuild
41 | - cd _cibuild
42 | - cmake "-G%GENERATOR%" ../src
43 | - cmake --build . --config "%CONFIG%"
44 |
--------------------------------------------------------------------------------
/bin/runTest.bat:
--------------------------------------------------------------------------------
1 | TootleSample.exe -a 5 ..\meshes\bolt.obj > out.obj
2 |
3 | PAUSE
4 |
--------------------------------------------------------------------------------
/docs/tootle-i3d2006-paper.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GPUOpen-Archive/amd_tootle/74cbd6b33e75ef90a9c395772850992ef29cd7fe/docs/tootle-i3d2006-paper.pdf
--------------------------------------------------------------------------------
/docs/tootle-i3d2006-talk.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GPUOpen-Archive/amd_tootle/74cbd6b33e75ef90a9c395772850992ef29cd7fe/docs/tootle-i3d2006-talk.pdf
--------------------------------------------------------------------------------
/docs/tootle2-siggraph2007-paper.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GPUOpen-Archive/amd_tootle/74cbd6b33e75ef90a9c395772850992ef29cd7fe/docs/tootle2-siggraph2007-paper.pdf
--------------------------------------------------------------------------------
/docs/tootle2-siggraph2007-talk.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GPUOpen-Archive/amd_tootle/74cbd6b33e75ef90a9c395772850992ef29cd7fe/docs/tootle2-siggraph2007-talk.pdf
--------------------------------------------------------------------------------
/lib/EMPTY.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GPUOpen-Archive/amd_tootle/74cbd6b33e75ef90a9c395772850992ef29cd7fe/lib/EMPTY.txt
--------------------------------------------------------------------------------
/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
2 | PROJECT(AMD_TOOTLE)
3 | SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
4 | ENABLE_TESTING()
5 |
6 | ADD_SUBDIRECTORY(TootleLib)
7 | ADD_SUBDIRECTORY(TootleSample)
8 |
--------------------------------------------------------------------------------
/src/TootleLib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | PROJECT(TootleLib)
2 |
3 | SET(SOURCES
4 | aligned_malloc.cpp
5 | clustering.cpp
6 | error.c
7 | feedback.cpp
8 | fit.cpp
9 | heap.c
10 | overdraw.cpp
11 | soup.cpp
12 | souptomesh.cpp
13 | Stripifier.cpp
14 | Timer.cpp
15 | tootlelib.cpp
16 | triorder.cpp
17 |
18 | RayTracer/TootleRaytracer.cpp
19 | RayTracer/JRT/JRTBoundingBox.cpp
20 | RayTracer/JRT/JRTCamera.cpp
21 | RayTracer/JRT/JRTCore.cpp
22 | RayTracer/JRT/JRTCoreUtils.cpp
23 | RayTracer/JRT/JRTH2KDTreeBuilder.cpp
24 | RayTracer/JRT/JRTHeuristicKDTreeBuilder.cpp
25 | RayTracer/JRT/JRTKDTree.cpp
26 | RayTracer/JRT/JRTKDTreeBuilder.cpp
27 | RayTracer/JRT/JRTMesh.cpp
28 | RayTracer/JRT/JRTOrthoCamera.cpp
29 | RayTracer/JRT/JRTPPMImage.cpp
30 | RayTracer/JRT/JRTTriangleIntersection.cpp
31 | RayTracer/Math/JMLFuncs.cpp)
32 |
33 | SET(HEADERS
34 | aligned_malloc.h
35 | bbox.h
36 | cloud.h
37 | clustering.h
38 | color.h
39 | error.h
40 | feedback.h
41 | fit.h
42 | heap.h
43 | matrix.h
44 | mesh.h
45 | option.h
46 | overdraw.h
47 | quaternion.h
48 | scalar.h
49 | soup.h
50 | souptomesh.h
51 | Stripifier.h
52 | Timer.h
53 | TootlePCH.h
54 | triorder.h
55 | vector.h
56 | viewpoints.h
57 | window.h
58 |
59 | include/tootlelib.h
60 |
61 | RayTracer/TootleRaytracer.h
62 | RayTracer/JRT/JRTBoundingBox.h
63 | RayTracer/JRT/JRTCamera.h
64 | RayTracer/JRT/JRTCommon.h
65 | RayTracer/JRT/JRTCore.h
66 | RayTracer/JRT/JRTCoreUtils.h
67 | RayTracer/JRT/JRTH2KDTreeBuilder.h
68 | RayTracer/JRT/JRTHeuristicKDTreeBuilder.h
69 | RayTracer/JRT/JRTKDTree.h
70 | RayTracer/JRT/JRTKDTreeBuilder.h
71 | RayTracer/JRT/JRTMesh.h
72 | RayTracer/JRT/JRTOrthoCamera.h
73 | RayTracer/JRT/JRTPPMImage.h
74 | RayTracer/JRT/JRTTriangleIntersection.h
75 | RayTracer/Math/JML.h
76 | RayTracer/Math/JMLFuncs.h
77 | RayTracer/Math/JMLMatrix.h
78 | RayTracer/Math/JMLScalar.h
79 | RayTracer/Math/JMLSSEVec.h
80 | RayTracer/Math/JMLVec2.h
81 | RayTracer/Math/JMLVec3.h)
82 |
83 | ADD_LIBRARY(TootleLib STATIC ${SOURCES} ${HEADERS})
84 | TARGET_INCLUDE_DIRECTORIES(TootleLib
85 | PUBLIC include
86 | PRIVATE
87 | RayTracer/JRT
88 | RayTracer/Math
89 | RayTracer
90 | ${CMAKE_CURRENT_SOURCE_DIR})
91 |
92 | TARGET_COMPILE_DEFINITIONS(TootleLib
93 | PUBLIC _SOFTWARE_ONLY_VERSION)
94 |
95 | IF(UNIX)
96 | TARGET_COMPILE_DEFINITIONS(TootleLib
97 | PUBLIC _LINUX)
98 |
99 | SET_PROPERTY(TARGET TootleLib PROPERTY CXX_STANDARD 11)
100 | SET_PROPERTY(TARGET TootleLib PROPERTY CXX_STANDARD_REQUIRED ON)
101 | ENDIF()
102 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTBoundingBox.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _FRT_BOUNDING_BOX_H_
7 | #define _FRT_BOUNDING_BOX_H_
8 |
9 | #include "JMLSSEVec.h"
10 |
11 | typedef SSEVec4 SSEVector;
12 |
13 | class JRTBoundingBox
14 | {
15 | public:
16 |
17 | JRTBoundingBox(const float* points, unsigned int num_points);
18 |
19 | JRTBoundingBox(const Vec3f* points, unsigned int num_points);
20 |
21 | JRTBoundingBox(const Vec3f& min = Vec3f(0, 0, 0), const Vec3f& max = Vec3f(1, 1, 1));
22 |
23 | inline const Vec3f& GetMin() const { return m_min; };
24 | inline const Vec3f& GetMax() const { return m_max; };
25 |
26 | inline Vec3f& GetMin() { return m_min; };
27 | inline Vec3f& GetMax() { return m_max; };
28 |
29 | Vec3f GetCenter() const { return (m_max + m_min) / 2 ; };
30 |
31 | void Expand(const Vec3f& point);
32 |
33 | bool RayHit(const Vec3f& origin, const Vec3f& endPoint, float* tmin_out, float* tmax_out) const;
34 |
35 |
36 | void Split(unsigned int axis, float value, JRTBoundingBox& front, JRTBoundingBox& back) const;
37 |
38 |
39 | bool PointInBox(const float origin[3]) const;
40 |
41 | JRTBoundingBox Union(const JRTBoundingBox& rOther) const;
42 |
43 | /// Checks for intersection between this box and another, and optionally returns the intersection
44 | /// \param rOther
45 | /// The other box to test for intersection with
46 | /// \param pBBOut
47 | /// Pointer to receive a bounding box containing the intersection of the two boxes
48 | /// \return True if the boxes intersect, false if not
49 | bool Intersection(const JRTBoundingBox& rOther, JRTBoundingBox* pBBOut) const;
50 |
51 | float GetVolume() const;
52 |
53 | float GetSurfaceArea() const;
54 |
55 | bool TriangleIntersect(const Vec3f* pV1, const Vec3f* pV2, const Vec3f* pV3) const;
56 |
57 | bool IsDegenerate() const;
58 |
59 | void GetCorners(Vec3f* pCorners) const;
60 |
61 | private:
62 |
63 | Vec3f m_min;
64 | Vec3f m_max;
65 | };
66 |
67 | JRTBoundingBox JRTBBoxUnion(const JRTBoundingBox& rFirst, const JRTBoundingBox& rSecond);
68 | JRTBoundingBox JRTBBoxIntersection(const JRTBoundingBox& rFirst, const JRTBoundingBox& rSecond);
69 | JRTBoundingBox JRTBBoxDifference(const JRTBoundingBox& rFirst, const JRTBoundingBox& rSecond);
70 |
71 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCamera.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "TootlePCH.h"
7 | #include "JRTCommon.h"
8 | #include "JRTCamera.h"
9 |
10 |
11 | /// \param position
12 | /// Camera position
13 | /// \param direction
14 | /// Camera direction
15 | /// \param up
16 | /// The 'up' vector
17 | /// \param fov
18 | /// Field of view angle, in radians
19 |
20 | JRTPerspectiveCamera::JRTPerspectiveCamera(const Vec3f& position, const Vec3f& direction, const Vec3f& up, float fov)
21 | : m_position(position),
22 | m_direction(direction)
23 | {
24 | m_right = Cross(up, direction);
25 | m_up = Cross(direction, m_right);
26 |
27 | m_right = Normalize(m_right);
28 | m_up = Normalize(m_up);
29 |
30 | // distance from center of viewing plane to edges
31 | // assuming a hither distance of 1, it is: tan(fov/2.0)
32 | // draw a diagram if you're curious
33 | m_plane_width = tan(fov / 2.0f);
34 |
35 |
36 | Vec3f H = m_right * m_plane_width;
37 | Vec3f V = m_up * m_plane_width;
38 | Vec3f center = m_position + m_direction;
39 |
40 | // get the pixel center on the top-left corner of the image plane
41 | m_corner = center - H;
42 | m_corner = m_corner + V;
43 |
44 | m_plane_width *= 2.0;
45 | m_aspect = 1;
46 | }
47 |
48 |
49 | void JRTPerspectiveCamera::SetAspectRatio(float aspect)
50 | {
51 | // recompute 'corner' position for sampling
52 | Vec3f center = m_position + m_direction;
53 | Vec3f H = m_right * (m_plane_width / 2.0f) * aspect;
54 | Vec3f V = m_up * (m_plane_width / 2.0f);
55 |
56 | m_corner = center - H;
57 | m_corner = m_corner + V;
58 | m_aspect = aspect;
59 | }
60 |
61 | void JRTPerspectiveCamera::GetRay(float s, float t, Vec3f* origin, Vec3f* delta) const
62 | {
63 | // correct for aspect ratio
64 | s *= m_aspect;
65 |
66 | s *= m_plane_width;
67 | t *= m_plane_width;
68 | Vec3f pixel_center = m_corner + (m_right * s) + (m_up * -t);
69 | Vec3f dir = (pixel_center - m_position);
70 |
71 | *origin = m_position;
72 | *delta = dir;
73 |
74 | }
75 |
76 |
77 | void JRTPerspectiveCamera::ProjectPoint(const Vec3f& pt, float* s, float* t) const
78 | {
79 | // convert point to camera space
80 | Vec3f pcam = pt - m_position;
81 | Vec3f camera_space_pt = (m_right * pcam.x) + (m_up * pcam.y) + (m_direction * pcam.z);
82 |
83 | if (camera_space_pt.z <= 0.0)
84 | {
85 | *s = -1;
86 | *t = -1;
87 | return;
88 | }
89 |
90 | // splat point onto image plane and find out where it lands
91 | // we are looking for a vector such that z=1
92 | float val = 1.0f / camera_space_pt.z;
93 | Vec3f splat;
94 | splat.x = val * camera_space_pt.x;
95 | splat.y = val * camera_space_pt.y;
96 | splat.z = 1;
97 |
98 | // normalize to size of image plane and clip
99 | splat.x /= m_plane_width;
100 | splat.y /= -m_plane_width;
101 |
102 | if (std::abs(splat.x) > 0.5 || std::abs(splat.y) > 0.5)
103 | {
104 | *s = -1;
105 | *t = -1;
106 | return;
107 | }
108 |
109 | // correct for aspect ratio and convert to NDC space
110 | splat.x /= m_aspect;
111 | splat.x += 0.5;
112 | splat.y += 0.5;
113 | *s = splat.x;
114 | *t = splat.y;
115 |
116 | }
117 |
118 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCamera.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_CAMERA_H_
7 | #define _JRT_CAMERA_H_
8 |
9 | #include "JRTCommon.h"
10 |
11 |
12 | class JRTCamera
13 | {
14 | public:
15 | virtual ~JRTCamera() {};
16 | virtual void GetRay(float s, float t, Vec3f* origin, Vec3f* delta) const = 0;
17 | virtual void SetAspectRatio(float aspect) = 0;
18 |
19 | // returns the position of the given point in camera NDC space
20 | // if the point is not visible, s and t are each set to -1
21 | virtual void ProjectPoint(const Vec3f& pt, float* s, float* t) const = 0;
22 | };
23 |
24 |
25 | class JRTPerspectiveCamera : virtual public JRTCamera
26 | {
27 | public:
28 | JRTPerspectiveCamera(const Vec3f& position, const Vec3f& direction, const Vec3f& up, float fov = 3.1415926);
29 |
30 | virtual void GetRay(float s, float t, Vec3f* origin, Vec3f* delta) const ;
31 | virtual void SetAspectRatio(float aspect) ;
32 |
33 | // returns the position of the given point in camera NDC space
34 | // if the point is not visible, s and t are each set to -1
35 | virtual void ProjectPoint(const Vec3f& pt, float* s, float* t) const ;
36 |
37 | private:
38 | float m_aspect;
39 | Vec3f m_position; // eye position in world space
40 | Vec3f m_direction; // viewing axis in world space
41 | Vec3f m_up; // "true" up. Vertical direction in world-space image plane
42 | Vec3f m_right; // horizontal direction in world-space image plane
43 |
44 | float m_plane_width; // size of image plane
45 | Vec3f m_corner; // top-left corner of image plane - world space
46 |
47 | };
48 |
49 |
50 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCommon.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_COMMON_H_
7 | #define _JRT_COMMON_H_
8 |
9 | /// epsilon value used in intersection computations.
10 | #define JRTEPSILON 0.00001f
11 |
12 | #include "TootlePCH.h"
13 |
14 | #include
15 |
16 | #ifdef _LINUX
17 | typedef unsigned long long UINT64;
18 | #else
19 | typedef unsigned __int64 UINT64;
20 | #endif
21 | typedef unsigned int UINT;
22 | typedef unsigned short USHORT;
23 | typedef unsigned char UBYTE;
24 |
25 | #include "JML.h"
26 | using namespace JML;
27 |
28 | #define JRT_ASSERT(x) assert(x)
29 | #define JRT_SAFE_DELETE(x) {if(x) delete x; x = NULL;}
30 | #define JRT_SAFE_DELETE_ARRAY(x) { if(x) delete[] x; x=NULL; }
31 |
32 |
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCore.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "TootlePCH.h"
7 | #include "JRTCommon.h"
8 | #include "JRTCore.h"
9 | #include "JRTMesh.h"
10 |
11 | #include "JRTKDTree.h"
12 | #include "JRTKDTreeBuilder.h"
13 | #include "JRTHeuristicKDTreeBuilder.h"
14 | #include "JRTH2KDTreeBuilder.h"
15 |
16 |
17 | JRTCore::JRTCore() : m_pTree(NULL), m_pHitArray(new TootleRayHit[5]), m_nArraySize(5)
18 | {
19 |
20 | }
21 |
22 | JRTCore::~JRTCore()
23 | {
24 | JRT_SAFE_DELETE(m_pTree);
25 | JRT_SAFE_DELETE_ARRAY(m_pHitArray);
26 | }
27 |
28 |
29 | JRTCore* JRTCore::Build(const std::vector& rMeshes)
30 | {
31 | JRTCore* pCaster = new JRTCore();
32 |
33 | if (rMeshes.size() == 0)
34 | {
35 | pCaster->m_pTree = NULL;
36 | return pCaster;
37 | }
38 |
39 | // build KD tree
40 | JRTHeuristicKDTreeBuilder builder;
41 | JRTKDTree* pTree = builder.BuildTree(rMeshes);
42 |
43 | if (!pTree)
44 | {
45 | delete pCaster;
46 | return NULL;
47 | }
48 |
49 | pCaster->m_pTree = pTree;
50 |
51 | return pCaster;
52 | }
53 |
54 |
55 | int SortTootleHit(const void* h1, const void* h2)
56 | {
57 | const TootleRayHit* ph1 = (const TootleRayHit*) h1;
58 | const TootleRayHit* ph2 = (const TootleRayHit*) h2;
59 | return ph1->t >= ph2->t;
60 | }
61 |
62 |
63 | /// \param rOrigin The ray origin
64 | /// \param rDirection The ray direction
65 | /// \param ppHitArray A pointer that will be set to point to an array of hits. The caller should NOT delete the returned array
66 | /// \param pHitCount A pointer that will receive the number of hits in the returned array.
67 | /// \return Returns false if out of memory, true otherwise.
68 | bool JRTCore::FindAllHits(const Vec3f& rOrigin, const Vec3f& rDirection, TootleRayHit** ppHitArray, UINT* pHitCount)
69 | {
70 | if (!m_pTree)
71 | {
72 | *ppHitArray = NULL;
73 | *pHitCount = 0;
74 | }
75 |
76 | UINT nHits = m_pTree->FindAllHits(rOrigin, rDirection, &m_pHitArray, &m_nArraySize);
77 |
78 | if (nHits == 0 || nHits == JRTKDTree::OUT_OF_MEMORY)
79 | {
80 | *ppHitArray = NULL;
81 | *pHitCount = 0;
82 | }
83 |
84 | if (nHits == JRTKDTree::OUT_OF_MEMORY)
85 | {
86 | return false;
87 | }
88 |
89 | #ifdef DEBUG
90 |
91 | // verify that there are no duplicates, just a test
92 | for (UINT i = 0; i < nHits; i++)
93 | {
94 | for (UINT j = i + 1; j < nHits; j++)
95 | {
96 | JRT_ASSERT(m_pHitArray[i].nFaceID != m_pHitArray[j].nFaceID)
97 | }
98 | }
99 |
100 | #endif
101 |
102 | // sort hits by distance
103 | qsort(m_pHitArray, nHits, sizeof(TootleRayHit), &SortTootleHit);
104 | *ppHitArray = m_pHitArray;
105 | *pHitCount = nHits;
106 |
107 | return true;
108 | }
109 |
110 | void JRTCore::CullBackfaces(const Vec3f& rViewDir, bool bCullCCW)
111 | {
112 | m_pTree->CullBackfaces(rViewDir, bCullCCW);
113 | }
114 |
115 |
116 |
117 | bool JRTCore::GetSceneBBHit(const Vec3f& rOrigin, const Vec3f& rDirection, Vec3f* pHitPt)
118 | {
119 | const JRTBoundingBox& rBB = m_pTree->GetSceneBounds();
120 | float fTMin, fTMax;
121 |
122 | if (!rBB.RayHit(rOrigin, rDirection, &fTMin, &fTMax))
123 | {
124 | return false;
125 | }
126 |
127 | if (fTMax < 0.0f)
128 | {
129 | return false;
130 | }
131 |
132 | *pHitPt = rOrigin + rDirection * fTMax;
133 | return true;
134 | }
135 |
136 |
137 | const JRTBoundingBox& JRTCore::GetSceneBB() const
138 | {
139 | return m_pTree->GetSceneBounds();
140 | }
141 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCore.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_CORE_H_
7 | #define _JRT_CORE_H_
8 |
9 | #include "JRTCommon.h"
10 | #include "JRTTriangleIntersection.h"
11 |
12 | struct JRTHitInfo
13 | {
14 | // the triangle that was hit
15 | const JRTMesh* pMesh;
16 | UINT nIndex;
17 |
18 | Vec3f mPosition;
19 | Vec3f mNormal;
20 | };
21 |
22 | struct TootleRayHit
23 | {
24 | float t;
25 | UINT nFaceID;
26 | };
27 |
28 | class JRTCSGNode;
29 | class JRTMesh;
30 | class JRTKDTree;
31 | class JRTBoundingBox;
32 |
33 | class JRTCore
34 | {
35 | public:
36 |
37 | static JRTCore* Build(const std::vector& rPrims);
38 |
39 | ~JRTCore();
40 |
41 | bool FindAllHits(const Vec3f& rOrigin, const Vec3f& rDirection, TootleRayHit** ppHitArray, UINT* pnHits);
42 |
43 | void CullBackfaces(const Vec3f& rViewDir, bool bCullCCW);
44 |
45 | /// Locates the position at which the given ray hits the scene bounding box.
46 | /// Returns false if the ray misses the bounding box
47 | bool GetSceneBBHit(const Vec3f& rOrigin, const Vec3f& rDirection, Vec3f* pHitPt);
48 |
49 | const JRTBoundingBox& GetSceneBB() const ;
50 |
51 | private:
52 |
53 | JRTCore();
54 |
55 | TootleRayHit* m_pHitArray;
56 | UINT m_nArraySize;
57 |
58 | JRTKDTree* m_pTree;
59 | };
60 |
61 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCoreUtils.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "TootlePCH.h"
7 | #include "JRTCommon.h"
8 | #include "JRTCoreUtils.h"
9 | #include "JRTMesh.h"
10 |
11 |
12 | // These arrays are used to implement the UCOMP, VCOMP, WCOMP macros
13 |
14 | // coordinate to drop: X Y Z
15 | const int INDEX1[3] = { 1, 0, 0 }; // projection coord 1
16 | const int INDEX2[3] = { 2, 2, 1 }; // projection coord 2
17 | // projection plane: YZ XZ XY
18 |
19 | TriPlaneState TriPlaneTest(const JRTTriangle& tri, Axis split_component, float split_value)
20 | {
21 | bool front = false, back = false;
22 |
23 | if (tri.GetV1()[split_component] < split_value)
24 | {
25 | back = true;
26 | }
27 | else
28 | {
29 | front = true;
30 | }
31 |
32 | if (tri.GetV2()[split_component] < split_value)
33 | {
34 | back = true;
35 | }
36 | else
37 | {
38 | front = true;
39 | }
40 |
41 | if (tri.GetV3()[split_component] < split_value)
42 | {
43 | back = true;
44 | }
45 | else
46 | {
47 | front = true;
48 | }
49 |
50 |
51 | if (front && back)
52 | {
53 | return STRADDLE;
54 | }
55 | else if (front)
56 | {
57 | return IN_FRONT;
58 | }
59 | else
60 | {
61 | return IN_BACK;
62 | }
63 | }
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTCoreUtils.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_CORE_UTILS_H_
7 | #define _JRT_CORE_UTILS_H_
8 |
9 | enum Axis
10 | {
11 | X_AXIS = 0,
12 | Y_AXIS = 1,
13 | Z_AXIS = 2
14 | };
15 |
16 | inline void SWAP(float& a, float& b) { float tmp = a; a = b; b = tmp; };
17 |
18 |
19 | // macros for projecting points onto axis-aligned planes
20 | #define UCOMP(P, axis) P[ INDEX1[axis] ]
21 | #define VCOMP(P, axis) P[ INDEX2[axis] ]
22 | #define WCOMP(P, axis) P[ axis ];
23 |
24 | #define UCOMPINDEX(axis) INDEX1[axis];
25 | #define VCOMPINDEX(axis) INDEX2[axis];
26 | #define WCOMPINDEX(axis) axis;
27 |
28 | // these arrays define which coordinates to select when projecting into a plane aligned to a particular axis
29 | extern const int INDEX1[3];
30 | extern const int INDEX2[3];
31 |
32 | //
33 | // TriPlaneTest
34 | // Returns a value indicating whether a triangle is in front of,
35 | // behind, or crossing an axis-aligned split plane
36 | //
37 | enum TriPlaneState
38 | {
39 | IN_FRONT,
40 | IN_BACK,
41 | STRADDLE
42 | };
43 |
44 | class JRTTriangle;
45 |
46 | TriPlaneState TriPlaneTest(const JRTTriangle& tri, Axis split_component, float split_value);
47 |
48 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTH2KDTreeBuilder.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_H2_KDTREE_BUILDER_H_
7 | #define _JRT_H2_KDTREE_BUILDER_H_
8 |
9 | #include "JRTCoreUtils.h"
10 | #include "JRTKDTreeBuilder.h"
11 |
12 | /// The H2 KDTree builder is a simplified heuristic tree builder
13 | /// The algorithm works thusly:
14 | /// - for each axis
15 | /// - Start at spatial median, classify polys
16 | /// - If all polys on one side, shift split plane
17 | /// - Choose axis with lowest spatial median cost (using SAH)
18 |
19 | class JRTH2KDTreeBuilder : public JRTKDTreeBuilder
20 | {
21 | public:
22 |
23 | void BuildTreeImpl(const JRTBoundingBox& rBounds,
24 | const std::vector& rTris,
25 | std::vector& rNodesOut,
26 | std::vector& rTriIndicesOut);
27 |
28 | private:
29 |
30 | struct SplitInfo
31 | {
32 | Axis eAxis;
33 | float fHeuristicValue; ///< Estimated cost of this split. If 0, it means do not split
34 | float fPosition;
35 | std::vector TrisFront;
36 | std::vector TrisBack;
37 | };
38 |
39 | void MakeLeaf(JRTKDNode* pNode,
40 | const std::vector& rTrisThisNode,
41 | std::vector& rNodesOut,
42 | std::vector& rTriIndicesOut);
43 |
44 | void DoBuildTree(UINT nMaxDepth,
45 | JRTKDNode* pNode,
46 | const JRTBoundingBox& rBounds,
47 | const std::vector& rTris,
48 | std::vector& rTrisThisNode,
49 | std::vector& rNodesOut,
50 | std::vector& rTriIndicesOut);
51 |
52 |
53 | void FindBestSplit(Axis eAxis,
54 | const JRTBoundingBox& rBounds,
55 | const std::vector& rTris,
56 | const std::vector& rTrisThisNode,
57 | SplitInfo* pSplitOut);
58 |
59 | void ClassifyTris(Axis eAxis,
60 | float fPosition,
61 | std::vector& rTrisBack,
62 | std::vector& rTrisFront,
63 | UINT& nStraddle,
64 | float& fTriMin,
65 | float& fTriMax,
66 | const std::vector& rTrisThisNode);
67 |
68 | float CostFunction(const JRTBoundingBox& rBounds, SplitInfo* pSlitOut);
69 |
70 | // triangle bounding boxes,used to speed classification
71 | // these are arranged by axis so that they'll cache better
72 | typedef std::pair FloatPair;
73 | std::vector m_BBX;
74 | std::vector m_BBY;
75 | std::vector m_BBZ;
76 | };
77 |
78 |
79 |
80 |
81 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTHeuristicKDTreeBuilder.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_HEURISTIC_KD_TREE_BUILDER_H_
7 | #define _JRT_HEURISTIC_KD_TREE_BUILDER_H_
8 |
9 |
10 | #include "JRTKDTreeBuilder.h"
11 | #include "JRTBoundingBox.h"
12 | #include "JRTCoreUtils.h"
13 |
14 | /// \brief A smart KD tree builder which uses the surface area heuristic
15 | /// Most of the inspiration for this code comes from Havran's PhD thesis
16 | class JRTHeuristicKDTreeBuilder : public JRTKDTreeBuilder
17 | {
18 | public:
19 |
20 |
21 |
22 | struct TriangleBB
23 | {
24 | const JRTTriangle* pTri;
25 | UINT nIndex;
26 | JRTBoundingBox box;
27 |
28 | // state flag used to classify this BB with respect to current partitioning plane
29 | mutable TriPlaneState planeState;
30 |
31 | };
32 |
33 |
34 | struct Split
35 | {
36 | float value;
37 | unsigned bMaxSplit : 1;
38 | unsigned nTriBB : 31;
39 |
40 | //bool bMaxSplit; /// Is this a max split (end of BB) or a min split (beginning of BB)
41 | //const TriangleBB* pTriBB;
42 | };
43 |
44 | typedef std::vector SplitVec;
45 |
46 |
47 | protected:
48 |
49 | virtual void BuildTreeImpl(const JRTBoundingBox& rBounds,
50 | const std::vector& rTris,
51 | std::vector& rNodesOut,
52 | std::vector& rTriIndicesOut);
53 |
54 |
55 | private:
56 |
57 | /* void BuildTreeRecursive( UINT nDepth,
58 | const JRTBoundingBox& rNodeBounds,
59 | const std::vector rBBs[3],
60 | JRTKDNode* pNode,
61 | std::vector& rNodesOut,
62 | std::vector& rTriIndicesOut );*/
63 |
64 | void ExtractSplits(UINT eAxis, const std::vector& rBBs, std::vector& rSplits, const JRTBoundingBox& rSceneBounds);
65 |
66 | void ClassifyBBs(SplitVec& rSplits, std::vector& rBBs, UINT eAxis, float fValue);
67 |
68 | void LocateBestSplit(float fNodeBBInvArea,
69 | const JRTBoundingBox& rNodeBounds,
70 | const SplitVec splits[3],
71 | UINT eAxis, UINT nTriCount, float& fBestCost, bool& bSplit, UINT& eSplitAxis, float& fSplitValue);
72 |
73 |
74 | void BuildTreeRecursive(UINT nDepth,
75 | const JRTBoundingBox& rNodeBounds,
76 | SplitVec splits[3],
77 | std::vector& rBBsThisNode,
78 | JRTKDNode* pNode,
79 | std::vector& rNodesOut,
80 | std::vector& rTriIndicesOut);
81 |
82 | JRTBoundingBox m_scene_bounds;
83 |
84 |
85 | std::vector m_bbs;
86 |
87 | };
88 |
89 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTKDTree.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_KDTREE_H_
7 | #define _JRT_KDTREE_H_
8 |
9 | #include "JRTCommon.h"
10 | #include "JRTBoundingBox.h"
11 | #include "JRTTriangleIntersection.h"
12 | #include "JRTCore.h"
13 |
14 | #ifdef _LINUX
15 | #include "../aligned_malloc.h"
16 | #define _aligned_malloc aligned_malloc
17 | #define _aligned_free aligned_free
18 | #endif
19 |
20 | // ***********************************************************
21 | // Node Data Structure
22 | // ***********************************************************
23 |
24 | // the #pragma pack(1) is so that VC++ will make this structure 8 bytes wide
25 | // if you omit the pack(), VC++ will pad the internal structs and throw the size off
26 | #pragma pack(1)
27 | class JRTKDNode
28 | {
29 | public:
30 |
31 | inline bool IsLeaf() const { return (inner.is_leaf == 1); };
32 |
33 |
34 | union
35 | {
36 | struct
37 | {
38 | // if an inner node, use this one
39 | unsigned is_leaf : 1;
40 | unsigned axis : 3;
41 | unsigned front_offset : 28;
42 |
43 | float position; // position of splitting plane
44 |
45 | } inner;
46 |
47 | struct
48 | {
49 | // if a leaf, use this one
50 | unsigned is_leaf : 1;
51 | unsigned triangle_start : 31; // offset of first triangle in triangle list
52 | UINT triangle_count;// number of triangles in this node
53 |
54 | } leaf;
55 | };
56 |
57 | };
58 | #pragma pack()
59 |
60 |
61 |
62 |
63 | class JRTKDTree
64 | {
65 | public:
66 |
67 | static const UINT MAX_TREE_DEPTH;
68 |
69 | /// Overloaded new operator allocates 16-byte aligned objects using _aligned_malloc
70 | void* operator new(size_t nSize) { return _aligned_malloc(nSize, 16); };
71 |
72 | /// Overloaded delete operator uses _aligned_free()
73 | void operator delete(void* pObj) { _aligned_free(pObj); };
74 |
75 |
76 | ~JRTKDTree();
77 |
78 | bool FindFirstHit(const Vec3f& rOrigin, const Vec3f& rDirection, JRTHitInfo* pHit, const JRTMesh* pExcludeMesh, UINT nExcludeTri, bool* pCSGStates) ;
79 |
80 | void CullBackfaces(const Vec3f& rViewDir, bool bCullCCW);
81 |
82 | UINT FindAllHits(const Vec3f& rOrigin, const Vec3f& rDirection, TootleRayHit** ppHitArray, UINT* pnArraySize);
83 |
84 | UINT GetNodeCount() const { return m_nNodeCount; };
85 |
86 | /// Returns total number of tris in tree (not taking into account duplication)
87 | UINT GetTriCount() const { return m_nTriangleCount; };
88 |
89 | /// Returns total number of triangle references for all leaves
90 | UINT GetIndexCount() const { return m_nIndexCount; };
91 |
92 | UINT GetMaxDepth() const ;
93 |
94 | UINT GetLeafCount() const;
95 |
96 | /// Returns an estimate of the amount of memory used by the tree
97 | UINT GetMemoryUsage() const;
98 |
99 | /// Returns the scene bounding box
100 | const JRTBoundingBox& GetSceneBounds() const { return m_treeBounds; };
101 |
102 | static const UINT OUT_OF_MEMORY = 0xffffffff;
103 |
104 | private:
105 |
106 | UINT RecurseMaxDepth(UINT nNode) const;
107 |
108 |
109 | friend class JRTKDTreeBuilder;
110 | JRTKDTree();
111 |
112 | // ***********************************************************
113 | // Tree internals
114 | // ***********************************************************
115 |
116 | // tree bounding box
117 | JRTBoundingBox m_treeBounds;
118 |
119 | // number of nodes
120 | UINT m_nNodeCount;
121 |
122 | // number of triangles
123 | UINT m_nTriangleCount;
124 |
125 | // number of triangle indices
126 | UINT m_nIndexCount;
127 |
128 | // array of KDTree nodes
129 | JRTKDNode* m_pNodeArray;
130 |
131 | // array of triangle indices. All indices for all nodes are packed into contiguous memory.
132 | // each node stores an offset for its triangle list in this array
133 | UINT* m_pIndexArray;
134 |
135 | // array of pre-processed triangles
136 | JRTCoreTriangle* m_pTriArray;
137 |
138 | // next ray ID to assign to a traced ray
139 | UINT m_nNextRayID;
140 |
141 |
142 | //****************** Ray traversal state ***********************
143 |
144 | // this is mutable state that changes during ray traversal. If we every want
145 | // to make this thing multi-threaded, we will need to allocate this stuff seperately
146 | // for each worker thread
147 |
148 |
149 | // mailboxes, one per triangle. These store the ray-id for the last ray to be tested
150 | // with this triangle
151 | UINT* m_pMailboxes;
152 |
153 | // flags to indicate whether or not a triangle is back-facing (TOOTLE SPECIFIC)
154 | bool* m_bBackFacing;
155 |
156 | };
157 |
158 | #endif
159 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTKDTreeBuilder.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_KDTREE_BUILDER_H_
7 | #define _JRT_KDTREE_BUILDER_H_
8 |
9 | #include "JRTCommon.h"
10 |
11 | class JRTMesh;
12 | class JRTKDTree;
13 | class JRTTriangle;
14 | class JRTKDNode;
15 | class JRTBoundingBox;
16 |
17 | /// \brief The tree builder class is responsible for constructing a KD tree from triangle soup.
18 | /// The base implementation uses a stupid naive splitting heuristic
19 | class JRTKDTreeBuilder
20 | {
21 | public:
22 |
23 | JRTKDTree* BuildTree(const std::vector& rMeshes);
24 |
25 | protected:
26 |
27 | virtual void BuildTreeImpl(const JRTBoundingBox& rBounds,
28 | const std::vector& rTris,
29 | std::vector& rNodesOut,
30 | std::vector& rTriIndicesOut);
31 |
32 |
33 | };
34 |
35 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTMesh.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "TootlePCH.h"
7 | #include "JRTCommon.h"
8 | #include "JRTMesh.h"
9 | #include "JRTBoundingBox.h"
10 |
11 | /// A mesh must have an array of positions and connectivity. It may also have per-vertex normals
12 | /// If per-vertex normals are omitted, then per-face normals are used instead.
13 | ///
14 | /// The mesh does NOT delete the input arrays
15 | ///
16 | /// \param rPositions
17 | /// Array of vertex positions
18 | /// \param pFaceNormals
19 | /// Array of face normals. Must be same length as nTriangleCount
20 | /// \param nTriangleCount
21 | /// Number of triangles
22 | /// \param pIndices
23 | /// An array of 3*nTriangleCount vertex indices
24 | JRTMesh* JRTMesh::CreateMesh(const Vec3f* pPositions,
25 | const Vec3f* pNormals,
26 | UINT nVertices,
27 | UINT nTriangleCount,
28 | const UINT* pIndices)
29 | {
30 | JRTMesh* pMesh = new JRTMesh();
31 |
32 | pMesh->m_nVertexCount = nVertices;
33 | pMesh->m_nTriangleCount = nTriangleCount;
34 |
35 | // copy vertex positions
36 | pMesh->m_Positions.assign (pPositions, pPositions + nVertices);
37 |
38 | // copy normals
39 | pMesh->m_FaceNormals.assign (pNormals, pNormals + nTriangleCount);
40 |
41 | // create triangles
42 | pMesh->m_Triangles.resize (nTriangleCount);
43 |
44 | for (UINT i = 0; i < nTriangleCount; i++)
45 | {
46 | pMesh->m_Triangles[i].m_pMesh = pMesh;
47 |
48 | JRT_ASSERT(pIndices[0] < nVertices);
49 | JRT_ASSERT(pIndices[1] < nVertices);
50 | JRT_ASSERT(pIndices[2] < nVertices);
51 |
52 | pMesh->m_Triangles[i].m_pV1 = reinterpret_cast (&pMesh->m_Positions[ pIndices[0] ]);
53 | pMesh->m_Triangles[i].m_pV2 = reinterpret_cast (&pMesh->m_Positions[ pIndices[1] ]);
54 | pMesh->m_Triangles[i].m_pV3 = reinterpret_cast (&pMesh->m_Positions[ pIndices[2] ]);
55 |
56 | pIndices += 3;
57 | }
58 |
59 | return pMesh;
60 |
61 | }
62 |
63 | JRTMesh::JRTMesh() :
64 | m_nTriangleCount(0),
65 | m_nVertexCount(0)
66 | {
67 | }
68 |
69 |
70 | JRTMesh::~JRTMesh()
71 | {
72 | }
73 |
74 | void JRTMesh::Transform(const Matrix4f& rXForm, const Matrix4f& rInverse)
75 | {
76 | // transform positions
77 | for (UINT i = 0; i < m_nVertexCount; i++)
78 | {
79 | TransformPoint(&m_Positions[i], &rXForm, &m_Positions[i]);
80 | }
81 |
82 | Matrix4f inverseTranspose = rInverse.Transpose();
83 |
84 | // transform normals
85 | if (! m_Normals.empty ())
86 | {
87 | for (UINT i = 0; i < m_nVertexCount; i++)
88 | {
89 | ALIGN16 Vec3f tmp = m_Normals[i];
90 | TransformVector(&tmp, &inverseTranspose, &m_Normals[i]);
91 | m_Normals[i] = Normalize(m_Normals[i]);
92 | }
93 | }
94 | else
95 | {
96 | // transform face normals
97 | for (UINT i = 0; i < m_nTriangleCount; i++)
98 | {
99 | ALIGN16 Vec3f tmp = m_FaceNormals[i];
100 | TransformVector(&tmp, &inverseTranspose, &m_FaceNormals[i]);
101 | m_FaceNormals[i] = tmp;
102 | }
103 | }
104 | }
105 |
106 |
107 | void JRTMesh::GetInterpolants(UINT nTriIndex, const float barycentrics[], Vec3f* pNormal, Vec2f* /*pUV*/) const
108 | {
109 | const UINT nIndex1 = (UINT)(m_Triangles[nTriIndex].m_pV1 - (const float*)m_Positions.data ()) / 3;
110 | const UINT nIndex2 = (UINT)(m_Triangles[nTriIndex].m_pV2 - (const float*)m_Positions.data ()) / 3;
111 | const UINT nIndex3 = (UINT)(m_Triangles[nTriIndex].m_pV3 - (const float*)m_Positions.data ()) / 3;
112 |
113 | if (!m_Normals.empty ())
114 | {
115 | *pNormal = Normalize(BarycentricLerp3f(m_Normals[nIndex1], m_Normals[nIndex2], m_Normals[nIndex3], barycentrics));
116 | }
117 | else
118 | {
119 | *pNormal = Normalize(m_FaceNormals[ nTriIndex ]);
120 | }
121 | }
122 |
123 |
124 |
125 | void JRTMesh::RemoveTriangle(UINT nTri)
126 | {
127 | if (nTri <= m_nTriangleCount)
128 | {
129 | // swap this triangle with the last one in the mesh
130 | JRTTriangle tmpTri = m_Triangles[m_nTriangleCount - 1];
131 | m_Triangles[m_nTriangleCount - 1] = m_Triangles[nTri];
132 | m_Triangles[nTri] = tmpTri;
133 |
134 | // swap face normals if there are any
135 | if (m_Normals.empty ())
136 | {
137 | Vec3f tmpNorm = m_FaceNormals[ m_nTriangleCount - 1 ];
138 | m_FaceNormals[m_nTriangleCount - 1] = m_FaceNormals[nTri];
139 | m_FaceNormals[ nTri ] = tmpNorm;
140 | }
141 |
142 | m_nTriangleCount--;
143 | }
144 | }
145 |
146 |
147 | JRTBoundingBox JRTMesh::ComputeBoundingBox() const
148 | {
149 | return JRTBoundingBox((const float*)this->m_Positions.data (), m_nVertexCount);
150 | }
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTMesh.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_MESH_H_
7 | #define _JRT_MESH_H_
8 |
9 | #include "JRTCommon.h"
10 |
11 | class JRTTriangle;
12 |
13 | class JRTCSGNode;
14 | class JRTSurfaceShader;
15 | class JRTPhotonShader;
16 | class JRTBoundingBox;
17 |
18 | class JRTMeshAttributes
19 | {
20 | public:
21 | JRTMeshAttributes() : pShader(NULL), pCSGNode(NULL), bCastsShadows(true), bCastsCaustics(false)
22 | {};
23 |
24 | JRTSurfaceShader* pShader;
25 | JRTPhotonShader* pPhotonShader;
26 | JRTCSGNode* pCSGNode;
27 | bool bCastsShadows;
28 | bool bCastsCaustics;
29 | };
30 |
31 |
32 | class JRTMesh
33 | {
34 | public:
35 |
36 | /// Factory method for creating meshes
37 | static JRTMesh* CreateMesh(const Vec3f* pPositions,
38 | const Vec3f* pNormals,
39 | UINT nVertices,
40 | UINT nTriangleCount,
41 | const UINT* pIndices);
42 |
43 | /// Mesh constructor
44 | JRTMesh();
45 |
46 | /// Mesh destructor
47 | ~JRTMesh();
48 |
49 | /// Transforms the mesh and re-preprocesses the triangles
50 | void Transform(const Matrix4f& rXForm, const Matrix4f& rInverse);
51 |
52 | /// Returns the number of triangles in the mesh
53 | UINT GetTriangleCount() const { return m_nTriangleCount; };
54 |
55 | /// Accessor for the array of triangles
56 | inline const JRTTriangle* GetTriangles() const { return m_Triangles.data (); };
57 |
58 |
59 | void GetInterpolants(UINT nTriIndex, const float barycentrics[3], Vec3f* pNormal, Vec2f* pUV) const;
60 |
61 | const JRTMeshAttributes& GetAttributes() const { return m_attributes; };
62 |
63 | void SetAttributes(const JRTMeshAttributes& rAttribs) { m_attributes = rAttribs; };
64 |
65 | /// Removes a particular triangle from the mesh
66 | void RemoveTriangle(UINT nTri);
67 |
68 | JRTBoundingBox ComputeBoundingBox() const;
69 |
70 | const Vec3f& GetFaceNormal(UINT nTri) const { return m_FaceNormals[nTri]; };
71 |
72 | const Vec3f& GetVertex(UINT i) const { return m_Positions[i]; };
73 | void SetVertex(UINT i, const Vec3f& v) { m_Positions[i] = v; };
74 |
75 | private:
76 |
77 | std::vector m_Positions;
78 | std::vector m_Normals;
79 | std::vector m_UVs;
80 |
81 | /// Pre-computed array of face normals. This is used only if no vertex normals are provided
82 | std::vector m_FaceNormals;
83 |
84 | std::vector m_Triangles;
85 |
86 | UINT m_nTriangleCount;
87 | UINT m_nVertexCount;
88 |
89 | JRTMeshAttributes m_attributes;
90 |
91 | // Disallow copy constructor, as m_Triangles contains pointers into the
92 | // other data structures
93 | JRTMesh (const JRTMesh&);
94 | JRTMesh& operator=(const JRTMesh&);
95 | };
96 |
97 |
98 |
99 |
100 | class JRTTriangle
101 | {
102 | public:
103 |
104 | /// Returns the first vertex
105 | inline const Vec3f& GetV1() const { return *(const Vec3f*)m_pV1; };
106 |
107 | /// Returns the second vertex
108 | inline const Vec3f& GetV2() const { return *(const Vec3f*)m_pV2; };
109 |
110 | /// Returns the third vertex
111 | inline const Vec3f& GetV3() const { return *(const Vec3f*)m_pV3; };
112 |
113 | /// Returns the mesh which owns this triangle
114 | inline JRTMesh* GetMesh() const { return m_pMesh; };
115 |
116 | /// Returns the index of this triangle in its parent's triangle array
117 | inline UINT GetIndexInMesh() const { return (UINT)(this - m_pMesh->GetTriangles()); };
118 |
119 | inline const Vec3f& GetNormal() const { return m_pMesh->GetFaceNormal(GetIndexInMesh()); };
120 | private:
121 |
122 |
123 | friend class JRTMesh;
124 |
125 | /// Pointer to first vertex position
126 | const float* m_pV1;
127 |
128 | /// Pointer to second vertex position
129 | const float* m_pV2;
130 |
131 | /// Pointer to third vertex position
132 | const float* m_pV3;
133 |
134 | /// Pointer to the mesh
135 | JRTMesh* m_pMesh;
136 |
137 | };
138 |
139 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTOrthoCamera.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "JRTCommon.h"
7 | #include "TootlePCH.h"
8 | #include "JRTCommon.h"
9 | #include "JRTOrthoCamera.h"
10 |
11 | JRTOrthoCamera::JRTOrthoCamera(const Vec3f& rPosition, const Vec3f& rDirection, const Vec3f& rUp, float fHorizontalSize)
12 | : m_position(rPosition), m_direction(rDirection), m_fSize(fHorizontalSize), m_fAspect(1)
13 | {
14 | m_right = Normalize(Cross(rUp, m_direction));
15 | m_up = Normalize(Cross(m_direction, m_right));
16 | }
17 |
18 |
19 | void JRTOrthoCamera::GetRay(float s, float t, Vec3f* origin, Vec3f* delta) const
20 | {
21 | *delta = Normalize(m_direction);
22 |
23 | // map s,t into -0.5 to 0.5 space, and invert t
24 | s -= 0.5f;
25 | t -= 0.5f;
26 | t *= -1;
27 |
28 | // use that to compute offsets from camera origin
29 | Vec3f dx = m_right * (s * m_fSize);
30 | Vec3f dy = m_up * (t * m_fSize * m_fAspect);
31 | *origin = m_position + dx + dy;
32 |
33 | }
34 |
35 |
36 | void JRTOrthoCamera::ProjectPoint(const Vec3f& /*pt*/, float* /*s*/, float* /*t*/) const
37 | {
38 | // TODO
39 | JRT_ASSERT(false);
40 | }
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTOrthoCamera.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_ORTHO_CAMERA_H_
7 | #define _JRT_ORTHO_CAMERA_H_
8 |
9 | #include "JRTCamera.h"
10 |
11 |
12 | class JRTOrthoCamera : public JRTCamera
13 | {
14 | public:
15 | JRTOrthoCamera(const Vec3f& position, const Vec3f& direction, const Vec3f& up, float fSize);
16 |
17 | virtual void GetRay(float s, float t, Vec3f* origin, Vec3f* delta) const ;
18 |
19 | virtual void SetAspectRatio(float fAspect) { m_fAspect = fAspect; };
20 |
21 | // returns the position of the given point in camera NDC space
22 | // if the point is not visible, s and t are each set to -1
23 | virtual void ProjectPoint(const Vec3f& pt, float* s, float* t) const ;
24 |
25 | const Vec3f& GetPosition() const { return m_position; };
26 | const Vec3f& GetDirection() const { return m_direction; };
27 | const Vec3f& GetUp() const { return m_up; };
28 |
29 | private:
30 |
31 | float m_fSize;
32 | float m_fAspect;
33 | Vec3f m_position;
34 | Vec3f m_direction;
35 | Vec3f m_up;
36 | Vec3f m_right;
37 | };
38 |
39 |
40 |
41 |
42 |
43 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTPPMImage.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _IMAGE_H_
7 | #define _IMAGE_H_
8 |
9 |
10 | typedef struct tag_pixel
11 | {
12 | unsigned char r;
13 | unsigned char g;
14 | unsigned char b;
15 |
16 | } PIXEL;
17 |
18 |
19 | class JRTPPMImage
20 | {
21 |
22 | public:
23 | /***************************
24 | * Image Constructor:
25 | * Sets the width and height of the image, in pixels
26 | * allocates memory for pixels. Each pixel is initialized to
27 | * 0,0,0 (black)
28 | ***************************/
29 | JRTPPMImage(int width = 256, int height = 256);
30 |
31 | JRTPPMImage(const JRTPPMImage& img);
32 |
33 | const JRTPPMImage& operator=(const JRTPPMImage& img);
34 |
35 | /***************************
36 | * Image Destructor:
37 | * Frees all dynamic memory.
38 | ***************************/
39 | virtual ~JRTPPMImage();
40 |
41 | /***************************
42 | * Accessors/Mutators:
43 | * Accessors for width and height are provided.
44 | * they return the width or height of the image, in pixels
45 | ***************************/
46 | inline int GetHeight() const { return p_miHeight;};
47 | inline int GetWidth() const { return p_miWidth;};
48 |
49 |
50 |
51 | void SetPixel(int x, int y, float r, float g, float b);
52 |
53 |
54 | /***********************************************************
55 | * SaveFile
56 | * Outputs the image to a PPM (P6) file
57 | * with the specified filename. Returns true if the
58 | * output was a success, false if not.
59 | *********************************************************/
60 | bool SaveFile(const char* sFile);
61 |
62 | /*********************************************************
63 | * LoadFile
64 | * Loads an image from a PPM (P6) file
65 | * with the specified filename. Returns true if
66 | * the image was loaded ok. False if it was not
67 | *
68 | ************************************************************/
69 | bool LoadFile(const char* sFile);
70 |
71 | private:
72 |
73 | void AllocPixels(int iWidth, int iHeight);
74 | void FreePixels();
75 |
76 | PIXEL* AccessPixel(int x, int y);
77 |
78 | PIXEL* p_mlpPixels;
79 | int p_miHeight;
80 | int p_miWidth;
81 |
82 | };
83 |
84 |
85 | #endif
86 |
87 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/JRT/JRTTriangleIntersection.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JRT_TRIANGLE_INTERSECTION_H_
7 | #define _JRT_TRIANGLE_INTERSECTION_H_
8 |
9 | #include "JRTCommon.h"
10 |
11 | // Note to self: P4 cache lines: 64 bytes
12 |
13 | class JRTMesh;
14 |
15 |
16 | // JRTCoreTriangle is a struct which stores all of the information needed to perform
17 | // ray-triangle intersection. Some preprocessing is performed on the triangles to optimize the
18 | // intersection calculation.
19 | struct JRTCoreTriangle
20 | {
21 | // Nu and Nv are the smaller two components of the normal, divided by
22 | // the largest component of the normal. This eliminates some multiplies
23 | // from the intersection code (Ingo wald thought of this, not me)
24 | float Nu;
25 | float Nv;
26 |
27 | // Nd is equal to -d, where d is the D term of the plane equation (ax + by + cz + d = 0)
28 | float Nd;
29 |
30 | // largest component of normal 0 = x, 1 = y, 2 = z
31 | // this determines what plane to project into to compute barycentrics
32 | UINT max_normal_comp;
33 |
34 | JRTMesh* pMesh; // pointer back to the mesh
35 | UINT nTriIndex; // index of this triangle in the mesh
36 |
37 | // one of the vertices, projected into the 2D plane of choice
38 | float V0u;
39 | float V0v;
40 |
41 | // the two vectors from V0 to the other vertices, projected
42 | // and scaled by 1/E1xE2
43 | float E1u;
44 | float E1v; // first is vector from v0 to v1
45 |
46 | float E2u; // second is vector from v0 to v2
47 | float E2v;
48 | };
49 |
50 |
51 |
52 |
53 | /**
54 | This function performs some pre-processing on a triangle to get it read for use by the
55 | ray-triangle intersector. This function does all kinds of magical pre-computation which allows
56 | the actual intersection code to be good and fast.
57 |
58 | The first three arguments are pointers to the vertex positions of the triangle (3-component float arrays).
59 |
60 | The last argument is a pointer to a Preprocessed triangle structure that will be filled with
61 | the pre-computed triangle information that the intersector uses.
62 | */
63 | void PreprocessTri(const float* v1, const float* v2, const float* v3, JRTCoreTriangle* triOut1);
64 |
65 |
66 |
67 | /**
68 | Ray-Triangle Intersection routine:
69 | Arguments:
70 | tri - preprocessed triangle to be tested for intersection
71 | origin - ray origin
72 | direction - ray direction
73 | tmin, tmax - t value intervals to test for
74 | tout - pointer to a variable to receive the t value
75 | may NOT be null
76 | barycentrics - pointer to an array to receive the barycentric coordinates of the hit point,
77 | may be NULL
78 |
79 | If there is an intersection with t values ranging between tmin and tmax, then
80 | *tout and barycentrics are set, and true is returned
81 |
82 | If there is no such intersection, then the values of *tout and barycentrics do not change
83 | and false is returned
84 | */
85 | bool RayTriangleIntersect(const JRTCoreTriangle* pTriInfo, const float* origin, const float* direction, float tmin, float tmax, float* tout, float barcentrics_out[3]);
86 |
87 |
88 |
89 |
90 |
91 |
92 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/Math/JML.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JML_H_
7 | #define _JML_H_
8 |
9 | #ifdef _LINUX
10 | #define ALIGN16
11 | #else
12 | // helpful alias for 16-byte alignment
13 | #define ALIGN16 __declspec(align(16))
14 | #endif
15 |
16 | #include "JMLVec2.h"
17 | #include "JMLVec3.h"
18 | #include "JMLMatrix.h"
19 | #include "JMLFuncs.h"
20 |
21 |
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/Math/JMLFuncs.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JML_FUNCS_H_
7 | #define _JML_FUNCS_H_
8 |
9 |
10 | #include
11 | #include
12 |
13 | #include "JMLVec2.h"
14 | #include "JMLVec3.h"
15 | #include "JMLMatrix.h"
16 | #include "JMLSSEVec.h"
17 |
18 | const float PI = 3.1415926f;
19 | const float E = 2.718281828f;
20 | #define Max(f1,f2) ((f1>f2) ? f1 : f2 )
21 | #define Min(f1,f2) ((f1
18 | class Matrix
19 | {
20 | public:
21 |
22 | Matrix()
23 | {
24 | // initialize to identity
25 | for (int i = 0; i < SIZE * SIZE; i++)
26 | {
27 | if (i % (SIZE + 1) == 0)
28 | {
29 | m_values[i] = (T)1;
30 | }
31 | else
32 | {
33 | m_values[i] = (T)0;
34 | }
35 | }
36 | };
37 |
38 | Matrix(const T values[(SIZE * SIZE)])
39 | {
40 | memcpy(m_values, values, (SIZE * SIZE)*sizeof(T));
41 | };
42 |
43 | Matrix(const Matrix& rhs)
44 | {
45 | *this = rhs;
46 | };
47 |
48 | const Matrix& operator=(const Matrix& rhs)
49 | {
50 | memcpy(m_values, rhs.m_values, (SIZE * SIZE)*sizeof(T));
51 | return *this;
52 | };
53 |
54 | /// Returns pointer to matrix data in COLUMN-major order
55 | const T* GetValues() const { return m_values; };
56 | T* GetValues() { return m_values; };
57 |
58 | operator const T* () const { return (const T*) this; };
59 |
60 | operator T* () { return (T*) this; };
61 |
62 | Matrix& operator *= (const Matrix& rhs)
63 | {
64 | T newdata[(SIZE * SIZE)];
65 | int i, j, x;
66 |
67 | for (j = 0; j < SIZE; j++)
68 | {
69 | for (i = 0; i < SIZE; i++)
70 | {
71 | /** loop across ith row and down jth column **/
72 | newdata[(SIZE * i) + j] = 0.0;
73 |
74 | for (x = 0; x < SIZE; x++)
75 | {
76 | newdata[(SIZE * i) + j] += m_values[(SIZE * i) + x] * rhs.m_values[(SIZE * x) + j];
77 | }
78 | }
79 | }
80 |
81 | memcpy(m_values, newdata, 16 * sizeof(T));
82 | };
83 |
84 | Matrix operator* (const Matrix& rhs) const
85 | {
86 | T newdata[(SIZE * SIZE)];
87 | int i, j, x;
88 |
89 | for (j = 0; j < SIZE; j++)
90 | {
91 | for (i = 0; i < SIZE; i++)
92 | {
93 | /** loop across ith row and down jth column **/
94 | newdata[(SIZE * i) + j] = 0.0;
95 |
96 | for (x = 0; x < SIZE; x++)
97 | {
98 | newdata[(SIZE * i) + j] += m_values[(SIZE * i) + x] * rhs.m_values[(SIZE * x) + j];
99 | }
100 | }
101 | }
102 |
103 | return Matrix(newdata);
104 | }
105 |
106 | Matrix Transpose() const
107 | {
108 | T newdata[(SIZE * SIZE)];
109 |
110 | int i, j;
111 |
112 | for (i = 0; i < SIZE; i++)
113 | {
114 | for (j = 0; j < SIZE; j++)
115 | {
116 | /** loop across ith row and down jth column **/
117 | newdata[(SIZE * j) + i] = m_values[(SIZE * i) + j];
118 | }
119 | }
120 |
121 | return Matrix(newdata);
122 | };
123 |
124 | void Set(unsigned int row, unsigned int col, T val)
125 | {
126 | m_values[(col * SIZE) + row ] = val;
127 | };
128 |
129 | T Get(unsigned int row, unsigned int col) const
130 | {
131 | return m_values[(col * SIZE) + row ];
132 | };
133 |
134 | private:
135 |
136 | T m_values[(SIZE * SIZE)];
137 |
138 | };
139 |
140 |
141 | typedef Matrix Matrix2f;
142 | typedef Matrix Matrix3f;
143 | typedef Matrix Matrix4f;
144 |
145 | typedef Matrix Matrix2d;
146 | typedef Matrix Matrix3d;
147 | typedef Matrix Matrix4d;
148 |
149 | };
150 |
151 |
152 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/Math/JMLScalar.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JML_SCALAR_H_
7 | #define _JML_SCALAR_H_
8 |
9 | #include
10 | #include
11 |
12 | namespace JML
13 | {
14 | inline float RandomFloat()
15 | {
16 | return (float)rand() / (float) RAND_MAX;
17 | };
18 |
19 |
20 | inline float FastSQRT(float v)
21 | {
22 | __m128 val = _mm_load1_ps(&v);
23 | val = _mm_sqrt_ss(val);
24 | return val.m128_f32[0];
25 | };
26 |
27 | inline float FastRSQ(float v)
28 | {
29 | __m128 val = _mm_load1_ps(&v);
30 | val = _mm_rsqrt_ss(val);
31 | float frsq = val.m128_f32[0];
32 | return (0.5f * frsq) * (3.0f - (v * frsq) * frsq);
33 | };
34 |
35 | };
36 |
37 |
38 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/Math/JMLVec2.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JML_VEC2_H_
7 | #define _JML_VEC2_H_
8 |
9 |
10 | namespace JML
11 | {
12 | /// \brief A template class for two-component vectors.
13 | /**
14 | The template argument must be a numeric type
15 | */
16 | template
17 | class Vec2
18 | {
19 | public:
20 |
21 | T x;
22 | T y;
23 |
24 | // *****************************************
25 | // Constructors
26 | // *****************************************
27 |
28 | /// Default constructor
29 | Vec2() : x((T)0), y((T)0) {};
30 |
31 | /// Value constructor
32 | Vec2(const T& vx, const T& vy) : x(vx), y(vy) {};
33 |
34 | /// Copy constructor
35 | Vec2(const Vec2& val) : x(val.x), y(val.y) {};
36 |
37 | /// Single value constructor. Sets all components to the given value
38 | Vec2(const T& v) : x(v), y(v) {};
39 |
40 |
41 | // *****************************************
42 | // Conversions/Assignment/Indexing
43 | // *****************************************
44 |
45 | /// cast to T*
46 | operator const T* () const { return (const T*)this; };
47 |
48 | /// cast to T*
49 | operator T* () { return (T*)this; };
50 |
51 | /// Indexing
52 | const T& operator[](int i) const { return ((const T*)this)[i]; };
53 | T& operator[](int i) { return ((T*)this)[i]; };
54 |
55 | /// Assignment
56 | const Vec2& operator=(const Vec2& rhs) { x = rhs.x; y = rhs.y; return *this; };
57 |
58 | // *****************************************
59 | // Comparison
60 | // *****************************************
61 |
62 | /// Equality comparison
63 | bool operator==(const Vec2& rhs) const { return (x == rhs.x && y == rhs.y); };
64 |
65 | /// Inequality comparision
66 | bool operator!=(const Vec2& rhs) const { return (x != rhs.x || y != rhs.y); };
67 |
68 | // *****************************************
69 | // Arithmetic
70 | // *****************************************
71 |
72 | /// Addition
73 | const Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); };
74 |
75 | /// Subtraction
76 | const Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y);};
77 |
78 | /// Multiply by scalar
79 | const Vec2 operator*(const T& v) const { return Vec2(x * v, y * v); };
80 |
81 | /// Divide by scalar
82 | const Vec2 operator/(const T& v) const { return Vec2(x / v, y / v); };
83 |
84 | /// Addition in-place
85 | Vec2& operator+= (const Vec2& rhs) { x += rhs.x; y += rhs.y; return *this; };
86 |
87 | /// Subtract in-place
88 | Vec2& operator-= (const Vec2& rhs) { x -= rhs.x; y -= rhs.y; return *this; };
89 |
90 | /// Scalar multiply in-place
91 | Vec2& operator*= (const T& v) { x *= v; y *= v; return *this; };
92 |
93 | /// Scalar divide in-place
94 | Vec2& operator/= (const T& v) { x /= v; y /= v; return *this; };
95 |
96 |
97 | };
98 |
99 | /// stream output
100 | template
101 | std::ostream& operator<<(std::ostream& sout, const Vec2& vec)
102 | {
103 | sout << "<" << vec.x << "," << vec.y << ">";
104 | return sout;
105 | };
106 |
107 | typedef Vec2 Vec2f;
108 | typedef Vec2 Vec2d;
109 | typedef Vec2 Vec2i;
110 |
111 |
112 |
113 |
114 | };
115 |
116 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/Math/JMLVec3.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _JML_VEC3_H_
7 | #define _JML_VEC3_H_
8 |
9 |
10 | namespace JML
11 | {
12 | /// \brief A template class for two-component vectors.
13 | /**
14 | The template argument must be a numeric type
15 | */
16 | template
17 | class Vec3
18 | {
19 | public:
20 |
21 | T x;
22 | T y;
23 | T z;
24 |
25 | // *****************************************
26 | // Constructors
27 | // *****************************************
28 |
29 | /// Default constructor
30 | Vec3() : x((T)0), y((T)0), z((T)0) {};
31 |
32 | /// Value constructor
33 | Vec3(const T& vx, const T& vy, const T& vz) : x(vx), y(vy), z(vz) {};
34 |
35 | /// Copy constructor
36 | Vec3(const Vec3& val) : x(val.x), y(val.y), z(val.z) {};
37 |
38 | /// Single value constructor. Sets all components to the given value
39 | Vec3(const T& v) : x(v), y(v), z(v) {};
40 |
41 | /// Array constructor. Assumes a 3-component array
42 | Vec3(const T* v) : x(v[0]), y(v[1]), z(v[2]) {};
43 |
44 | // *****************************************
45 | // Conversions/Assignment/Indexing
46 | // *****************************************
47 |
48 | /// cast to T*
49 | operator const T* () const { return (const T*)this; };
50 |
51 | /// cast to T*
52 | operator T* () { return (T*)this; };
53 |
54 | /// Assignment
55 | const Vec3& operator=(const Vec3& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; return *this; };
56 |
57 | // *****************************************
58 | // Comparison
59 | // *****************************************
60 |
61 | /// Equality comparison
62 | bool operator==(const Vec3& rhs) const { return (x == rhs.x && y == rhs.y && z == rhs.z); };
63 |
64 | /// Inequality comparision
65 | bool operator!=(const Vec3& rhs) const { return (x != rhs.x || y != rhs.y || z != rhs.z); };
66 |
67 | // *****************************************
68 | // Arithmetic
69 | // *****************************************
70 |
71 | /// Addition
72 | const Vec3 operator+(const Vec3& rhs) const { return Vec3(x + rhs.x, y + rhs.y, z + rhs.z); };
73 |
74 | /// Subtraction
75 | const Vec3 operator-(const Vec3& rhs) const { return Vec3(x - rhs.x, y - rhs.y, z - rhs.z);};
76 |
77 | /// Multiply by scalar
78 | const Vec3 operator*(const T& v) const { return Vec3(x * v, y * v, z * v); };
79 |
80 | /// Divide by scalar
81 | const Vec3 operator/(const T& v) const { return Vec3(x / v, y / v, z / v); };
82 |
83 | /// Divide by vector
84 | const Vec3 operator/(const Vec3& rhs) const { return Vec3(x / rhs.x, y / rhs.y, z / rhs.z); };
85 |
86 | /// Addition in-place
87 | Vec3& operator+= (const Vec3& rhs) { x += rhs.x; y += rhs.y; z += rhs.z; return *this; };
88 |
89 | /// Subtract in-place
90 | Vec3& operator-= (const Vec3& rhs) { x -= rhs.x; y -= rhs.y; z -= rhs.z; return *this; };
91 |
92 | /// Scalar multiply in-place
93 | Vec3& operator*= (const T& v) { x *= v; y *= v; z *= v; return *this; };
94 |
95 | /// Scalar divide in-place
96 | Vec3& operator/= (const T& v) { x /= v; y /= v; z /= v; return *this; };
97 | };
98 |
99 | /// stream output
100 | template
101 | std::ostream& operator<<(std::ostream& sout, const Vec3& vec)
102 | {
103 | sout << "<" << vec.x << "," << vec.y << "," << vec.z << ">";
104 | return sout;
105 | };
106 |
107 | typedef Vec3 Vec3f;
108 | typedef Vec3 Vec3d;
109 | typedef Vec3 Vec3i;
110 |
111 | };
112 |
113 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/TootleRaytracer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 |
7 | #ifndef _TOOTLE_RAYTRACER_H_
8 | #define _TOOTLE_RAYTRACER_H_
9 |
10 |
11 | class JRTCore;
12 | class JRTMesh;
13 | class JRTOrthoCamera;
14 |
15 | #include
16 |
17 | struct TootleRayHit;
18 |
19 | /// An overdraw table is a table that determines, for a pair of faces, how much one face overdraws the other
20 | typedef std::vector< std::vector > TootleOverdrawTable;
21 |
22 |
23 | /// \brief A class which resolves triangle visibility for Tootle, using ray tracing.
24 | class TootleRaytracer
25 | {
26 | public:
27 | TootleRaytracer();
28 |
29 | ~TootleRaytracer();
30 |
31 | /// Initializes the ray tracer and builds all of the necessary data structures
32 | bool Init(const float* pVertexPositions, const unsigned int* pIndices, const float* pFaceNormals, unsigned int nVertices,
33 | unsigned int nFaces, const unsigned int* pFaceClusters);
34 |
35 | /// Computes an overdraw table for a set of viewpoints.
36 | bool CalculateOverdraw(const float* pViewpoints, unsigned int nViewpoints, unsigned int nImageSize,
37 | bool bCullCCW, TootleOverdrawTable* pODArray);
38 |
39 | // Measure the overdraw for a set of viewpoints.
40 | bool MeasureOverdraw(const float* pViewpoints, UINT nViewpoints, UINT nImageSize, bool bCullCCW, float& fAvgODOut, float& fMaxODOut);
41 |
42 | /// Cleans up the internal data structures
43 | void Cleanup();
44 |
45 | private:
46 |
47 |
48 | /// Renders the scene from a particular camera position and updates the overdraw array
49 | bool ProcessViewpoint(const float* pCameraPosition, unsigned int nImageSize, bool bCullCCW, TootleOverdrawTable* pODArray);
50 |
51 | /// Renders the scene from a particular camera position and measures the overdraw
52 | bool ProcessViewpoint(const float* pCameraPosition, unsigned int nImageSize, bool bCullCCW,
53 | unsigned int& nPixelHit, unsigned int& nPixelDrawn);
54 |
55 | /// Updates the overdraw table with overdraw that occurs for a particular pixel in the test image
56 | void ProcessPixel(TootleRayHit* pRayHit, unsigned int nHits, TootleOverdrawTable* pODArray);
57 |
58 | /// Compute the number of times for a particular pixel is drawn by the mesh
59 | void GetPixelDrawn(TootleRayHit* pRayHits, UINT nHits, UINT& nPixelOverdrawn);
60 |
61 | const unsigned int* m_pFaceClusters;
62 | JRTCore* m_pCore;
63 | JRTMesh* m_pMesh;
64 | };
65 |
66 | #endif
--------------------------------------------------------------------------------
/src/TootleLib/RayTracer/makefile:
--------------------------------------------------------------------------------
1 | CC = g++ -O3 -fpermissive -msse -D_SOFTWARE_ONLY_VERSION -D_LINUX
2 | #CC = g++ -g -Wall -fpermissive -msse -D_SOFTWARE_ONLY_VERSION -D_LINUX
3 |
4 | TOP = ../../..
5 | TARGET = ${TOP}/lib/libRayTracer.a
6 | RTJRT = JRT
7 | RTMATH = Math
8 |
9 | CFLAGS = -I. -I../ -I../include -I${RTJRT} -I${RTMATH}
10 |
11 | LDFlags = -lm
12 |
13 | OBJECTS = TootleRaytracer.o ${RTJRT}/JRTBoundingBox.o ${RTJRT}/JRTCamera.o ${RTJRT}/JRTCore.o ${RTJRT}/JRTCoreUtils.o ${RTJRT}/JRTH2KDTreeBuilder.o ${RTJRT}/JRTHeuristicKDTreeBuilder.o ${RTJRT}/JRTKDTree.o ${RTJRT}/JRTKDTreeBuilder.o ${RTJRT}/JRTMesh.o ${RTJRT}/JRTOrthoCamera.o ${RTJRT}/JRTPPMImage.o ${RTJRT}/JRTTriangleIntersection.o ${RTMATH}/JMLFuncs.o
14 |
15 | CLEAN = ${TARGET} ${OBJECTS} *.o
16 |
17 | RayTracer: ${OBJECTS}
18 | ar -rs ${TARGET} *.o
19 |
20 | .cpp.o:
21 | ${CC} ${CFLAGS} -c $<
22 |
23 | .c.o:
24 | ${CC} ${CFLAGS} -c $<
25 |
26 | clean:
27 | /bin/rm -f ${CLEAN}
28 |
--------------------------------------------------------------------------------
/src/TootleLib/Timer.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #include "TootlePCH.h"
7 | #ifdef _WIN32
8 | #include
9 | #else
10 | #include
11 | #include
12 | #endif
13 |
14 | #include "Timer.h"
15 |
16 | Timer::
17 | Timer()
18 | {
19 | Reset();
20 | }
21 |
22 | void
23 | Timer::
24 | Reset(void)
25 | {
26 | time = Get();
27 | }
28 |
29 | double
30 | Timer::
31 | GetElapsed(void)
32 | {
33 | return Get() - time;
34 | }
35 |
36 | double
37 | Timer::Get(void)
38 | {
39 | #ifdef _WIN32
40 | FILETIME ft;
41 | GetSystemTimeAsFileTime(&ft);
42 | return ft.dwLowDateTime / 1.0e7 + ft.dwHighDateTime * (4294967296.0 / 1.0e7);
43 | #else
44 | struct timeval v;
45 | gettimeofday(&v, (struct timezone*) NULL);
46 | return v.tv_sec + v.tv_usec / 1.0e6;
47 | #endif
48 | }
49 |
--------------------------------------------------------------------------------
/src/TootleLib/Timer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _TIMER_H
7 | #define _TIMER_H
8 |
9 | class Timer
10 | {
11 | public:
12 | Timer();
13 | void Reset(void);
14 | double GetElapsed(void);
15 | double Get(void);
16 | private:
17 | double time;
18 | };
19 |
20 | #endif // _TIME_H
21 |
--------------------------------------------------------------------------------
/src/TootleLib/TootlePCH.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************//**
2 | // Copyright (c) 2006-2015 Advanced Micro Devices, Inc. All rights reserved.
3 | /// \author AMD Developer Tools Team
4 | /// \file
5 | ****************************************************************************************/
6 | #ifndef _TOOTLEPCH_H_
7 | #define _TOOTLEPCH_H_
8 |
9 | // disable VC++ 2K5 warnings about deprecated standard C functions
10 | #if defined( _MSC_VER )
11 | #if _MSC_VER >= 1400
12 | #define _CRT_SECURE_NO_DEPRECATE
13 | #endif
14 | #endif
15 |
16 | #ifdef _LINUX
17 | #define __cdecl
18 | #define _isnan(x) isnan(x)
19 | #define _finite(x) finite(x)
20 | #endif
21 |
22 | #ifdef __cplusplus
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include