Skip to content

Commit

Permalink
feat: Modify testrender to work with triangle meshes (#1865)
Browse files Browse the repository at this point in the history
testrender was originally envisioned as a tiny example renderer that should only handle spheres/planes. Over time several groups have expressed the wish for it to handle arbitrary geometry instead. This PR replaces the sphere and quad primitives with triangle meshes.

I am making use of the (embedded) rapidobj library to load models in the .obj format. The original .xml scene format remains, so that you can combine several models together as well as declare and assign the osl shader networks you want to these meshes. For backwards compatibility, spheres and planes are still supported via tessellation (you specify how many subdivisions you want). In the case of .obj scenes, the shader assignment can be done either by the mesh name or the material name.

I am submitting this to get the review kickstarted. The history of commits includes some fairly large test scenes that should be squashed away to go into the main repo. Files over 50Mb are recommended to use git lfs, but we probably want to figure that out as a different task (possibly handle it via a separate repo).

The handling of derivatives is not totally correct yet, but the behavior is compatible with the previous (incorrect) handling of derivatives we had before.


---------

Signed-off-by: Chris Kulla <[email protected]>
  • Loading branch information
fpsunflower authored Sep 20, 2024
1 parent 709c5ff commit 78e5392
Show file tree
Hide file tree
Showing 82 changed files with 16,340 additions and 437 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ build
*.log
.vscode
.envrc

.DS_Store
4 changes: 4 additions & 0 deletions src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ macro ( TESTSUITE )
# Run the test unoptimized, unless it matches a few patterns that
# we don't test unoptimized (or has an OPTIMIZEONLY marker file).
if (NOT _testname MATCHES "optix"
AND NOT _testname MATCHES "render"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
Expand All @@ -137,6 +138,7 @@ macro ( TESTSUITE )
# services keeping unoptimized, unless it matches a few patterns that
# we don't test unoptimized (or has an OPTIMIZEONLY marker file).
if (NOT _testname MATCHES "optix"
AND NOT _testname MATCHES "render"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY"
Expand All @@ -159,6 +161,7 @@ macro ( TESTSUITE )
# optimization, triggered by setting TESTSHADE_OPT env variable.
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
if (NOT _testname MATCHES "optix"
AND NOT _testname MATCHES "render"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE"
Expand Down Expand Up @@ -350,6 +353,7 @@ macro (osl_add_all_tests)
raytype raytype-reg raytype-specialized regex-reg
reparam reparam-arrays reparam-string testoptix-reparam
render-background render-bumptest
render-bunny
render-cornell render-furnace-diffuse
render-mx-furnace-burley-diffuse
render-mx-furnace-oren-nayar
Expand Down
7 changes: 6 additions & 1 deletion src/testrender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
set (testrender_srcs
shading.cpp
simpleraytracer.cpp
scene.cpp
bvh.cpp
testrender.cpp)

find_package(Threads REQUIRED)

if (OSL_USE_OPTIX)
list (APPEND testrender_srcs optixraytracer.cpp)
set (testrender_cuda_srcs
Expand Down Expand Up @@ -69,7 +73,8 @@ add_executable (testrender ${testrender_srcs})
target_link_libraries (testrender
PRIVATE
oslexec oslquery
pugixml::pugixml)
pugixml::pugixml
Threads::Threads)

osl_optix_target (testrender)

Expand Down
Loading

0 comments on commit 78e5392

Please sign in to comment.