Commit 41d8aa64 authored by Joel Macht's avatar Joel Macht
Browse files

Initial commit

parents
regression/*.res
regression/report.html
regression/*/testrender_fb00.pfm
regression/*/testrender_fb00.txt
regression/*/testrender.png
regression/*/reference.pfm
regression/*/reference.txt
regression/*/reference.png
regression/*/??_bsdf*
regression/*/??_ebsdf*
regression/*/??_pdf*
regression/*/??_epdf*
regression/*/*.svg
regression/*/usertime
regression/*/wallclock
regression/*/*log
regression/geo/*
ext/pthread-pool/*.o
ext/pthread-pool/libpthreadpool.a
tools/img/bakesky
tools/img/dbor
tools/img/dbord
tools/img/exr2pfm
tools/img/pfm2exr
tools/img/pfm2fb
tools/img/pfm2hdr
tools/img/pfmdiff
tools/img/ppm2fb
tools/img/*.comp.spv
tools/vol/ovdb2vol
tools/vol/voltest
tools/geo/geo-createuvs
tools/geo/geo-disp
tools/geo/geo-make
tools/geo/geo-subdiv
tools/geo/obj2geo
tools/geo/obj2particles
tools/gradient/poissonsolve
tools/gradient/cgsolve
data/ergb2spec.coeff
data/xyz2spec.coeff
corona
arch
config.mk
shaders/
This diff is collapsed.
CC=gcc
CFLAGS+=-fPIC -fno-strict-aliasing -std=c11 -Wall -pipe -I/usr/include -Ibuild/ -I. -Iinclude/ -Icamera/ -Iext/pthread-pool/ -D_GNU_SOURCE -g
# openvdb will be appended for all but -I
OPENVDB_PATH=ext/openvdb_dev
#CFLAGS+=-Werror -Wno-error=maybe-uninitialized
LDFLAGS=-lm -lc -ldl -rdynamic -Lext/pthread-pool/ -lpthreadpool -pthread -Wl,-rpath,'$$ORIGIN/shaders'
SHARED=-shared
# dr dobb's idea about makefile debugging:
OLD_SHELL := $(SHELL)
# SHELL = $(warning [$@ ($^) ($?)])$(OLD_SHELL)
SHELL = $(warning [$@ ($?)])$(OLD_SHELL)
.PHONY: all clean debug modules modules_clean
include config.mk
CFLAGS+=-Icamera/$(CAMERA_LENS)/
CFLAGS+=-Isrc/pointsampler.d/ # for vmlt.h
MOD_HEADERS=\
build/filter.h \
build/vmlt_registry.h\
build/colourspaces.h
MOD_SOURCES=\
$(EXTRA_SOURCES)\
src/accel.d/$(MOD_accel).c\
src/camera.d/$(MOD_camera).c\
src/display.d/$(MOD_display).c\
src/points.d/$(MOD_points).c\
src/pointsampler.d/$(MOD_pointsampler).c\
src/render.d/$(MOD_render).c\
src/sampler.d/$(MOD_sampler).c\
src/lights.d/$(MOD_lights).c
CAMERA_HEADERS=\
camera/$(CAMERA_LENS)/init.h\
camera/$(CAMERA_LENS)/pt_evaluate.h\
camera/$(CAMERA_LENS)/pt_evaluate_aperture.h\
camera/$(CAMERA_LENS)/pt_sample_aperture.h\
camera/$(CAMERA_LENS)/lt_sample_aperture.h\
camera/$(CAMERA_LENS)/pt_evaluate_jacobian.h\
camera/$(CAMERA_LENS)/pt_evaluate_aperture_jacobian.h
STATIC_HEADERS=\
camera/lens.h\
include/corona_common.h\
include/camera.h\
include/render.h\
include/view.h\
include/points.h\
include/sampler.h\
include/spectrum.h\
include/pointsampler.h\
include/lbvh.h\
include/dbor.h\
include/fakegaussian.h\
include/distancemap.h\
include/quaternion.h\
include/rgb2spec.h\
include/shader.h\
include/prims.h \
include/geo.h \
include/geo/line.h\
include/geo/sphere.h\
include/geo/triangle.h\
include/pathspace/manifold.h\
include/pathspace/measurement.h\
include/pathspace/raydifferentials.h\
include/pathspace/nee.h\
include/pathspace/mnee.h\
include/pathspace/tech.h\
include/screenshot.h\
include/lights.h
STATIC_SOURCES=\
src/corona_common.c\
src/shader.c\
src/view.c\
src/pathspace.c\
src/pathspace/tech.c\
src/prims.c\
src/screenshot.c\
src/main.c
# veach mlt subsystem required for vmlt and erpt
ifeq ($(MOD_pointsampler),vmlt)
STATIC_SOURCES+=src/pathspace/vmlt.c
endif
ifeq ($(MOD_render),erpt)
STATIC_SOURCES+=src/pathspace/vmlt.c
endif
debug:CFLAGS+=-gdwarf-2 -ggdb3 -msse2 -mfpmath=sse -O0
debug:LDFLAGS+=-lm -lc -ldl -lrt -lX11 -rdynamic -Lext/pthread-pool/ -lpthreadpool -pthread -Wl,-rpath,'$$ORIGIN/shaders'
debug:corona modules
# use address sanitizer feature of clang. run with:
# ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-6.0/bin/llvm-symbolizer ./corona
# or whatever the path in your system if it's not in $PATH.
sanitize:CFLAGS+=-O0 -ggdb3 -msse2 -mfpmath=sse -fsanitize=address -fno-omit-frame-pointer
# sanitize:CFLAGS+=-O1 -fsanitize=address -fno-omit-frame-pointer
sanitize:LDFLAGS+=-fsanitize=address
sanitize:corona modules
config.mk arch:
@echo -e " \033[1m\033[33m*\033[30m\033[0m please configure the build for your processor and rendering needs:"
@echo -e " \033[1m\033[33m*\033[30m\033[0m cp arch.example arch; cp config.mk.example config.mk" && false
build/%.h : include/%*.h Makefile config.mk
@cp -f include/$*_$(value BUILD_MOD_$*).h $@
build/%.c : src/%*.c Makefile config.mk
@cp -f src/$*_$(value BUILD_MOD_$*).c $@
# configure colour spaces
build/colourspaces.h: Makefile config.mk
@echo "#pragma once" > build/colourspaces.h
@echo "// generated during build, do not edit." >> build/colourspaces.h
@for file in include/colour/*.h; do \
echo \#include \"$$file\" >> build/colourspaces.h;\
done
@echo "#define colour_input_to_xyz colour_${COL_input}_to_xyz" >> build/colourspaces.h
@echo "#define colour_xyz_to_input colour_xyz_to_${COL_input}" >> build/colourspaces.h
@echo "#define colour_input_print_info colour_${COL_input}_print_info" >> build/colourspaces.h
@echo "#define colour_output_to_xyz colour_${COL_output}_to_xyz" >> build/colourspaces.h
@echo "#define colour_xyz_to_output colour_xyz_to_${COL_output}" >> build/colourspaces.h
@echo "#define colour_output_print_info colour_${COL_output}_print_info" >> build/colourspaces.h
@echo "#define colour_camera_to_xyz colour_${COL_camera}_to_xyz" >> build/colourspaces.h
@echo "#define colour_xyz_to_camera colour_xyz_to_${COL_camera}" >> build/colourspaces.h
@echo "#define colour_camera_print_info colour_${COL_camera}_print_info" >> build/colourspaces.h
build:
mkdir -p build
# version header
# build/version.h: Makefile .git/FETCH_HEAD
build/version.h:
@echo "#ifndef CORONA_VERSION_H" > build/version.h
@echo "#define VERSION \"$(shell git describe --tags)\"" >> build/version.h
@echo "#endif" >> build/version.h
# veach metropolis configuration
build/vmlt_registry.h: Makefile config.mk
@printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n" $(foreach MUT,$(MUTATIONS),"#include \"vmlt_$(MUT).h\"") > build/vmlt_registry.h
@printf "static inline void vmlt_register_all(vmlt_t *t)\n{\n" >> build/vmlt_registry.h
@printf " %s\n %s\n %s\n %s\n %s\n %s\n %s\n" $(foreach MUT,$(MUTATIONS),"vmlt_register(t, &$(MUT)_init, &$(MUT)_cleanup, &$(MUT)_suitability, &$(MUT)_mutate, &$(MUT)_print_info);") >> build/vmlt_registry.h
@echo "}" >> build/vmlt_registry.h
build/filter.h: Makefile config.mk
@printf "#pragma once\n" > build/filter.h
@printf '#include "filter/box.h"\n' >> build/filter.h
@printf '#include "filter/blackmanharris.h"\n' >> build/filter.h
@printf "#define filter_splat filter_%s_splat\n" $(MOD_filter) >> build/filter.h
@printf "#define filter_splat4 filter_%s_splat4\n" $(MOD_filter) >> build/filter.h
@printf "#define filter_print_info filter_%s_print_info\n" $(MOD_filter) >> build/filter.h
ext/pthread-pool/libpthreadpool.a:
make -C ext/pthread-pool/
test:
make -C regression
# create tristimulus to spectrum upsampling luts:
COLOURLUTS=data/ergb2spec.coeff data/xyz2spec.coeff
tools/img/rgb2spec_opt:
make -C tools/img rgb2spec_opt
data/ergb2spec.coeff: tools/img/rgb2spec_opt
mkdir -p data
tools/img/rgb2spec_opt 64 $@ eRGB
data/xyz2spec.coeff: tools/img/rgb2spec_opt
mkdir -p data
tools/img/rgb2spec_opt 64 $@ XYZ
corona: build $(MOD_HEADERS) $(MOD_SOURCES) $(COLOURLUTS) $(CAMERA_HEADERS) $(STATIC_HEADERS) $(STATIC_SOURCES) Makefile arch build/version.h ext/pthread-pool/libpthreadpool.a
$(CC) $(CFLAGS) $(STATIC_SOURCES) $(MOD_SOURCES) -o corona $(LDFLAGS)
clean: modules_clean
rm -f corona
rm -f build/*
make -C ext/pthread-pool clean
SHADERS=color mult interior texture medium_rgb medium_poe dielectric diffdiel colorcheckersg metal medium_hete vdata medium_aggregate
ifneq (,$(findstring MF_COUNT,$(CFLAGS)))
# hero wavelength, need to disable a few non-ported bsdf :(
else
# single wavelength
SHADERS+=mmetal mdiffuse mdielectric hair
endif
SHADER_DEPEND=include/corona_common.h include/spectrum.h build/colourspaces.h include/shader.h Makefile
shaders/libdielectric.so:src/shaders/ggx.h
shaders/libmdielectric2.so:src/shaders/MicrosurfaceScattering.cpp src/shaders/MicrosurfaceScattering.h
shaders/libmmetal2.so:src/shaders/MicrosurfaceScattering.cpp src/shaders/MicrosurfaceScattering.h
shaders/libmdiffuse2.so:src/shaders/MicrosurfaceScattering.cpp src/shaders/MicrosurfaceScattering.h
shaders/libdiffdiel.so:src/shaders/ggx.h
shaders/libmdielectric.so:src/shaders/microfacet.h
shaders/libmetal.so:src/shaders/fresnel.h src/shaders/ggx.h
shaders/libmmetal.so:src/shaders/fresnel.h src/shaders/microfacet.h
shaders/libmdiffuse.so:src/shaders/microfacet.h
VOL_HEADERS=include/vol/types.h\
include/vol/vol.h\
include/vol/trace.h\
include/vol/trace_impl.inc\
include/vol/interpolation.h\
include/vol/payload.h\
include/vol/payload_compress.h\
include/vol/lighthierarchy.h\
include/vol/shaders.h\
include/vol/trace_octree.h
shaders/libmedium_hete.so:${VOL_HEADERS}
modules_clean:
rm -f shaders/*.so
modules: build $(MOD_HEADERS) $(MOD_SOURCES)
modules: CFLAGS+=-fPIC
modules: $(patsubst %,shaders/lib%.so,$(SHADERS)) \
shaders/libenvmap.so \
shaders/libconst.so
#shaders/libspectral.so # this is cool and we want it back!
shaders/lib%.so: src/shaders/%.c $(SHADER_DEPEND) # shaders
@mkdir -p shaders
$(CC) $(CFLAGS) $(SHARED) $< -o $@
shaders/libenvmap.so: src/shaders/sky_envmap.c $(SHADER_DEPEND)
$(CC) $(CFLAGS) $(SHARED) $< -I src/shaders/ -o $@
shaders/libspectral.so: src/shaders/sky_spectral.c $(SHADER_DEPEND)
$(CC) $(CFLAGS) $(SHARED) $< -I src/shaders/ -o $@
shaders/libconst.so: src/shaders/sky_const.c $(SHADER_DEPEND)
$(CC) $(CFLAGS) $(SHARED) $< -o $@
=======================
CORONA-13
=======================
=======================
QUICKSTART:
=======================
$ cp arch.example arch
$ cp config.mk.example config.mk
$ make
$ ./corona regression/0010_pt/test.nra2
keyboard control:
[;.] camera speed -/+ (dvorak)
[ye] camera speed -/+ (qwertz)
[12] exposure time
[34] f-stop
[56] focal len
[78] iso value
[c] save camera position
[l] load camera position
[p] print screenshot
[h] toggle display
quake movement, use left mouse button to turn
=======================
REQUIREMENTS:
=======================
m c dl pthread
optional:
GL SDL OpenVDB X11 tcmalloc avutil avcodec swscale
=======================
FEATURES:
=======================
ray tracing primitives:
- triangles, quads, cylinders/lines, spheres/points, distance field shells
acceleration structures:
- grid
- qbvh + shadow cache
- qbvh + motion blur
- qbvh + motion blur + parallel build
- bih
camera models:
- thinlens + chromatic aberration
- polynomial optics lens
- (obscura)
reflection models: programmable shaders with loadable modules:
- ashi (anisotropic phong reflection model)
- dielectric (rough/specular)
- metal (rough/specular)
- heterogeneous medium/openvdb
- homogeneous medium
- texture maps (diffuse, glossy, specular, emission, roughness)
- may be combined in any way (or: write your own)
point sets used for integration:
- simple and fast mersenne twister (SSE)
- halton points
- kelemen metropolis sampling
- veach metropolis sampling:
- large steps/bidirectional mutation
- multi chain
- lens perturbation
- vertex area sampling
- half vector space perturbation
- combined hslt
render modes:
- visibility and aov only
- timing (rdtsc shading)
- global illumination
- gradient domain sampling
- energy redistribution path tracing
sampling methods (unbiased):
- pt
- ptdl
- lt
- ptlt
- bdpt
- bdpt1
- ppm
- ptmnee
colour management:
- aces
- ergb (smits' srgb adapted to illuminant E)
- rec709
- srgb
- adobergb
- xyz
spectral upsampling:
- smits
- grid
threading:
- pinned pthread pool
- affinity file with list of cores
frontend:
- null: commandline, screenshots
- unix: X11 (pixeltoaster style)
- gl : opengl backend
- net : mpeg stream over tcp
screenshots:
- pfm : portable float maps
- dng : digital negative raw format
tools:
- convert pfm2exr, pfm2hdr, exr2dng
- obj2geo
- netrender viewer
- turntable camera creation
- bsdf battle tester
regression tests
=======================
BUILD AND INSTALL:
=======================
corona-13 follows a compile-your-own build strategy. rather than allowing a lot
of run-time options, most of the flexible modules are fixed at compile time.
you can edit these settings in the file config.mk:
$ cp config.mk.example config.mk
$ cp arch.example arch
and pick the modules you like best. also have a look at the file arch to suit
your hardware.
$ make
mpeg stream rendering:
corona features a render server interface through corona-net, built with
MOD_display=network. to use this, start corona as usual on the server. corona
will block and wait for a client connection. you can initiate one by typing
$ make corona-netrender -C tools/
$ tools/corona-netrender <ip-address or hostname>
client side. maybe you need to tunnel it through a firewall by using ssh before
launching corona-netrender:
$ ssh -f hostname -L 8090:hostname:8090 -N
enjoy!
=======================
ACKNOWLEDGEMENTS:
=======================
contributors:
neospark, daylight model, photon kd,
endless ideas (sky quad sampling, qbvh)
(GPLv3)
leo, halton points
john, pthread-pool
=======================
CHANGES:
=======================
13-th generation rt
(corona-13) : path space api, new geo backend, new threading backend, veach metropolis.
(corona-14) : simulated shading/ray tracing reordering
(corona-12) :
(corona-11) :
(corona-10)
`real-time rayes' : same on GPU with motion blur
(corona-9)
`rayes' : reyes style ray tracing with reordering
(corona-8) : procedural geo voxel octree ray tracing
(corona-7) : triangle mesh voxelized and ray traced
(corona-6)
`radiata' : spectral rendering!
(corona 5)
`riot' : ray i/o tracer, optimized for SIMD and FPGA
(corona 4)
`mod-rt' : c99, cp inheritance, unbiased light transport: pt, ptdl, lt
(corona 3)
`int-rt' : c99, cpp inheritance, lafortune-style bdpt, integer arith
(corona 2)
`spiessert': C++ inheritance, ray packets, boring state-of-the-art:
bih, kd[-ondemand] (parallel)
(corona 1)
`rearview' : npr, realtime, voxel based
cleanup:
- guided_extend vs guided_create_path?
- vertex area measure vs dwp
- use throughput or not? we are evaling the bsdf..
- don't refit vi==1 bvh but build from scratch with real bounds immediately
- only need one lbvh for first bounce, probably no extra index array
fixes:
- knn needs to consider first bounce gaussian!
- environment maps
- check index matched ior
bugs:
- pdf cache invalidation on edges (don't copy paths for mlt?)
- jacobian for vmlt->kmlt and transmit/reflect
vol:
- light sampling should work on edge->vol and vertex->interior (dedup)
- requires some refactoring of medium interface (store flags with
homo/hete/emissive accessible without callback)
- nee + culling
- refactor interior and vol such that mu_t mu_s mu_e are on vertex.shading
and ior shader are on vol struct
pathspace:
- clean up propagate vs. update_throughput (propagate with mutation semantics etc
seems like the place to leave throughput + pdf alone)
- remove consistency checks after all calls to path_project() with mutation
mode (now done inside)
guiding:
- one bvh per regex prefix (bounce, reflection mode)
- fill distance sampling cdf from eye also in neighbour tiles
- specular or otherwise requires to sometimes sample by bsdf instead
- need to keep regex prefix useful
- when to cluster next vertices together, when to separate?
hmc:
- multi step size sampling
- anisotropic step size sampling
regression:
- fix scenes for new geo format!
- sparse git commit hash only for big changes (in timing plot)
also copy/pasteable
shaders:
- introduce multi-layer shader to test spec/glossy lobe interaction
- wire anisotropic roughness to the microfacet models that support it
pathspace:
- on-demand pdf/pdf_adj cache system for efficiency!
cleanup:
- include optics to tools/
displacements:
- include into prims_geo
- depend on triangulated obj so far!
- init prim in alloc() callback in prims_geo.h (set extra bits, function in shell.h)
-
all: corona modules
CC=clang
CXX=clang++
CFLAGS+=-march=native -msse2 -mfpmath=sse -O3 -ffast-math -fno-finite-math-only -g
CXXFLAGS+=-march=native -msse2 -mfpmath=sse -O3 -ffast-math -fno-finite-math-only -g
LDFLAGS+=-fuse-ld=gold
#pragma once
// generated during build, do not edit.
#include "include/colour/aces.h"
#include "include/colour/adobergb.h"
#include "include/colour/ergb.h"
#include "include/colour/rec709.h"
#include "include/colour/srgb.h"
#include "include/colour/xyz.h"
#define colour_input_to_xyz colour_ergb_to_xyz
#define colour_xyz_to_input colour_xyz_to_ergb
#define colour_input_print_info colour_ergb_print_info
#define colour_output_to_xyz colour_adobergb_to_xyz
#define colour_xyz_to_output colour_xyz_to_adobergb
#define colour_output_print_info colour_adobergb_print_info
#define colour_camera_to_xyz colour_xyz_to_xyz
#define colour_xyz_to_camera colour_xyz_to_xyz
#define colour_camera_print_info colour_xyz_print_info
#pragma once
#include "filter/box.h"
#include "filter/blackmanharris.h"
#define filter_splat filter_blackmanharris_splat
#define filter_splat4 filter_blackmanharris_splat4
#define filter_print_info filter_blackmanharris_print_info
#ifndef CORONA_VERSION_H
#define VERSION ""
#endif
static inline void vmlt_register_all(vmlt_t *t)
{
}
#pragma once
static inline float lens_aperture_area(const float radius, const int blades)
{
const float tri = .5f*radius * radius * sinf(2.0f*M_PI/(float)blades);
return blades * tri;
}
static inline void lens_aperture_sample(float *x, float *y, float r1, float r2, const float radius, const int blades)
{
const int tri = (int)(r1*blades);
// rescale:
r1 = r1*blades - tri;
// sample triangle:
float a = sqrtf(r1);
float b = (1.0f-r2)*a;
float c = r2*a;
float p1[2], p2[2];
common_sincosf(2.0f*M_PI/blades * (tri+1), p1, p1+1);
common_sincosf(2.0f*M_PI/blades * tri, p2, p2+1);
*x = radius * (b * p1[1] + c * p2[1]);
*y = radius * (b * p1[0] + c * p2[0]);
}
static inline int lens_aperture_clip(const float x, const float y, const float radius, const int blades)
{
// early out
if(x*x + y*y > radius*radius) return 0;
float xx = radius;
float yy = 0.0f;
for(int b=1;b<blades