diff --git a/.gitignore b/.gitignore index a15c6943..0e2506b7 100644 --- a/.gitignore +++ b/.gitignore @@ -359,3 +359,9 @@ autogen/ # Ignore temp files added by flex project/mantaray/~flex* + +# Temporary files added by Intel tools +My Advisor Results*/ + +# Temporary Blender files +*.blend1 diff --git a/README.md b/README.md index 48ea3963..030c72fb 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -![Alt text](docs/public/banners/mantaray_banner_v3.png?raw=true) +![Alt text](docs/public/banners/mantaray_banner_v4.png?raw=true) -**MantaRay** is an open-source renderer currently under development. It uses modern rendering techniques to generate photorealistic images of complex scenes. +**MantaRay** is an advanced open-source renderer. It uses modern rendering techniques to generate photorealistic images of complex scenes. ## Getting Started To get started, consider reading this tutorial: [Getting Started](docs/public/tutorials/1_getting_started/1_getting_started.md). -Tutorials are continuously added here: [Tutorials](docs/public/tutorials/all_tutorials.md) +Tutorials are continually added here: [Tutorials](docs/public/tutorials/all_tutorials.md) ## Setup Instructions For Developers diff --git a/cli/src/main.cpp b/cli/src/main.cpp index a1bf86f8..42418c44 100644 --- a/cli/src/main.cpp +++ b/cli/src/main.cpp @@ -3,7 +3,7 @@ #include -#define VERSION "v1.0.1a" +#define VERSION "v1.1.0a" void printHeader() { std::cout << "////////////////////////////////////////////////" << std::endl; diff --git a/demos/aperture_demo.cpp b/demos/aperture_demo.cpp index e14b68fd..76a0e0e2 100644 --- a/demos/aperture_demo.cpp +++ b/demos/aperture_demo.cpp @@ -38,10 +38,6 @@ void manta_demo::apertureDemo(int samplesPerPixel, int resolutionX, int resoluti blocks.setFastIntersectEnabled(false); blocksObj.destroy(); - SpherePrimitive outdoorTopLightGeometry; - outdoorTopLightGeometry.setRadius((math::real)10.0); - outdoorTopLightGeometry.setPosition(math::loadVector(10.f, 20.f, 5.5f)); - // Create scene objects KDTree kdtree; kdtree.configure((math::real)500.0, math::constants::Zero); @@ -66,10 +62,10 @@ void manta_demo::apertureDemo(int samplesPerPixel, int resolutionX, int resoluti manta::SimpleLens lens; manta::PolygonalAperture aperture; aperture.setRadius((math::real)0.25); + aperture.setBladeCurvature(0.25f); aperture.configure(3, 0.f, false); lens.setAperture(&aperture); - lens.initialize(); lens.setPosition(cameraPos); lens.setDirection(dir); lens.setUp(up); @@ -78,6 +74,7 @@ void manta_demo::apertureDemo(int samplesPerPixel, int resolutionX, int resoluti lens.setSensorResolutionY(resolutionY); lens.setSensorHeight(10.0f); lens.setSensorWidth(10.0f * (resolutionX / (math::real)resolutionY)); + lens.configure(); lens.update(); RandomSampler sampler; @@ -118,6 +115,10 @@ void manta_demo::apertureDemo(int samplesPerPixel, int resolutionX, int resoluti // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(2.0, 2.0)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); // Run the ray tracer rayTracer.configure(200 * MB, 50 * MB, 12, 100, true); diff --git a/demos/blocks_demo.cpp b/demos/blocks_demo.cpp index 261be9dc..b710d1dc 100644 --- a/demos/blocks_demo.cpp +++ b/demos/blocks_demo.cpp @@ -130,6 +130,7 @@ void manta_demo::blocksDemo(int samplesPerPixel, int resolutionX, int resolution lens.setSensorResolutionY(resolutionY); lens.setSensorHeight(10.0f); lens.setSensorWidth(10.0f * (resolutionX / (math::real)resolutionY)); + lens.configure(); lens.update(); RandomSampler sampler; @@ -170,6 +171,10 @@ void manta_demo::blocksDemo(int samplesPerPixel, int resolutionX, int resolution // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.0, 1.0)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); // Run the ray tracer rayTracer.configure(200 * MB, 50 * MB, 12, 100, true); diff --git a/demos/box_city_demo.cpp b/demos/box_city_demo.cpp index 8014b2a0..46db3ba0 100644 --- a/demos/box_city_demo.cpp +++ b/demos/box_city_demo.cpp @@ -170,6 +170,10 @@ void manta_demo::boxCityDemo(int samplesPerPixel, int resolutionX, int resolutio // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.0, 1.0)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); // Initialize and run the ray tracer rayTracer.configure(200 * MB, 50 * MB, 12, 100, true); @@ -242,15 +246,15 @@ void manta_demo::boxCityDemo(int samplesPerPixel, int resolutionX, int resolutio step.getMainOutput()->setInput(mantaOutput.getMainOutput()); step.evaluate(); - MultiplyNode mulNode; + BinaryNode mulNode; mulNode.initialize(); - mulNode.getMainOutput()->setInputA(step.getMainOutput()); - mulNode.getMainOutput()->setInputB(mantaOutput.getMainOutput()); + mulNode.connectInput(step.getMainOutput(), "left", nullptr); + mulNode.connectInput(mantaOutput.getMainOutput(), "right", nullptr); mulNode.evaluate(); ConvolutionNode convNode; convNode.initialize(); - convNode.setInputs(mulNode.getMainOutput(), fraunNode.getMainOutput()); + convNode.setInputs(mulNode.getPrimaryOutput(), fraunNode.getMainOutput()); convNode.setResize(true); convNode.setClip(true); convNode.evaluate(); diff --git a/demos/complex_room_demo.cpp b/demos/complex_room_demo.cpp index f47ac067..fe476f42 100644 --- a/demos/complex_room_demo.cpp +++ b/demos/complex_room_demo.cpp @@ -32,10 +32,6 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol RayTracer rayTracer; rayTracer.setMaterialLibrary(new MaterialLibrary); - - DielectricMediaInterface glassFresnel; - glassFresnel.setIorIncident(1.0f); - glassFresnel.setIorTransmitted(1.6f); // Create all materials LambertianBSDF lambert; @@ -51,6 +47,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *wallMaterial = rayTracer.getMaterialLibrary()->newMaterial(); wallMaterial->setName("WallMaterial"); wallMaterial->setBSDF(&wallBSDF); + wallMaterial->setEmission(math::constants::Zero); // Floor material PhongDistribution floorCoating; @@ -63,6 +60,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *floorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); floorMaterial->setName("FloorMaterial"); floorMaterial->setBSDF(&floorBSDF); + floorMaterial->setEmission(math::constants::Zero); // Floor material PhongDistribution carpetCoating; @@ -75,6 +73,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *carpetMaterial = rayTracer.getMaterialLibrary()->newMaterial(); carpetMaterial->setName("CarpetMaterial"); carpetMaterial->setBSDF(&carpetBSDF); + carpetMaterial->setEmission(math::constants::Zero); // Steel material PhongDistribution tableSteelCoating; @@ -87,6 +86,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *tableSteel = rayTracer.getMaterialLibrary()->newMaterial(); tableSteel->setName("TableSteel"); tableSteel->setBSDF(&tableSteelBSDF); + tableSteel->setEmission(math::constants::Zero); // Table top material PhongDistribution tableTopCoating; @@ -99,6 +99,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *tableTop = rayTracer.getMaterialLibrary()->newMaterial(); tableTop->setName("TableTop"); tableTop->setBSDF(&tableTopBSDF); + tableTop->setEmission(math::constants::Zero); // Book material PhongDistribution bookCoating; @@ -111,6 +112,7 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol SimpleBSDFMaterial *book = rayTracer.getMaterialLibrary()->newMaterial(); book->setName("Book"); book->setBSDF(&bookBSDF); + book->setEmission(math::constants::Zero); // Create all scene geometry Mesh roomGeometry; @@ -140,12 +142,8 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol math::Vector dir = math::normalize(math::sub(target, cameraPos)); - LightRay sampleRay; - sampleRay.setDirection(dir); - sampleRay.setSource(cameraPos); - KDTree kdtree; - kdtree.configure(100.0f, math::constants::Zero); + kdtree.configure(1000.0f, math::constants::Zero); kdtree.analyzeWithProgress(&roomGeometry, 4); SpherePrimitive outdoorTopLightGeometry; @@ -222,6 +220,10 @@ void manta_demo::complexRoomDemo(int samplesPerPixel, int resolutionX, int resol // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(616, 1459, &scene, group, &sceneBuffer); diff --git a/demos/demos.h b/demos/demos.h index b18b0557..fdcdaf1f 100644 --- a/demos/demos.h +++ b/demos/demos.h @@ -42,7 +42,6 @@ #include "../include/microfacet_transmission_bsdf.h" #include "../include/microfacet_glass_bsdf.h" #include "../include/material_pointer.h" -#include "../include/power_node.h" #include "../include/remap_node.h" #include "../include/square_aperture.h" #include "../include/polygonal_aperture.h" @@ -58,13 +57,15 @@ #include "../include/vector_map_wrapper_node.h" #include "../include/convolution_node.h" #include "../include/image_output_node.h" -#include "../include/multiply_node.h" #include "../include/ramp_node.h" #include "../include/step_node.h" #include "../include/material_library.h" #include "../include/obj_file_node.h" #include "../include/kd_tree_node.h" #include "../include/cached_vector_node.h" +#include "../include/binary_node.h" +#include "../include/gaussian_filter.h" +#include "../include/box_filter.h" namespace manta_demo { diff --git a/demos/main.cpp b/demos/main.cpp index 8253aeb6..b41ef8cf 100644 --- a/demos/main.cpp +++ b/demos/main.cpp @@ -7,10 +7,10 @@ int main() { createAllDirectories(); // Run a demo - constexpr DEMO demo = DEMO::SDL_DEMO; - constexpr int samples = 10; - constexpr int resolutionX = 1920; // 2048 / 2; - constexpr int resolutionY = 1080; // 1536 / 2; + constexpr DEMO demo = DEMO::SAMSUNG_A8; + constexpr int samples = 100; + constexpr int resolutionX = 1920; + constexpr int resolutionY = 1080; runDemo(demo, samples, resolutionX, resolutionY); diff --git a/demos/material_visualizer.cpp b/demos/material_visualizer.cpp index 88cfbdcb..e215b30a 100644 --- a/demos/material_visualizer.cpp +++ b/demos/material_visualizer.cpp @@ -90,6 +90,7 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re SimpleBSDFMaterial *paintMaterial = rayTracer.getMaterialLibrary()->newMaterial(); paintMaterial->setBSDF(&simpleWoodBSDF); paintMaterial->setName("SimpleDarkWood"); + paintMaterial->setEmission(math::constants::Zero); // Steel PhongDistribution phongSteel; @@ -102,6 +103,7 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re steelMaterial->setName("Steel"); steelMaterial->setReflectance(getColor(255, 255, 255)); steelMaterial->setBSDF(&steelBSDF); + steelMaterial->setEmission(math::constants::Zero); // Steel 2 TextureNode fingerprintTexture; @@ -114,11 +116,17 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re metalTexture.initialize(); metalTexture.evaluate(); - PowerNode fingerprintPower(4.0f, fingerprintTexture.getMainOutput()); + CachedVectorNode constS; + constS.initialize(); + constS.setValue(math::loadScalar(4.0f)); + PowerNode fingerprintPower; + fingerprintPower.initialize(); + fingerprintPower.connectInput(fingerprintTexture.getMainOutput(), "__right", nullptr); + fingerprintPower.connectInput(constS.getPrimaryOutput(), "__left", nullptr); RemapNode specularPowerFingerprint( math::loadScalar(0.0f), math::loadScalar(1.0f), - fingerprintPower.getMainOutput()); + fingerprintPower.getPrimaryOutput()); RemapNode invFingerprint( math::loadScalar(1.0f), @@ -141,6 +149,7 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re SimpleBSDFMaterial *steel2Material = rayTracer.getMaterialLibrary()->newMaterial(); steel2Material->setName("Steel2"); steel2Material->setBSDF(&steelBSDF2); + steel2Material->setEmission(math::constants::Zero); // GGX Test GgxDistribution ggxTest; @@ -155,6 +164,7 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re SimpleBSDFMaterial *ggxTestMaterial = rayTracer.getMaterialLibrary()->newMaterial(); ggxTestMaterial->setName("GGX_Test"); ggxTestMaterial->setBSDF(&ggxTestBDSF); + ggxTestMaterial->setEmission(math::constants::Zero); ggxTestMaterial->setReflectance(math::constants::One); // ======================================================================== @@ -167,6 +177,7 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re SimpleBSDFMaterial *backdropTexture = rayTracer.getMaterialLibrary()->newMaterial(); backdropTexture->setBSDF(&lambert); backdropTexture->setReflectanceNode(checkerboardTexture.getMainOutput()); + backdropTexture->setEmission(math::constants::Zero); backdropTexture->setName("Backdrop"); SimpleBSDFMaterial *lightMaterial = rayTracer.getMaterialLibrary()->newMaterial(); @@ -237,6 +248,10 @@ void manta_demo::materialVisualizer(int samplesPerPixel, int resolutionX, int re // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(369, 462, &scene, group, &sceneBuffer); diff --git a/demos/pen_demo.cpp b/demos/pen_demo.cpp index a7203160..a74b1b24 100644 --- a/demos/pen_demo.cpp +++ b/demos/pen_demo.cpp @@ -196,6 +196,10 @@ void manta_demo::penDemo(int samplesPerPixel, int resolutionX, int resolutionY) // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.0, 1.0)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(179, 1423, &scene, group, &sceneBuffer); diff --git a/demos/samsung_a8_demo.cpp b/demos/samsung_a8_demo.cpp index b89f780f..cc777021 100644 --- a/demos/samsung_a8_demo.cpp +++ b/demos/samsung_a8_demo.cpp @@ -16,7 +16,7 @@ void manta_demo::samsungA8Demo(int samplesPerPixel, int resolutionX, int resolut constexpr bool DETERMINISTIC_SEED_MODE = false; constexpr bool TRACE_SINGLE_PIXEL = false; constexpr SCENE SCENE = BANNER_SCENE; - constexpr bool HIGH_RESOLUTION = true; + constexpr bool HIGH_RESOLUTION = false; constexpr bool ENABLE_SMUDGE = true; RayTracer rayTracer; @@ -187,87 +187,104 @@ void manta_demo::samsungA8Demo(int samplesPerPixel, int resolutionX, int resolut SimpleBSDFMaterial *defaultMaterial = rayTracer.getMaterialLibrary()->newMaterial(); defaultMaterial->setName("Default"); defaultMaterial->setBSDF(&lambert); + defaultMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *phoneCaseMaterial = rayTracer.getMaterialLibrary()->newMaterial(); phoneCaseMaterial->setName("PhoneCase"); phoneCaseMaterial->setReflectance(getColor(255, 255, 255)); phoneCaseMaterial->setReflectanceNode(smudgeMap.getMainOutput()); phoneCaseMaterial->setBSDF(&phoneCaseBSDF); + phoneCaseMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *bayDoorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); bayDoorMaterial->setName("BayDoorMaterial"); bayDoorMaterial->setReflectance(getColor(255, 255, 255)); bayDoorMaterial->setBSDF(&bayDoorBSDF); + bayDoorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *bronzeMaterial = rayTracer.getMaterialLibrary()->newMaterial(); bronzeMaterial->setName("Bronze"); bronzeMaterial->setReflectance(getColor(0xC0, 0xA5, 0x70)); bronzeMaterial->setBSDF(&bronzeBSDF); + bronzeMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *steelMaterial = rayTracer.getMaterialLibrary()->newMaterial(); steelMaterial->setName("Steel"); steelMaterial->setReflectance(getColor(255, 255, 255)); steelMaterial->setBSDF(&steelBSDF); + steelMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *blackPlasticMaterial = rayTracer.getMaterialLibrary()->newMaterial(); blackPlasticMaterial->setName("BlackPlastic"); blackPlasticMaterial->setReflectance(getColor(255, 255, 255)); blackPlasticMaterial->setBSDF(&blackPlasticBSDF); + blackPlasticMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *blackMaterial = rayTracer.getMaterialLibrary()->newMaterial(); blackMaterial->setName("Black"); blackMaterial->setReflectance(getColor(0, 0, 0)); blackMaterial->setBSDF(nullptr); + blackMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *floorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); floorMaterial->setName("Floor"); floorMaterial->setReflectance(getColor(255, 255, 255)); floorMaterial->setBSDF(&floorBSDF); + floorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *glassMaterial = rayTracer.getMaterialLibrary()->newMaterial(); glassMaterial->setName("Glass"); glassMaterial->setReflectance(getColor(255, 255, 255)); glassMaterial->setBSDF(&simpleGlassBSDF); + glassMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *lensGlassMaterial = rayTracer.getMaterialLibrary()->newMaterial(); lensGlassMaterial->setName("LensGlass"); lensGlassMaterial->setReflectance(getColor(255, 255, 255)); lensGlassMaterial->setBSDF(&lensGlassBSDF); + lensGlassMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *speakerGrillMaterial = rayTracer.getMaterialLibrary()->newMaterial(); speakerGrillMaterial->setName("SpeakerGrill"); speakerGrillMaterial->setReflectance(getColor(255, 255, 255)); speakerGrillMaterial->setBSDF(&speakerGrillBSDF); + speakerGrillMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *screenMaskMaterial = rayTracer.getMaterialLibrary()->newMaterial(); screenMaskMaterial->setName("ScreenMask"); screenMaskMaterial->setReflectance(getColor(5, 5, 5)); screenMaskMaterial->setBSDF(&lambert); + screenMaskMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *mattePlasticMaterial = rayTracer.getMaterialLibrary()->newMaterial(); mattePlasticMaterial->setName("MattePlastic"); mattePlasticMaterial->setReflectance(getColor(0x52, 0x4f, 0x51)); mattePlasticMaterial->setBSDF(&mattePlasticBSDF); + mattePlasticMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *imageSensorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); imageSensorMaterial->setName("ImageSensor"); imageSensorMaterial->setReflectance(getColor(0x34, 0x2e, 0x38)); imageSensorMaterial->setBSDF(&imageSensorBSDF); + imageSensorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *mirrorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); mirrorMaterial->setName("Mirror"); mirrorMaterial->setReflectance(getColor(255, 255, 255)); mirrorMaterial->setBSDF(&mirrorBSDF); + mirrorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *flashColorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); flashColorMaterial->setName("FlashColor"); flashColorMaterial->setReflectance(getColor(0xE7, 0xE0, 0x7F)); flashColorMaterial->setBSDF(&lambert); + flashColorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *backPlateMaterial = rayTracer.getMaterialLibrary()->newMaterial(); backPlateMaterial->setName("BackPlate"); backPlateMaterial->setReflectance(getColor(255, 255, 255)); backPlateMaterial->setBSDF(&backPlateBSDF); + backPlateMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *screenMaterial = rayTracer.getMaterialLibrary()->newMaterial(); screenMaterial->setName("Screen"); @@ -375,6 +392,10 @@ void manta_demo::samsungA8Demo(int samplesPerPixel, int resolutionX, int resolut // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(1044, 1063, &scene, group, &sceneBuffer); diff --git a/demos/sdl/box_city_demo.mr b/demos/sdl/box_city_demo.mr index 3a2eeddf..7cdef09b 100644 --- a/demos/sdl/box_city_demo.mr +++ b/demos/sdl/box_city_demo.mr @@ -129,7 +129,8 @@ ray_tracer mr( scene: scene, camera: settings.camera, materials: library, - background: 1.1 + background: 1.1, + filter: box_filter() ) image_output( diff --git a/demos/sdl/pen_demo.mr b/demos/sdl/pen_demo.mr index 3a70178d..57bc1a19 100644 --- a/demos/sdl/pen_demo.mr +++ b/demos/sdl/pen_demo.mr @@ -73,7 +73,7 @@ auto node backdrop_material { name: "Backdrop", library: library, bsdf: bsdf, - reflectance: light_wood + reflectance: uv_wrap(light_wood) ); image_file light_wood( diff --git a/demos/sdl/samsung/samsung_banner_demo.mr b/demos/sdl/samsung/samsung_banner_demo.mr new file mode 100644 index 00000000..c38c9ddb --- /dev/null +++ b/demos/sdl/samsung/samsung_banner_demo.mr @@ -0,0 +1,57 @@ +import "mantaray.mr" +import "samsung_materials.mr" + +auto node settings { + output samples: 100; + output enable_matte_render: false; + output enable_full_render: true; +} + +samsung_render full_render( + enable: settings.enable_full_render, + samples: settings.samples, + output_name: "samsung_demo", + background: 0, + materials: samsung_materials() +) + +samsung_render matte_render( + enable: settings.enable_matte_render, + samples: settings.samples, + output_name: "samsung_demo_matte", + background: 1.3, + materials: matte_library() +) + +node matte_library { + alias output this: matte_library; + + material_library matte_library() + bsdf_material( + library: matte_library, + name: "Default", + bsdf: microfacet_reflection_bsdf(ggx_distribution(0.5)), + reflectance: 1.0 + ) +} + +node samsung_render { + toggle enable: true; + input samples: 100; + input output_name; + input materials; + input background: 0; + + quick_render( + samples: samples, + + object_file: "../../../demos/models/samsung_a8_banner_scene.obj", + materials: materials, + camera_position: vector(8.2166, 8.00816, -31.4485), + camera_target: vector(7.66829, 7.63167, -18.7725), + plane_height: 0.4992, + output_name: output_name, + output_dir: "../../../workspace/render/bitmap/", + background: background + ) +} diff --git a/demos/sdl/samsung/samsung_instagram.mr b/demos/sdl/samsung/samsung_instagram.mr new file mode 100644 index 00000000..303a86ae --- /dev/null +++ b/demos/sdl/samsung/samsung_instagram.mr @@ -0,0 +1,59 @@ +import "mantaray.mr" +import "samsung_materials.mr" + +auto node settings { + output samples: 25000; + output enable_matte_render: true; + output enable_full_render: true; +} + +samsung_render full_render( + enable: settings.enable_full_render, + samples: settings.samples, + output_name: "samsung_demo", + background: 0, + materials: samsung_materials() +) + +samsung_render matte_render( + enable: settings.enable_matte_render, + samples: settings.samples, + output_name: "samsung_demo_matte", + background: 1.3, + materials: matte_library() +) + +node matte_library { + alias output this: matte_library; + + material_library matte_library() + bsdf_material( + library: matte_library, + name: "Default", + bsdf: microfacet_reflection_bsdf(ggx_distribution(0.5)), + reflectance: 1.0 + ) +} + +node samsung_render { + toggle enable: true; + input samples: 100; + input output_name; + input materials; + input background: 0; + + quick_render( + samples: samples, + + object_file: "../../../demos/models/samsung_a8_banner_scene.obj", + materials: materials, + camera_position: vector(8.2166, 8.00816, -31.4485), + camera_target: vector(5.1977, 7.63167, -18.7725), + resolution_x: 1080, + resolution_y: 1350, + plane_height: 0.6, + output_name: output_name, + output_dir: "../../../workspace/render/bitmap/", + background: background + ) +} diff --git a/demos/sdl/samsung/samsung_materials.mr b/demos/sdl/samsung/samsung_materials.mr new file mode 100644 index 00000000..218c0eb3 --- /dev/null +++ b/demos/sdl/samsung/samsung_materials.mr @@ -0,0 +1,233 @@ +import "mantaray.mr" + +public node samsung_materials { + input library: material_library(); + alias output this: library; + + // Base path for all textures + string texture_path("../../textures/") + + image_file speaker_grill( + filename: texture_path + "samsung_a8/speaker_grill.jpg" + ) + + image_file back_plate_texture( + filename: texture_path + "samsung_a8/back_plate.png" + ) + + image_file phone_screen_texture( + filename: texture_path + "samsung_a8/phone_screen_v2.jpg" + ) + + image_file ground_roughness( + filename: texture_path + "chrome_roughness.jpg", + correct_gamma: false + ) + + image_file smudge_map( + filename: texture_path + "samsung_a8/fingerprints_roughness_map.png", + correct_gamma: false + ) + + // Common distributions + phong_distribution dist_phone_case( + power: 1024 * smudge_map + 8 + ) + + phong_distribution dist_glass( + power: 5000 * smudge_map + 200 + ) + + phong_distribution dist_back_plastic(5000) + phong_distribution dist_bay_door(256) + phong_distribution dist_bronze(256) + phong_distribution dist_steel(1024) + phong_distribution dist_floor( + power: 256 * ground_roughness + 240 + ) + phong_distribution dist_matte_plastic(64) + phong_distribution mirror_dist(20000) + + lambertian_bsdf lambert() + + // Materials + bsdf_material default_material( + library: library, + name: "Default", + bsdf: lambert + ) + + bsdf_material phone_case( + library: library, + name: "PhoneCase", + bsdf: bilayer_bsdf( + coating: dist_phone_case, + diffuse: 0, + specular: 0.01 + ) + ) + + bsdf_material bay_door( + library: library, + name: "BayDoorMaterial", + bsdf: bilayer_bsdf( + coating: dist_bay_door, + diffuse: 0, + specular: 0 + ) + ) + + bsdf_material bronze( + library: library, + name: "Bronze", + bsdf: microfacet_reflection_bsdf(dist_bronze), + reflectance: srgb_i(0xC0, 0xA5, 0x70) + ) + + bsdf_material steel( + library: library, + name: "Steel", + bsdf: microfacet_reflection_bsdf(dist_steel) + ) + + bsdf_material back_plastic( + library: library, + name: "BlackPlastic", + bsdf: bilayer_bsdf( + coating: dist_back_plastic, + diffuse: 0, + specular: 0.05 + ) + ) + + bsdf_material black( + library: library, + name: "Black", + reflectance: 0, + bsdf: lambert + ) + + bsdf_material floor( + library: library, + name: "Floor", + bsdf: bilayer_bsdf( + coating: dist_floor, + diffuse: 0, + specular: 0.05 + ) + ) + + bsdf_material glass( + library: library, + name: "Glass", + bsdf: glass_bsdf( + distribution: dist_glass, + media_interface: dielectric_interface(1.4) + ) + ) + + bsdf_material lens_glass( + library: library, + name: "LensGlass", + bsdf: glass_bsdf( + distribution: dist_glass, + media_interface: dielectric_interface(1.5) + ) + ) + + bsdf_material speaker_grill_material( + library: library, + name: "SpeakerGrill", + bsdf: bilayer_bsdf( + coating: dist_bay_door, + diffuse: 0.1 * speaker_grill, + specular: 0 + ) + ) + + bsdf_material screen_mask( + library: library, + name: "ScreenMask", + reflectance: srgb_i(5, 5, 5), + bsdf: lambert + ) + + bsdf_material matte_plastic( + library: library, + name: "MattePlastic", + reflectance: srgb_i(0x52, 0x4F, 0x51), + bsdf: lambert + ) + + bsdf_material image_sensor( + library: library, + name: "ImageSensor", + reflectance: srgb_i(0x34, 0x2E, 0x38), + bsdf: lambert + ) + + bsdf_material mirror( + library: library, + name: "Mirror", + bsdf: microfacet_reflection_bsdf(mirror_dist) + ) + + bsdf_material flash_color( + library: library, + name: "FlashColor", + reflectance: srgb_i(0xE7, 0xE0, 0x7F), + bsdf: lambert + ) + + bsdf_material back_plate( + library: library, + name: "BackPlate", + bsdf: bilayer_bsdf( + coating: dist_back_plastic, + diffuse: back_plate_texture, + specular: 0 + ) + ) + + bsdf_material screen( + library: library, + name: "Screen", + emission: 1.6 * phone_screen_texture, + reflectance: srgb_i(3, 3, 3), + bsdf: lambert + ) + + samsung_lights( + library: library + ) +} + +public node samsung_lights { + input library; + + lambertian_bsdf lambert() + + bsdf_material strong_light( + library: library, + name: "StrongLight", + emission: 12.0, + reflectance: 0, + bsdf: lambert + ) + + bsdf_material weak_light( + library: library, + name: "WeakLight", + emission: 1.9, + reflectance: 0, + bsdf: lambert + ) + + bsdf_material fill_light( + library: library, + name: "FillLight", + emission: 15.0, + reflectance: 0, + bsdf: lambert + ) +} diff --git a/demos/sdl/teapot_lamp_demo.mr b/demos/sdl/teapot_lamp_demo.mr index bbf696b8..90ae8ca5 100644 --- a/demos/sdl/teapot_lamp_demo.mr +++ b/demos/sdl/teapot_lamp_demo.mr @@ -9,7 +9,7 @@ log() log() auto node settings { - output samples: 1; + output samples: 128; output resolution_x: 1920; output resolution_y: 1080; output enable_fraunhofer: false; @@ -43,10 +43,11 @@ auto node test_material { name: "TeapotMaterial", library: library, bsdf: lambertian_bsdf(), - reflectance: 1.0, - emission: - separator * glow_color + - (1.0 - separator) * vector(glow_color.g, glow_color.b, glow_color.r) + reflectance: 0.0, + emission: 1.0 + //emission: + // separator * glow_color + + // (1.0 - separator) * vector(glow_color.g, glow_color.b, glow_color.r) ); vector_var glow_color( @@ -59,7 +60,6 @@ auto node test_material { s: surface_interaction().position.y, foot: 0.75 ) - } auto node floor_material { @@ -83,7 +83,8 @@ auto node bulb_material { name: "BulbMaterial", library: library, reflectance: vector(), - emission: srgb_i(255, 197, 143) * 50, + //emission: srgb_i(255, 197, 143) * 50, + emission: 0, bsdf: lambertian_bsdf() ); } @@ -159,7 +160,8 @@ image_output( map: mr.image, filename: settings.output_dir + settings.current_date.as_string + "_" + settings.output_name + - "_S" + string(settings.samples) + ".jpg" + "_S" + string(settings.samples) + ".jpg", + jpeg_quality: 100 ) diffraction_simulation( diff --git a/demos/sdl/the_gadget.mr b/demos/sdl/the_gadget.mr index 1b50152c..78a397b2 100644 --- a/demos/sdl/the_gadget.mr +++ b/demos/sdl/the_gadget.mr @@ -2,7 +2,7 @@ private import "mantaray.mr" private import "utilities.mr" auto node settings { - output samples: 45000; + output samples: 100; output resolution_x: 1900; output resolution_y: 1268; output output_dir: "../../workspace/render/bitmap/"; diff --git a/demos/simple_room_demo.cpp b/demos/simple_room_demo.cpp index 76cd3e5f..2b78c6e6 100644 --- a/demos/simple_room_demo.cpp +++ b/demos/simple_room_demo.cpp @@ -39,6 +39,7 @@ void manta_demo::simpleRoomDemo(int samplesPerPixel, int resolutionX, int resolu wallMaterial->setName("WallMaterial"); wallMaterial->setBSDF(&lambert); wallMaterial->setReflectance(getColor(200, 200, 200)); + wallMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial outdoorLight; outdoorLight.setEmission(math::loadVector(18.f, 16.f, 16.f)); @@ -52,11 +53,13 @@ void manta_demo::simpleRoomDemo(int samplesPerPixel, int resolutionX, int resolu tableMaterial->setName("TableMaterial"); tableMaterial->setReflectance(getColor(78, 46, 40)); tableMaterial->setBSDF(&lambert); + tableMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *groundMaterial = rayTracer.getMaterialLibrary()->newMaterial(); groundMaterial->setName("GroundMaterial"); groundMaterial->setReflectance(math::mul(math::loadVector(78, 46, 40), math::loadScalar(0.001f))); groundMaterial->setBSDF(&lambert); + groundMaterial->setEmission(math::constants::Zero); // Create all scene geometry Mesh smallHouse; @@ -118,6 +121,10 @@ void manta_demo::simpleRoomDemo(int samplesPerPixel, int resolutionX, int resolu // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); // Create the raytracer rayTracer.configure(200 * MB, 100 * MB, 12, 100, true); diff --git a/demos/stock_scene_demo.cpp b/demos/stock_scene_demo.cpp index 0b8ea3e4..ac9555fc 100644 --- a/demos/stock_scene_demo.cpp +++ b/demos/stock_scene_demo.cpp @@ -63,16 +63,22 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu LambertianBSDF lambert; - PowerNode texturePower(4.0f, fingerprintTexture.getMainOutput()); + CachedVectorNode constS; + constS.setValue(math::loadScalar(4.0f)); + constS.initialize(); + PowerNode texturePower; + texturePower.initialize(); + texturePower.connectInput(fingerprintTexture.getMainOutput(), "__left", nullptr); + texturePower.connectInput(constS.getPrimaryOutput(), "__right", nullptr); RemapNode specularPowerFingerprint( math::loadScalar(0.0f), math::loadScalar(1.0f), - texturePower.getMainOutput()); + texturePower.getPrimaryOutput()); RemapNode invFingerprint( math::loadScalar(1.0f), math::loadScalar(0.5f), - texturePower.getMainOutput()); + texturePower.getPrimaryOutput()); // Steel PhongDistribution phongSteel; @@ -96,15 +102,18 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu SimpleBSDFMaterial *steelMaterial = rayTracer.getMaterialLibrary()->newMaterial(); steelMaterial->setName("Steel"); steelMaterial->setBSDF(&steelBSDF); + steelMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *shinySteelMaterial = rayTracer.getMaterialLibrary()->newMaterial(); shinySteelMaterial->setName("ShinySteel"); shinySteelMaterial->setBSDF(&shinySteelBSDF); + shinySteelMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *blackSteelMaterial = rayTracer.getMaterialLibrary()->newMaterial(); blackSteelMaterial->setName("BlackSteel"); blackSteelMaterial->setReflectance(getColor(0xC0, 0xC0, 0xC0)); blackSteelMaterial->setBSDF(&steelBSDF); + blackSteelMaterial->setEmission(math::constants::Zero); // Graphite PhongDistribution phongGraphite; @@ -117,6 +126,7 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu graphiteMaterial->setName("Graphite"); graphiteMaterial->setReflectance(getColor(0x29, 0x29, 0x29)); graphiteMaterial->setBSDF(&graphiteBSDF); + graphiteMaterial->setEmission(math::constants::Zero); // Pencil paint PhongDistribution phongGloss; @@ -134,27 +144,32 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu SimpleBSDFMaterial *paintMaterial = rayTracer.getMaterialLibrary()->newMaterial(); paintMaterial->setName("PencilPaint"); paintMaterial->setBSDF(&paintBSDF); + paintMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *defaultLambert = rayTracer.getMaterialLibrary()->newMaterial(); defaultLambert->setBSDF(&lambert); defaultLambert->setName("Default"); + defaultLambert->setEmission(math::constants::Zero); SimpleBSDFMaterial *rubber = rayTracer.getMaterialLibrary()->newMaterial(); rubber->setBSDF(&lambert); rubber->setName("Eraser"); rubber->setReflectance(getColor(0xFF, 0xFF, 0xFF)); rubber->setReflectanceNode(eraserTexture.getMainOutput()); + rubber->setEmission(math::constants::Zero); SimpleBSDFMaterial *wood = rayTracer.getMaterialLibrary()->newMaterial(); wood->setBSDF(&lambert); wood->setName("Wood"); wood->setReflectance(getColor(0xFF, 0xFF, 0xFF)); wood->setReflectanceNode(woodTexture.getMainOutput()); + wood->setEmission(math::constants::Zero); SimpleBSDFMaterial *floorMaterial = rayTracer.getMaterialLibrary()->newMaterial(); floorMaterial->setBSDF(&lambert); floorMaterial->setName("Floor"); floorMaterial->setReflectanceNode(floorTexture.getMainOutput()); + floorMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial *mainLight = rayTracer.getMaterialLibrary()->newMaterial(); mainLight->setBSDF(nullptr); @@ -218,6 +233,7 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu lens.setSensorResolutionY(resolutionY); lens.setSensorHeight(8.0f); lens.setSensorWidth(8.0f * (resolutionX / (math::real)resolutionY)); + lens.configure(); lens.update(); if (!LENS_SIMULATION) { @@ -261,6 +277,10 @@ void manta_demo::stockSceneDemo(int samplesPerPixel, int resolutionX, int resolu // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(1522, 674, &scene, group, &sceneBuffer); diff --git a/demos/stress_spiders.cpp b/demos/stress_spiders.cpp index 55be8b98..438320f5 100644 --- a/demos/stress_spiders.cpp +++ b/demos/stress_spiders.cpp @@ -41,6 +41,7 @@ void manta_demo::stressSpidersDemo(int samplesPerPixel, int resolutionX, int res SimpleBSDFMaterial *spiderMaterial = rayTracer.getMaterialLibrary()->newMaterial(); spiderMaterial->setName("Equipment"); spiderMaterial->setBSDF(&spiderBSDF); + spiderMaterial->setEmission(math::constants::Zero); PhongDistribution groundCoating; groundCoating.setPower((math::real)64); @@ -52,6 +53,7 @@ void manta_demo::stressSpidersDemo(int samplesPerPixel, int resolutionX, int res SimpleBSDFMaterial *groundMaterial = rayTracer.getMaterialLibrary()->newMaterial(); groundMaterial->setName("Ground"); groundMaterial->setBSDF(&groundBSDF); + groundMaterial->setEmission(math::constants::Zero); SimpleBSDFMaterial outdoorTopLightMaterial; outdoorTopLightMaterial.setEmission(math::loadVector(5.f, 5.f, 5.f)); @@ -154,6 +156,10 @@ void manta_demo::stressSpidersDemo(int samplesPerPixel, int resolutionX, int res // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(819, 199, &scene, group, &sceneBuffer); diff --git a/demos/teapot_lamp_demo.cpp b/demos/teapot_lamp_demo.cpp index 02d8a238..fd8e6e30 100644 --- a/demos/teapot_lamp_demo.cpp +++ b/demos/teapot_lamp_demo.cpp @@ -105,6 +105,7 @@ void manta_demo::teapotLampDemo(int samplesPerPixel, int resolutionX, int resolu glassMaterial->setName("Glass"); glassMaterial->setReflectance(getColor(255, 255, 255)); glassMaterial->setBSDF(&simpleGlassBSDF); + glassMaterial->setEmission(math::constants::Zero); // Create all scene geometry Mesh lamp; @@ -188,6 +189,10 @@ void manta_demo::teapotLampDemo(int samplesPerPixel, int resolutionX, int resolu // Output the results to a scene buffer ImagePlane sceneBuffer; + GaussianFilter filter; + filter.setExtents(math::Vector2(1.5, 1.5)); + filter.configure((math::real)4.0); + sceneBuffer.setFilter(&filter); if (TRACE_SINGLE_PIXEL) { rayTracer.tracePixel(1025, 921, &scene, &camera, &sceneBuffer); @@ -261,13 +266,13 @@ void manta_demo::teapotLampDemo(int samplesPerPixel, int resolutionX, int resolu MultiplyNode mulNode; mulNode.initialize(); - mulNode.getMainOutput()->setInputA(step.getMainOutput()); - mulNode.getMainOutput()->setInputB(mantaOutput.getMainOutput()); + mulNode.connectInput(step.getMainOutput(), "left", nullptr); + mulNode.connectInput(mantaOutput.getMainOutput(), "right", nullptr); mulNode.evaluate(); ConvolutionNode convNode; convNode.initialize(); - convNode.setInputs(mulNode.getMainOutput(), fraunNode.getMainOutput()); + convNode.setInputs(mulNode.getPrimaryOutput(), fraunNode.getMainOutput()); convNode.setResize(true); convNode.setClip(true); convNode.evaluate(); diff --git a/demos/textures/samsung_a8/phone_screen_v2.jpg b/demos/textures/samsung_a8/phone_screen_v2.jpg new file mode 100644 index 00000000..f952c966 Binary files /dev/null and b/demos/textures/samsung_a8/phone_screen_v2.jpg differ diff --git a/demos/utils.cpp b/demos/utils.cpp index 905c6886..f9f3dabf 100644 --- a/demos/utils.cpp +++ b/demos/utils.cpp @@ -83,7 +83,7 @@ void manta_demo::editImage(manta::ImagePlane *sceneBuffer, const std::string &ou std::cout << "Enter scale factor: "; std::cin >> scale; - temp.scale(scale); + //temp.scale(scale); manta::SaveImageData(temp.getBuffer(), temp.getWidth(), temp.getHeight(), outputFname.c_str()); temp.destroy(); diff --git a/docs/public/banners/mantaray_banner_v4.png b/docs/public/banners/mantaray_banner_v4.png new file mode 100644 index 00000000..a4b0dcaa Binary files /dev/null and b/docs/public/banners/mantaray_banner_v4.png differ diff --git a/docs/public/tutorials/1_getting_started/1_getting_started.md b/docs/public/tutorials/1_getting_started/1_getting_started.md index 27b74b37..6f3c3b34 100644 --- a/docs/public/tutorials/1_getting_started/1_getting_started.md +++ b/docs/public/tutorials/1_getting_started/1_getting_started.md @@ -71,6 +71,8 @@ The final render will look something like this: Congratulations, you've rendered your first scene with MantaRay! In upcoming tutorials you'll learn how to apply materials and use more advanced features of MantaRay. +Next tutorial: [Basics of Materials](../2_basics_of_materials/2_basics_of_materials.md) + ## Useful Links * [MantaRay Tutorials](../all_tutorials.md) diff --git a/docs/public/tutorials/2_basics_of_materials/2_basics_of_materials.md b/docs/public/tutorials/2_basics_of_materials/2_basics_of_materials.md new file mode 100644 index 00000000..a57c507f --- /dev/null +++ b/docs/public/tutorials/2_basics_of_materials/2_basics_of_materials.md @@ -0,0 +1,133 @@ +# 2 Basics of Materials + +In the [previous tutorial](../1_getting_started/1_getting_started.md) we set up a simple scene using MantaRay. In this tutorial we'll explore materials and camera placement to give the scene a bit more depth. + +## Step 1 - Better Camera Positioning + +In the first tutorial we rendered the scene below using mostly default parameters from the `quick_render` node. + +![Alt text](../1_getting_started/assets/2019-08-20_T19_54_53_quick_render_S128.jpg) + +As can be seen, the camera angle isn't particularly flattering for this scene. Fortunately, updating both the camera target and position is easy with the `quick_render` tool. To start this tutorial, let's create a copy of the script from the last tutorial and name it `adding_materials.mr`. The entire script thus far is: + +``` +import "mantaray.mr" + +quick_render( + object_file: "simple_scene.obj" +) +``` + +In Piranha, parameters are specified using the '`:`' symbol, with the name on the left and the value on the right. So far, we've only set the value of one parameter `object_file` which specifies the `.obj` file from which geometry will be loaded. The `quick_render` node has many more parameters that we can use to customize our scene. In particular `camera_target` controls the 3D location that the camera is 'looking at' and `camera_position` controls where the camera is actually positioned. + +If we adjust these parameters, we will observe the scene actually change. + +``` +import "mantaray.mr" + +quick_render( + object_file: "simple_scene.obj", + camera_target: vector(0.0, 0.5, 0.0), + camera_position: vector(5.0, 2.5, 5.0) +) +``` + +By default, the `quick_render` node places the camera at (5.0, 5.0, 5.0) with the target at (0.0, 0.0, 0.0). By moving the `y` component of the position down by 2.5, we are also moving the camera down by 2.5 units. Similarly we have adjusted the `y` component of the `camera_target` parameter which will cause the camera to rotate upwards. Rendering this scene will produce this result: + +![Alt text](assets/2019-08-26_T18_50_22_quick_render_S128.jpg) + +This is okay but the top is still clipped. We can do better by shifting both the camera target and position up by 1 unit: + +![Alt text](assets/2019-08-26_T18_54_12_quick_render_S128.jpg) + +``` +import "mantaray.mr" + +quick_render( + object_file: "simple_scene.obj", + camera_target: vector(0.0, 1.5, 0.0), + camera_position: vector(5.0, 3.5, 5.0) +) +``` + +All default parameters can be seen in `manta-lib/utilities/quick_render.mr` as the MantaRay standard library is fully accessible for viewing. **WARNING** - even though the standard library is made accessible, you should not modify it unless you *really* know what you're doing. + +## Step 2 - Adding Materials in Blender + +In order for MantaRay to know which material is assigned to which object, we must first set up placeholder materials in Blender. With each object selected, we can proceed to create a new material for each one. + +![Alt text](assets/screenshots/screenshot_1.PNG) + +The content of these new materials doesn't matter, but it's important to name them in a convenient way as MantaRay materials are indexed by name. For this scene, I've created 4 materials called `Floor`, `Cube`, `Sphere` and `Cone` and assigned them to their corresponding objects in the scene. Export this file in the same way that was done in the [previous tutorial](../1_getting_started/1_getting_started.md). + +## Step 3 - Creating a Material Library + +The 4 materials assigned to our geometric primitives don't mean much to MantaRay at this point since they are just labels. Therefore, we need to create some materials to associate with these labels. First we need to create a new empty material library. This is achieved by adding the following line of code to our SDL script: + +``` +material_library library() +``` + +We now need to fill this library with materials. We'll use the simple material node type `bsdf_material`. Each material takes the following form: + +``` +bsdf_material cube_material( + library: library, + name: "Cube", // Must match the material name in Blender + reflectance: srgb_i(0xba, 0xdc, 0x58) +) +``` + +The `reflectance` parameter can be read as 'color'. `srgb_i` is a node which takes three parameters R, G and B in integer form. The components can be specified either as decimal or hexadecimal values. Using colors taken from [this website](https://flatuicolors.com/palette/au) we can now set up 4 materials for each object in the scene. The final script looks like this: + +``` +import "mantaray.mr" + +material_library library() + +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58) +) + +bsdf_material floor_material( + library: library, + name: "Floor", + reflectance: srgb_i(0x30, 0x33, 0x6b) +) + +bsdf_material cone_material( + library: library, + name: "Cone", + reflectance: srgb_i(0xf9, 0xca, 0x24) +) + +bsdf_material sphere_material( + library: library, + name: "Sphere", + reflectance: srgb_i(0xeb, 0x4d, 0x4b) +) + +quick_render( + materials: library, + object_file: "simple_scene.obj", + camera_target: vector(0.0, 1.5, 0.0), + camera_position: vector(5.0, 3.5, 5.0) +) +``` + +Notice how a new parameter `materials` was specified in the `quick_render` node. This lets MantaRay know which collection of materials we'll be using to apply to a scene. Executing this script in the MantaRay CLI will give something like this: + +![Alt text](assets/2019-08-26_T19_37_38_quick_render_S128.jpg) + +## Conclusion + +Our scene now has color! It probably won't be winning any awards but it at least looks a little less bland now. In the next tutorial we'll look into using more realistic materials. + +## Useful Links + +* [Previous Tutorial (Getting Started)](../1_getting_started/1_getting_started.md) +* [MantaRay Tutorials](../all_tutorials.md) +* [Piranha Handbook](https://github.com/ange-yaghi/piranha/blob/master/docs/handbook/handbook.md) +* [VS Code Piranha Plugin](https://github.com/ange-yaghi/mantaray-sdl-extension) diff --git a/docs/public/tutorials/2_basics_of_materials/adding_materials.mr b/docs/public/tutorials/2_basics_of_materials/adding_materials.mr new file mode 100644 index 00000000..e568235b --- /dev/null +++ b/docs/public/tutorials/2_basics_of_materials/adding_materials.mr @@ -0,0 +1,34 @@ +import "mantaray.mr" + +material_library library() + +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58) +) + +bsdf_material floor_material( + library: library, + name: "Floor", + reflectance: srgb_i(0x30, 0x33, 0x6b) +) + +bsdf_material cone_material( + library: library, + name: "Cone", + reflectance: srgb_i(0xf9, 0xca, 0x24) +) + +bsdf_material sphere_material( + library: library, + name: "Sphere", + reflectance: srgb_i(0xeb, 0x4d, 0x4b) +) + +quick_render( + materials: library, + object_file: "simple_scene.obj", + camera_target: vector(0.0, 1.5, 0.0), + camera_position: vector(5.0, 3.5, 5.0) +) diff --git a/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_50_22_quick_render_S128.jpg b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_50_22_quick_render_S128.jpg new file mode 100644 index 00000000..90f27083 Binary files /dev/null and b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_50_22_quick_render_S128.jpg differ diff --git a/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_54_12_quick_render_S128.jpg b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_54_12_quick_render_S128.jpg new file mode 100644 index 00000000..9e1c0862 Binary files /dev/null and b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T18_54_12_quick_render_S128.jpg differ diff --git a/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T19_37_38_quick_render_S128.jpg b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T19_37_38_quick_render_S128.jpg new file mode 100644 index 00000000..d0f0e811 Binary files /dev/null and b/docs/public/tutorials/2_basics_of_materials/assets/2019-08-26_T19_37_38_quick_render_S128.jpg differ diff --git a/docs/public/tutorials/2_basics_of_materials/assets/blender/simple_scene.blend b/docs/public/tutorials/2_basics_of_materials/assets/blender/simple_scene.blend new file mode 100644 index 00000000..9d47ffd0 Binary files /dev/null and b/docs/public/tutorials/2_basics_of_materials/assets/blender/simple_scene.blend differ diff --git a/docs/public/tutorials/2_basics_of_materials/assets/screenshots/screenshot_1.PNG b/docs/public/tutorials/2_basics_of_materials/assets/screenshots/screenshot_1.PNG new file mode 100644 index 00000000..48c7cf22 Binary files /dev/null and b/docs/public/tutorials/2_basics_of_materials/assets/screenshots/screenshot_1.PNG differ diff --git a/docs/public/tutorials/3_realistic_materials/3_realistic_materials.md b/docs/public/tutorials/3_realistic_materials/3_realistic_materials.md new file mode 100644 index 00000000..47eea871 --- /dev/null +++ b/docs/public/tutorials/3_realistic_materials/3_realistic_materials.md @@ -0,0 +1,160 @@ +# 3 Realistic Materials + +In the [previous tutorial](../2_basics_of_materials/2_basics_of_materials.md) we applied some simple materials to our scene to give it some color. + +![Alt text](../2_basics_of_materials/assets/2019-08-26_T19_37_38_quick_render_S128.jpg) + +The default model used by the `bsdf_material` is the Lambertian model which is not physically realistic. It can, however, roughly approximate a highly diffuse material like paper. In this tutorial we'll look at using some of the more advanced and physically accurate models that MantaRay provides. + +## Introduction to Microfacet Models + +A microfacet model is an approximation to how light reflects off of a surface. It assumes that all materials are (at a microscopic level) composed of tiny reflectors. If these reflectors all point in the same direction, the material is shiny. If they are completely random and can point in any direction with equal probability, then the material would appear rough. In this tutorial we'll focus on the *GGX* model. + +## Using a Microfacet Model + +Recall that creating a single BSDF material looks like this: + +``` +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58) +) +``` + +We purposefully omitted a parameter to the `bsdf_material` node called `bsdf`. Using this input we can decide to use a completely different reflection model. To use a GGX model, we would do the following: + +``` +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58), + bsdf: microfacet_reflection_bsdf( + ggx_distribution(width: 0.5) + ) +``` + +The GGX distribution has only one input `width`. Intuitively, `width` can be thought of as controlling the *spread* of microfacets. A smaller spread results in a shiny material, whereas a larger spread results in a rough material. The `width` can be between 0 and 1. + +To test this out, make a copy of the script from tutorial 2 and name it `advanced_materials.mr`. Now update the material to use the GGX model as shown above. Three renders are shown below with different width inputs. + +### width = 0.01 +![Alt text](assets/render1.jpg) + +### width = 0.1 +![Alt text](assets/render2.jpg) + +### width = 0.5 +![Alt text](assets/render3.jpg) + +The GGX model can be applied to the other objects as done in the render below. + +![Alt text](assets/render4.jpg) + +## Glass + +MantaRay provides the `glass_bsdf` node to simulate glass and glass-like materials. + +``` +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58), + bsdf: glass_bsdf() +) +``` + +![Alt text](assets/render5.jpg) + +Like the `microfacet_reflection_bsdf` node, a specific distribution can be specified for the glass material. We can make the glass a little less polished by passing in a GGX model with a width of 0.2. + +``` +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58), + bsdf: glass_bsdf( + ggx_distribution(0.2) + ) +) +``` + +![Alt text](assets/render6.jpg) + +As before, the glass model can be used for artistic effect on any of the primitives in the scene. + +![Alt text](assets/render7.jpg) + +## Light Emission + +Another input parameter to the `bsdf_material` is `emission` which controls how much light is emitted by an object. For example, we can make the green cube glow by using the code below: + +``` +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58), + // Emits light with the same color as the reflectance + emission: srgb_i(0xba, 0xdc, 0x58), + bsdf: glass_bsdf( + ggx_distribution(0.2) + ) +) +``` + +![Alt text](assets/render8.jpg) + +The cube is now clearly emitting light but it's a bit too bright. Since we want the color to be exactly the same as the reflectance color, we would ordinarily have to scale the R, G and B components manually by the same amount. Piranha provides a much simpler way to do this via *operations*. We can simply multiply the `srgb_i` node by 0.1 to scale the color down. + +``` + ... + emission: 0.1 * srgb_i(0xba, 0xdc, 0x58), + ... +``` + +We can now see that the cube still emits the correct shade of green light but is less bright: + +![Alt text](assets/render9.jpg) + +## Bilayer Material + +Many materials are composed of a relatively diffuse underlying layer with a glossy coating on top. MantaRay can approximate this effect using the `bilayer_bsdf` node. This BSDF is similar to the others discussed so far, but it has its own color inputs so we should remove the `reflectance` parameter from the `bsdf_material` for now. Let's use the bilayer model for the red sphere in the back to make it look a little more convincing: + +``` +bsdf_material sphere_material( + library: library, + name: "Sphere", + bsdf: bilayer_bsdf( + coating: ggx_distribution(0.01), + diffuse: srgb_i(0xeb, 0x4d, 0x4b), + specular: 0.1 + ) +) +``` + +![Alt text](assets/render10.jpg) + +| Parameter | Description | +|---------------|--------------------| +|`coating`|The microfacet distribution of the coating layer| +|`diffuse`|The diffuse color of the underlying layer| +|`specular`|How reflective the surface is (between 0 and 1)| + +If the specular is set to 1 then the coating layer will be highly reflective everywhere as shown in this render: + +![Alt text](assets/render12.jpg) + +If the specular is set to 0 then the coating layer will only be reflective at very shallow angles as shown in the example below: + +![Alt text](assets/render11.jpg) + +## Conclusion + +We've now explored some of the more sophisticated surface models provided by MantaRay. In the next tutorial we'll look at applying textures. + +## Useful Links + +* [Previous Tutorial (Basics of Materials)](../2_basics_of_materials/2_basics_of_materials.md) +* [MantaRay Tutorials](../all_tutorials.md) +* [Piranha Handbook](https://github.com/ange-yaghi/piranha/blob/master/docs/handbook/handbook.md) +* [VS Code Piranha Plugin](https://github.com/ange-yaghi/mantaray-sdl-extension) diff --git a/docs/public/tutorials/3_realistic_materials/advanced_materials.mr b/docs/public/tutorials/3_realistic_materials/advanced_materials.mr new file mode 100644 index 00000000..6bfc8e73 --- /dev/null +++ b/docs/public/tutorials/3_realistic_materials/advanced_materials.mr @@ -0,0 +1,49 @@ +import "mantaray.mr" + +material_library library() + +bsdf_material cube_material( + library: library, + name: "Cube", + reflectance: srgb_i(0xba, 0xdc, 0x58), + // Emits light with the same color as the reflectance + emission: srgb_i(0xba, 0xdc, 0x58) * 0.1, + bsdf: glass_bsdf( + ggx_distribution(0.2) + ) +) + +bsdf_material floor_material( + library: library, + name: "Floor", + reflectance: srgb_i(0x30, 0x33, 0x6b), + bsdf: microfacet_reflection_bsdf( + ggx_distribution(0.05) + ) +) + +bsdf_material cone_material( + library: library, + name: "Cone", + reflectance: srgb_i(0xf9, 0xca, 0x24), + bsdf: glass_bsdf( + ggx_distribution(0.5) + ) +) + +bsdf_material sphere_material( + library: library, + name: "Sphere", + bsdf: bilayer_bsdf( + coating: ggx_distribution(0.01), + diffuse: srgb_i(0xeb, 0x4d, 0x4b), + specular: 1.0 + ) +) + +quick_render( + materials: library, + object_file: "simple_scene.obj", + camera_target: vector(0.0, 1.5, 0.0), + camera_position: vector(5.0, 3.5, 5.0) +) diff --git a/docs/public/tutorials/3_realistic_materials/assets/blender/simple_scene.blend b/docs/public/tutorials/3_realistic_materials/assets/blender/simple_scene.blend new file mode 100644 index 00000000..3b333c41 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/blender/simple_scene.blend differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render1.jpg b/docs/public/tutorials/3_realistic_materials/assets/render1.jpg new file mode 100644 index 00000000..7fa5fc36 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render1.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render10.jpg b/docs/public/tutorials/3_realistic_materials/assets/render10.jpg new file mode 100644 index 00000000..540d6527 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render10.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render11.jpg b/docs/public/tutorials/3_realistic_materials/assets/render11.jpg new file mode 100644 index 00000000..68263402 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render11.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render12.jpg b/docs/public/tutorials/3_realistic_materials/assets/render12.jpg new file mode 100644 index 00000000..fd83ee9a Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render12.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render2.jpg b/docs/public/tutorials/3_realistic_materials/assets/render2.jpg new file mode 100644 index 00000000..42c0588e Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render2.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render3.jpg b/docs/public/tutorials/3_realistic_materials/assets/render3.jpg new file mode 100644 index 00000000..d8c7be47 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render3.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render4.jpg b/docs/public/tutorials/3_realistic_materials/assets/render4.jpg new file mode 100644 index 00000000..ef82afbf Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render4.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render5.jpg b/docs/public/tutorials/3_realistic_materials/assets/render5.jpg new file mode 100644 index 00000000..c63c1df7 Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render5.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render6.jpg b/docs/public/tutorials/3_realistic_materials/assets/render6.jpg new file mode 100644 index 00000000..560269ed Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render6.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render7.jpg b/docs/public/tutorials/3_realistic_materials/assets/render7.jpg new file mode 100644 index 00000000..f1a9ed5f Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render7.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render8.jpg b/docs/public/tutorials/3_realistic_materials/assets/render8.jpg new file mode 100644 index 00000000..8da3aecb Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render8.jpg differ diff --git a/docs/public/tutorials/3_realistic_materials/assets/render9.jpg b/docs/public/tutorials/3_realistic_materials/assets/render9.jpg new file mode 100644 index 00000000..f26e9ddf Binary files /dev/null and b/docs/public/tutorials/3_realistic_materials/assets/render9.jpg differ diff --git a/docs/public/tutorials/all_tutorials.md b/docs/public/tutorials/all_tutorials.md index fba15596..178c29aa 100644 --- a/docs/public/tutorials/all_tutorials.md +++ b/docs/public/tutorials/all_tutorials.md @@ -2,3 +2,5 @@ ## Basic Tutorials * [1 Getting Started](1_getting_started/1_getting_started.md) +* [2 Basics of Materials](2_basics_of_materials/2_basics_of_materials.md) +* [3 Realistic Materials](3_realistic_materials/3_realistic_materials.md) diff --git a/include/box_filter.h b/include/box_filter.h new file mode 100644 index 00000000..04a74323 --- /dev/null +++ b/include/box_filter.h @@ -0,0 +1,18 @@ +#ifndef MANTARAY_BOX_FILTER_H +#define MANTARAY_BOX_FILTER_H + +#include "filter.h" + +namespace manta { + + class BoxFilter : public Filter { + public: + BoxFilter(); + ~BoxFilter(); + + virtual math::Vector evaluate(const math::Vector2 &p); + }; + +} /* namespace manta */ + +#endif /* MANTARAY_BOX_FILTER_H */ diff --git a/include/cached_vector_node.h b/include/cached_vector_node.h index 28878e45..840fcbdb 100644 --- a/include/cached_vector_node.h +++ b/include/cached_vector_node.h @@ -15,6 +15,9 @@ namespace manta { CachedVectorOutput *getMainOutput() { return &m_output; } + void setValue(const math::Vector &v) { m_output.setValue(v); } + math::Vector getValue() const { return m_output.getValue(); } + protected: virtual void _initialize(); virtual void _evaluate(); @@ -22,9 +25,6 @@ namespace manta { virtual void registerOutputs(); - void setValue(const math::Vector &v) { m_output.setValue(v); } - math::Vector getValue() const { return m_output.getValue(); } - protected: CachedVectorOutput m_output; }; diff --git a/include/camera_ray_emitter.h b/include/camera_ray_emitter.h index e2c68c94..99879913 100644 --- a/include/camera_ray_emitter.h +++ b/include/camera_ray_emitter.h @@ -1,11 +1,11 @@ #ifndef MANTARAY_CAMERA_RAY_EMITTER_H #define MANTARAY_CAMERA_RAY_EMITTER_H -#include "../include/manta_math.h" +#include "manta_math.h" namespace manta { - class Sampler2D; + class Sampler2d; class RayContainer; class StackAllocator; @@ -15,8 +15,8 @@ namespace manta { virtual ~CameraRayEmitter(); virtual void generateRays(RayContainer *rayContainer) const = 0; - void setSampler(Sampler2D *sampler) { m_sampler = sampler; } - Sampler2D *getSampler() const { return m_sampler; } + void setSampler(Sampler2d *sampler) { m_sampler = sampler; } + Sampler2d *getSampler() const { return m_sampler; } void setSampleCount(int samples) { m_sampleCount = samples; } int getSampleCount() const { return m_sampleCount; } @@ -27,14 +27,39 @@ namespace manta { math::Vector getDirection() const { return m_direction; } void setDirection(const math::Vector &v) { m_direction = v; } + math::Vector getUp() const { return m_up; } + void setUp(const math::Vector &up) { m_up = up; } + + math::Vector getRight() const { return m_right; } + void setRight(const math::Vector &right) { m_right = right; } + + math::Vector getImagePlaneOrigin() const { return m_imagePlaneOrigin; } + void setImagePlaneOrigin(const math::Vector &imagePlaneOrigin) { m_imagePlaneOrigin = imagePlaneOrigin; } + + math::Vector2 getPixelIncrement() const { return m_pixelIncrement; } + void setPixelIncrement(const math::Vector2 &increment) { m_pixelIncrement = increment; } + + void setImagePlaneCoordinates(int x, int y) { m_pixelX = x; m_pixelY = y; } + int getPixelX() const { return m_pixelX; } + int getPixelY() const { return m_pixelY; } + void setStackAllocator(StackAllocator *s) { m_stackAllocator = s; } StackAllocator *getStackAllocator() { return m_stackAllocator; } + math::Vector transformToImagePlane(const math::Vector2 coordinates) const; + protected: - Sampler2D *m_sampler; + Sampler2d *m_sampler; math::Vector m_position; math::Vector m_direction; + math::Vector m_up; + math::Vector m_right; + math::Vector m_imagePlaneOrigin; + math::Vector2 m_pixelIncrement; + + int m_pixelX; + int m_pixelY; int m_sampleCount; diff --git a/include/camera_ray_emitter_group.h b/include/camera_ray_emitter_group.h index 23febf78..04668c42 100644 --- a/include/camera_ray_emitter_group.h +++ b/include/camera_ray_emitter_group.h @@ -9,7 +9,7 @@ namespace manta { class ImagePlane; - class Sampler2D; + class Sampler2d; class CameraRayEmitter; class RayContainer; @@ -42,8 +42,8 @@ namespace manta { void setSampleCount(int samples) { m_samples = samples; } int getSampleCount() const { return m_samples; } - void setSampler(Sampler2D *sampler) { m_sampler = sampler; } - Sampler2D *getSampler() const { return m_sampler; } + void setSampler(Sampler2d *sampler) { m_sampler = sampler; } + Sampler2d *getSampler() const { return m_sampler; } virtual void configure() = 0; @@ -94,7 +94,7 @@ namespace manta { math::real_d m_planeDistance; int m_samples; - Sampler2D *m_sampler; + Sampler2d *m_sampler; }; } /* namespace manta */ diff --git a/include/filter.h b/include/filter.h new file mode 100644 index 00000000..d8384bb8 --- /dev/null +++ b/include/filter.h @@ -0,0 +1,33 @@ +#ifndef MANTARAY_FILTER_H +#define MANTARAY_FILTER_H + +#include "object_reference_node.h" + +#include "manta_math.h" + +namespace manta{ + + class Filter : public ObjectReferenceNode { + public: + Filter(); + ~Filter(); + + virtual math::Vector evaluate(const math::Vector2 &p) = 0; + + void setExtents(const math::Vector2 &extents) { m_extents = extents; } + math::Vector2 getExtents() const { return m_extents; } + + protected: + math::Vector2 m_extents; + + protected: + virtual void _initialize(); + virtual void _evaluate(); + virtual void registerInputs(); + + piranha::pNodeInput m_radiusInput; + }; + +} /* namespace manta */ + +#endif /* MANTARAY_FILTER_H */ diff --git a/include/gaussian_filter.h b/include/gaussian_filter.h new file mode 100644 index 00000000..047af157 --- /dev/null +++ b/include/gaussian_filter.h @@ -0,0 +1,47 @@ +#ifndef MANTARAY_GAUSSIAN_FILTER_H +#define MANTARAY_GAUSSIAN_FILTER_H + +#include "filter.h" + +namespace manta { + + class GaussianFilter : public Filter { + protected: + static constexpr int CACHE_STEPS = 1024; + static constexpr int SAFETY_FACTOR = 32; + static constexpr bool ENABLE_CACHE = true; + + public: + GaussianFilter(); + ~GaussianFilter(); + + void configure(math::real alpha); + + virtual math::Vector evaluate(const math::Vector2 &p); + + protected: + math::real gaussian(math::real d, math::real expv); + math::real gaussianCache(math::real d); + void computeCache(); + + math::real m_alpha; + + protected: + math::real m_expX; + math::real m_expY; + math::real m_invR; + + protected: + math::real *m_cache; + + protected: + virtual void _initialize(); + virtual void _evaluate(); + virtual void registerInputs(); + + piranha::pNodeInput m_alphaInput; + }; + +} /* namespace manta */ + +#endif /* MANTARAY_GAUSSIAN_FILTER_H */ diff --git a/include/grid_sampler.h b/include/grid_sampler.h index a457b86c..8a5b13e4 100644 --- a/include/grid_sampler.h +++ b/include/grid_sampler.h @@ -5,12 +5,12 @@ namespace manta { - class GridSampler : public Sampler2D { + class GridSampler : public Sampler2d { public: GridSampler(); virtual ~GridSampler(); - virtual void generateSamples(int sampleCount, math::Vector *target) const; + virtual void generateSamples(int sampleCount, math::Vector2 *target) const; virtual int getTotalSampleCount(int sampleCount) const; void setGridWidth(int gridWidth) { m_gridWidth = gridWidth; } diff --git a/include/image_plane.h b/include/image_plane.h index eaa49634..f8a96fdc 100644 --- a/include/image_plane.h +++ b/include/image_plane.h @@ -1,26 +1,34 @@ #ifndef MANTARAY_IMAGE_PLANE_H #define MANTARAY_IMAGE_PLANE_H +#include "image_sample.h" +#include "job_queue.h" #include "manta_math.h" +#include "stack_allocator.h" + +#include +#include +#include namespace manta { - // Forward declarations - class Convolution; + class Filter; class ImagePlane { public: ImagePlane(); ~ImagePlane(); - void initialize(int width, int height, math::real physicalWidth, - math::real physicalHeight); + void initialize(int width, int height); void destroy(); bool checkPixel(int x, int y) const; inline void set(const math::Vector &v, int x, int y); inline math::Vector sample(int x, int y) const; + void setFilter(Filter *filter) { m_filter = filter; } + Filter *getFilter() const { return m_filter; } + int getWidth() const { return m_width; } int getHeight() const { return m_height; } @@ -32,32 +40,19 @@ namespace manta { const math::Vector *getBuffer() const { return m_buffer; } - // ----- Analysis and Manipulation ----- - - // Get max intensity in the scene buffer - math::real getMax() const; - - // Get min intensity in the scene buffer - math::real getMin() const; - - // Get the average value in the scene buffer - math::Vector getAverage() const; + void processSamples(ImageSample *samples, int sampleCount, StackAllocator *stack); - // Apply gamma - void applyGammaCurve(math::real gamma); - - void add(const ImagePlane *b); - - // Scale all values in the scene buffer - void scale(math::real scale); + void normalize(); protected: - math::real m_physicalWidth; - math::real m_physicalHeight; - int m_width; int m_height; math::Vector *m_buffer; + math::real *m_sampleWeightSums; + Filter *m_filter; + + protected: + std::mutex m_lock; }; } /* namespace manta */ diff --git a/include/image_sample.h b/include/image_sample.h new file mode 100644 index 00000000..8f10291b --- /dev/null +++ b/include/image_sample.h @@ -0,0 +1,15 @@ +#ifndef MANTARAY_IMAGE_SAMPLE_H +#define MANTARAY_IMAGE_SAMPLE_H + +#include "manta_math.h" + +namespace manta { + + struct ImageSample { + math::Vector intensity; + math::Vector2 imagePlaneLocation; + }; + +} /* namespace manta */ + +#endif /* MANTARAY_IMAGE_SAMPLE_H */ diff --git a/include/job_queue.h b/include/job_queue.h index 3f2b3bda..38347a77 100644 --- a/include/job_queue.h +++ b/include/job_queue.h @@ -1,5 +1,5 @@ -#ifndef JOB_QUEUE_H -#define JOB_QUEUE_H +#ifndef MANTARAY_JOB_QUEUE_H +#define MANTARAY_JOB_QUEUE_H #include #include @@ -35,4 +35,4 @@ namespace manta { } /* namespace manta */ -#endif /* JOB_QUEUE_H */ +#endif /* MANTARAY_JOB_QUEUE_H */ diff --git a/include/lens_camera_ray_emitter_group.h b/include/lens_camera_ray_emitter_group.h index 0ccf4a39..d1adaf09 100644 --- a/include/lens_camera_ray_emitter_group.h +++ b/include/lens_camera_ray_emitter_group.h @@ -32,6 +32,10 @@ namespace manta { virtual void registerInputs(); piranha::pNodeInput m_lensInput; + + protected: + math::real m_xIncrement; + math::real m_yIncrement; }; } /* namespace manta */ diff --git a/include/light_ray.h b/include/light_ray.h index 87ed611d..0ca12a80 100644 --- a/include/light_ray.h +++ b/include/light_ray.h @@ -30,6 +30,9 @@ namespace manta { void setAperturePoint(const math::Vector2 &aperturePoint) { m_aperturePoint = aperturePoint; } math::Vector2 getAperturePoint() const { return m_aperturePoint; } + void setImagePlaneLocation(const math::Vector2 &imagePlaneLocation) { m_imagePlaneLocation = imagePlaneLocation; } + math::Vector2 getImagePlaneLocation() const { return m_imagePlaneLocation; } + void calculateTransformations(); int getKX() const { return m_kx; } @@ -45,6 +48,7 @@ namespace manta { protected: int m_meta; + math::Vector2 m_imagePlaneLocation; math::Vector2 m_aperturePoint; math::Vector m_direction; diff --git a/include/multiply_node.h b/include/multiply_node.h deleted file mode 100644 index 01b64330..00000000 --- a/include/multiply_node.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef MANTARAY_MULTIPLY_NODE_H -#define MANTARAY_MULTIPLY_NODE_H - -#include - -#include "vector_node_output.h" -#include "multiply_node_output.h" -#include "manta_math.h" - -namespace manta { - - class MultiplyNode : public piranha::Node { - public: - MultiplyNode(); - virtual ~MultiplyNode(); - - MultiplyNodeOutput *getMainOutput() { return &m_output; } - - protected: - MultiplyNodeOutput m_output; - - virtual void _initialize(); - - virtual void registerInputs(); - virtual void registerOutputs(); - }; - -} /* namespace manta */ - -#endif /* MANTARAY_MULTIPLY_NODE_H */ diff --git a/include/multiply_node_output.h b/include/multiply_node_output.h deleted file mode 100644 index d5da95a6..00000000 --- a/include/multiply_node_output.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef MANTARAY_MULTIPLY_NODE_OUTPUT_H -#define MANTARAY_MULTIPLY_NODE_OUTPUT_H - -#include "vector_node_output.h" - -#include "manta_math.h" -#include "intersection_point.h" - -namespace manta { - - class MultiplyNodeOutput : public VectorNodeOutput { - public: - MultiplyNodeOutput() { - m_inputA = nullptr; - m_inputB = nullptr; - - m_defaultA = math::constants::Zero; - m_defaultB = math::constants::Zero; - } - - virtual ~MultiplyNodeOutput() { - /* void */ - } - - virtual void sample(const IntersectionPoint *surfaceInteraction, void *target) const; - virtual void discreteSample2D(int x, int y, void *target) const; - virtual void getDataReference(const void **target) const; - - void setInputA(piranha::pNodeInput input) { m_inputA = input; } - piranha::pNodeInput getInputA() const { return m_inputA; } - - void setInputB(piranha::pNodeInput input) { m_inputB = input; } - piranha::pNodeInput getInputB() const { return m_inputB; } - - void setDefaultA(const math::Vector &v) { m_defaultA = v; } - math::Vector getDefaultA() const { return m_defaultA; } - - void setDefaultB(const math::Vector &v) { m_defaultB = v; } - math::Vector getDefaultB() const { return m_defaultB; } - - piranha::pNodeInput *getInputAConnection() { return &m_inputA; } - piranha::pNodeInput *getInputBConnection() { return &m_inputB; } - - protected: - virtual void _evaluateDimensions(); - - protected: - piranha::pNodeInput m_inputA; - piranha::pNodeInput m_inputB; - math::Vector m_defaultA; - math::Vector m_defaultB; - }; - -} /* namespace manta */ - -#endif /* MANTARAY_MULTIPLY_NODE_OUTPUT_H */ diff --git a/include/object_channel_types.h b/include/object_channel_types.h index f5f18cb6..b00b53ac 100644 --- a/include/object_channel_types.h +++ b/include/object_channel_types.h @@ -20,6 +20,7 @@ namespace manta { static const piranha::ChannelType ApertureChannel; static const piranha::ChannelType LensChannel; static const piranha::ChannelType MediaInterfaceChannel; + static const piranha::ChannelType FilterChannel; }; template @@ -40,10 +41,11 @@ namespace manta { class Scene; class SceneObject; class CameraRayEmitterGroup; - class Sampler2D; + class Sampler2d; class Aperture; class Lens; class MediaInterface; + class Filter; // Helper macro #define ASSIGN_CHANNEL_TYPE(type, channel) template <> extern inline const piranha::ChannelType *LookupChannelType() { return &ObjectChannel::channel; } @@ -59,10 +61,11 @@ namespace manta { ASSIGN_CHANNEL_TYPE(Scene, SceneChannel); ASSIGN_CHANNEL_TYPE(SceneObject, SceneObjectChannel); ASSIGN_CHANNEL_TYPE(CameraRayEmitterGroup, CameraChannel); - ASSIGN_CHANNEL_TYPE(Sampler2D, SamplerChannel); + ASSIGN_CHANNEL_TYPE(Sampler2d, SamplerChannel); ASSIGN_CHANNEL_TYPE(Aperture, ApertureChannel); ASSIGN_CHANNEL_TYPE(Lens, LensChannel); ASSIGN_CHANNEL_TYPE(MediaInterface, MediaInterfaceChannel); + ASSIGN_CHANNEL_TYPE(Filter, FilterChannel); } /* namespace manta */ diff --git a/include/power_node.h b/include/power_node.h deleted file mode 100644 index 185610b7..00000000 --- a/include/power_node.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef MANTARAY_POWER_NODE_H -#define MANTARAY_POWER_NODE_H - -#include - -#include "vector_node_output.h" -#include "power_node_output.h" -#include "manta_math.h" - -namespace manta { - - class PowerNode : public piranha::Node { - public: - PowerNode(); - PowerNode(math::real power, VectorNodeOutput *input); - virtual ~PowerNode(); - - void setPower(math::real power) { m_power = power; } - math::real getPower() const { return m_power; } - - void setInputNode(VectorNodeOutput *inputNode) { m_inputNode = inputNode; } - VectorNodeOutput *getInputNode() const { return m_inputNode; } - - void setPowerNode(VectorNodeOutput *powerNode) { m_powerNode = powerNode; } - VectorNodeOutput *getPowerNode() const { return m_powerNode; } - - PowerNodeOutput *getMainOutput() { return &m_output; } - - protected: - virtual void _initialize(); - - virtual void registerInputs(); - virtual void registerOutputs(); - - VectorNodeOutput *m_inputNode; - VectorNodeOutput *m_powerNode; - PowerNodeOutput m_output; - - math::real m_power; - }; - -} /* namespace manta */ - -#endif /* MANTARAY_POWER_NODE_H */ diff --git a/include/power_node_output.h b/include/power_node_output.h deleted file mode 100644 index 95298a3e..00000000 --- a/include/power_node_output.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef MANTARAY_POWER_NODE_OUTPUT_H -#define MANTARAY_POWER_NODE_OUTPUT_H - -#include "vector_node_output.h" - -#include "manta_math.h" -#include "vector_map_2d.h" -#include "intersection_point.h" - -namespace manta { - - class PowerNodeOutput : public VectorNodeOutput { - public: - PowerNodeOutput() { - setDimensions(1); - setDimensionSize(0, 1); - - m_input = nullptr; - m_powerNode = nullptr; - m_defaultPower = (math::real)1.0; - } - - virtual ~PowerNodeOutput() { - /* void */ - } - - virtual void sample(const IntersectionPoint *surfaceInteraction, void *target) const; - virtual void discreteSample2D(int x, int y, void *target) const; - virtual void fullOutput(const void **target) const; - - void setInput(piranha::pNodeInput input) { m_input = input; } - piranha::pNodeInput getInput() const { return m_input; } - - void setPowerNode(piranha::pNodeInput powerNode) { m_powerNode = powerNode; } - piranha::pNodeInput getPowerNode() const { return m_powerNode; } - - void setDefaultPower(math::real defaultPower) { m_defaultPower = defaultPower; } - math::real getDefaultPower() const { return m_defaultPower; } - - protected: - piranha::pNodeInput m_input; - piranha::pNodeInput m_powerNode; - math::real m_defaultPower; - }; - -} /* namespace manta */ - -#endif /* MANTARAY_POWER_NODE_OUTPUT_H */ diff --git a/include/random_sampler.h b/include/random_sampler.h index c630d82f..f90aae50 100644 --- a/include/random_sampler.h +++ b/include/random_sampler.h @@ -5,12 +5,12 @@ namespace manta { - class RandomSampler : public Sampler2D { + class RandomSampler : public Sampler2d { public: RandomSampler(); virtual ~RandomSampler(); - virtual void generateSamples(int sampleCount, math::Vector *target) const; + virtual void generateSamples(int sampleCount, math::Vector2 *target) const; virtual int getTotalSampleCount(int sampleCount) const; }; diff --git a/include/ray_container.h b/include/ray_container.h index 13dcbb54..f582c8ce 100644 --- a/include/ray_container.h +++ b/include/ray_container.h @@ -1,7 +1,7 @@ #ifndef MANTARAY_RAY_CONTAINER_H #define MANTARAY_RAY_CONTAINER_H -#include "../include/manta_math.h" +#include "manta_math.h" namespace manta { diff --git a/include/ray_tracer.h b/include/ray_tracer.h index b33b94af..4dc032c5 100644 --- a/include/ray_tracer.h +++ b/include/ray_tracer.h @@ -91,6 +91,7 @@ namespace manta { piranha::pNodeInput m_materialLibraryInput; piranha::pNodeInput m_sceneInput; piranha::pNodeInput m_cameraInput; + piranha::pNodeInput m_filterInput; VectorMap2DNodeOutput m_output; diff --git a/include/sample_container.h b/include/sample_container.h new file mode 100644 index 00000000..4a682513 --- /dev/null +++ b/include/sample_container.h @@ -0,0 +1,35 @@ +#ifndef MANTARAY_SAMPLE_CONTAINER_H +#define MANTARAY_SAMPLE_CONTAINER_H + +namespace manta { + + // Forward declarations + class ImageSample; + class StackAllocator; + + class SampleContainer { + public: + SampleContainer(); + virtual ~SampleContainer(); + + ImageSample *getSample() const { return m_samples; } + int getRayCount() const { return m_rayCount; } + + void initializeSamples(int count); + void destroySamples(); + + void setStackAllocator(StackAllocator *allocator) { m_stackAllocator = allocator; } + StackAllocator *getStackAllocator() const { return m_stackAllocator; } + + private: + int m_rayCount; + + ImageSample *m_samples; + + private: + StackAllocator *m_stackAllocator; + }; + +} /* namespace manta */ + +#endif /* MANTARAY_SAMPLE_CONTAINER_H */ diff --git a/include/sampler_2d.h b/include/sampler_2d.h index 91306bc2..8a8e9788 100644 --- a/include/sampler_2d.h +++ b/include/sampler_2d.h @@ -9,31 +9,13 @@ namespace manta { class StackAllocator; - class Sampler2D : public ObjectReferenceNode { + class Sampler2d : public ObjectReferenceNode { public: - Sampler2D(); - ~Sampler2D(); + Sampler2d(); + ~Sampler2d(); - virtual void generateSamples(int sampleCount, math::Vector *target) const = 0; + virtual void generateSamples(int sampleCount, math::Vector2 *target) const = 0; virtual int getTotalSampleCount(int sampleCount) const = 0; - - void setAxis1(const math::Vector &axis1) { m_axis1 = axis1; } - math::Vector getAxis1() const { return m_axis1; } - - void setAxis2(const math::Vector &axis2) { m_axis2 = axis2; } - math::Vector getAxis2() const { return m_axis2; } - - void setBoundaryWidth(math::real boundary) { m_boundaryWidth = boundary; } - math::real getBoundaryWidth() const { return m_boundaryWidth; } - - void setBoundaryHeight(math::real boundary) { m_boundaryHeight = boundary; } - math::real getBoundaryHeight() const { return m_boundaryHeight; } - - protected: - math::Vector m_axis1; - math::Vector m_axis2; - math::real m_boundaryWidth; - math::real m_boundaryHeight; }; } /* namespace manta */ diff --git a/include/simple_sampler.h b/include/simple_sampler.h index 313c385f..f6c2828d 100644 --- a/include/simple_sampler.h +++ b/include/simple_sampler.h @@ -5,12 +5,12 @@ namespace manta { - class SimpleSampler : public Sampler2D { + class SimpleSampler : public Sampler2d { public: SimpleSampler(); ~SimpleSampler(); - virtual void generateSamples(int sampleCount, math::Vector *target) const; + virtual void generateSamples(int sampleCount, math::Vector2 *target) const; virtual int getTotalSampleCount(int sampleCount) const; }; diff --git a/include/standard_camera_ray_emitter.h b/include/standard_camera_ray_emitter.h index b368cc89..805db1c4 100644 --- a/include/standard_camera_ray_emitter.h +++ b/include/standard_camera_ray_emitter.h @@ -1,7 +1,7 @@ #ifndef MANTARAY_STANDARD_CAMERA_RAY_EMITTER_H #define MANTARAY_STANDARD_CAMERA_RAY_EMITTER_H -#include "../include/camera_ray_emitter.h" +#include "camera_ray_emitter.h" namespace manta { @@ -13,12 +13,6 @@ namespace manta { virtual ~StandardCameraRayEmitter(); virtual void generateRays(RayContainer *rayContainer) const; - - void setTargetOrigin(const math::Vector &origin) { m_targetOrigin = origin; } - math::Vector getTargetOrigin() const { return m_targetOrigin; } - - protected: - math::Vector m_targetOrigin; }; } /* namespace manta */ diff --git a/include/subtract_node_output.h b/include/subtract_node_output.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/triangle_filter.h b/include/triangle_filter.h new file mode 100644 index 00000000..78c0be5f --- /dev/null +++ b/include/triangle_filter.h @@ -0,0 +1,19 @@ +#ifndef MANTARAY_TRIANGLE_FILTER_H +#define MANTARAY_TRIANGLE_FILTER_H + +#include "filter.h" + +namespace manta { + + class TriangleFilter : public Filter { + public: + TriangleFilter(); + ~TriangleFilter(); + + virtual math::Vector evaluate(const math::Vector2 &p); + }; + +} /* namespace manta */ + +#endif /* MANTARAY_TRIANGLE_FILTER_H */ + diff --git a/include/unary_node.h b/include/unary_node.h index f474a944..b2a9b034 100644 --- a/include/unary_node.h +++ b/include/unary_node.h @@ -4,6 +4,7 @@ #include "node.h" #include "unary_node_output.h" +#include "uv_operation_output.h" namespace manta { @@ -42,12 +43,17 @@ namespace manta { template using UnaryNode = SingleOutputNode>; + template + using UvNode = SingleOutputNode>; + typedef UnaryNode VectorNegateNode; typedef UnaryNode VectorNormalizeNode; typedef UnaryNode VectorMagnitudeNode; typedef UnaryNode VectorMaxComponentNode; typedef UnaryNode VectorAbsoluteNode; + typedef UvNode UvWrapNode; + } /* namespace manta */ #endif /* MANTARAY_UNARY_NODE_H */ diff --git a/include/uv_operation_output.h b/include/uv_operation_output.h new file mode 100644 index 00000000..b42df016 --- /dev/null +++ b/include/uv_operation_output.h @@ -0,0 +1,101 @@ +#ifndef MANTARAY_UV_OPERATION_OUTPUT_H +#define MANTARAY_UV_OPERATION_OUTPUT_H + +#include "vector_node_output.h" + +#include "surface_interaction_node.h" + +namespace manta { + + enum UV_OPERATION { + WRAP + }; + + template + class UvOperationOutput : public VectorNodeOutput { + public: + + public: + UvOperationOutput() { + m_input = nullptr; + } + + virtual ~UvOperationOutput() { + /* void */ + } + + static inline bool doOp(const IntersectionPoint *surfaceInteraction, IntersectionPoint *output) { + switch (op) { + case WRAP: + return wrap(surfaceInteraction, output); + default: + return false; + } + } + + static inline bool wrap(const IntersectionPoint *surfaceInteraction, IntersectionPoint *output) { + math::real u = math::getX(surfaceInteraction->m_textureCoodinates); + math::real v = math::getY(surfaceInteraction->m_textureCoodinates); + + if (u <= (math::real)1.0 && u >= (math::real)0.0 && + v <= (math::real)1.0 && v >= (math::real)0.0) { + return false; + } + + math::real fu = fmodf(u, (math::real)1.0); + math::real fv = fmodf(v, (math::real)1.0); + + if (fu < (math::real)0.0) fu += (math::real)1.0; + if (fv < (math::real)0.0) fv += (math::real)1.0; + + math::Vector newCoordinates = math::loadVector(fu, fv); + + *output = *surfaceInteraction; + output->m_textureCoodinates = newCoordinates; + + return true; + } + + virtual void sample(const IntersectionPoint *surfaceInteraction, void *target) const { + IntersectionPoint newIntersectionPoint; + bool changed = doOp(surfaceInteraction, &newIntersectionPoint); + + if (!changed) static_cast(m_input)->sample(surfaceInteraction, target); + else static_cast(m_input)->sample(&newIntersectionPoint, target); + } + + virtual void discreteSample2d(int x, int y, void *target) const { + static_cast(m_input)->discreteSample2d(x, y, target); + } + + virtual void getDataReference(const void **target) const { + *target = nullptr; + } + + virtual void _evaluateDimensions() { + VectorNodeOutput *input = static_cast(m_input); + input->evaluateDimensions(); + + int dimensions = input->getDimensions(); + setDimensions(dimensions); + + for (int i = 0; i < dimensions; i++) { + setDimensionSize(i, input->getSize(i)); + } + } + + piranha::pNodeInput *getConnection() { return &m_input; } + + protected: + virtual void registerInputs() { + registerInput(&m_input); + } + + protected: + piranha::pNodeInput m_input; + }; + +} /* namespace manta */ + +#endif /* MANTARAY_UNARY_NODE_OUTPUT_H */ + diff --git a/project/mantaray/mantaray.vcxproj b/project/mantaray/mantaray.vcxproj index 15f68ee2..94cc723e 100644 --- a/project/mantaray/mantaray.vcxproj +++ b/project/mantaray/mantaray.vcxproj @@ -19,13 +19,16 @@ - + + + + @@ -57,14 +60,12 @@ - - - + @@ -73,8 +74,8 @@ - + @@ -87,7 +88,6 @@ - @@ -140,6 +140,7 @@ + @@ -158,10 +159,13 @@ + + + @@ -170,6 +174,7 @@ + @@ -183,9 +188,6 @@ - - - @@ -196,11 +198,12 @@ - + + @@ -217,7 +220,6 @@ - diff --git a/project/mantaray/mantaray.vcxproj.filters b/project/mantaray/mantaray.vcxproj.filters index ad65364a..b83b0aff 100644 --- a/project/mantaray/mantaray.vcxproj.filters +++ b/project/mantaray/mantaray.vcxproj.filters @@ -295,9 +295,6 @@ {f142cbcd-03f8-4292-b817-5637529626ab} - - {e6161bde-c428-46bc-9101-9e05975ed498} - {70ed637c-565b-4cc0-9fa5-2fcc9967b349} @@ -379,6 +376,21 @@ {bc3c2bf2-cc92-4569-b7a0-0327bf8ee7c1} + + {89e2613f-ff55-430f-8257-8e22a1cf097f} + + + {82c2a266-f2f2-451f-99da-140c1234b0fd} + + + {3bfcff02-9cde-43f7-8f05-6368b2f952d0} + + + {8615616b-68db-4c78-9a05-e55e54f81a72} + + + {3f6cc6d2-bc47-4428-96df-ec52cdedae07} + @@ -543,9 +555,6 @@ Source Files\material\interface\library - - Source Files\material\interface\library - Source Files\output\jpeg @@ -612,9 +621,6 @@ Source Files\sdl\nodes\output-ports - - Source Files\sdl\nodes\output-ports\operations - Source Files\sdl\nodes\output-ports\operations @@ -630,9 +636,6 @@ Source Files\sdl\nodes - - Source Files\sdl\nodes\library - Source Files\sdl\nodes\output-ports\operations @@ -693,12 +696,6 @@ Source Files\material\interface - - Source Files\sdl\nodes\output-ports\operations\binary - - - Source Files\sdl\nodes\output-ports\operations\binary - Source Files\sdl\nodes\output-ports\atomic-types @@ -717,12 +714,27 @@ Source Files\sdl\nodes\library\date - - Source Files\sdl\nodes\library\date - Source Files\sdl\nodes\library\surface-interaction + + Source Files\sdl\nodes\library\date + + + Source Files\emitter\sampling + + + Source Files\image-plane\filters + + + Source Files\image-plane\filters + + + Source Files\image-plane\filters + + + Source Files\image-plane\filters + @@ -944,9 +956,6 @@ Header Files\sdl\nodes\library - - Header Files\sdl\nodes\library - Header Files\output\jpeg @@ -1031,9 +1040,6 @@ Header Files\sdl\nodes\output-ports - - Header Files\sdl\nodes\output-ports\operations - Header Files\sdl\nodes\output-ports\operations @@ -1043,9 +1049,6 @@ Header Files\sdl\nodes\library - - Header Files\sdl\nodes\library - Header Files\sdl\nodes\output-ports\operations @@ -1103,12 +1106,6 @@ Header Files\material\interface - - Header Files\sdl\nodes\output-ports\operations\binary - - - Header Files\sdl\nodes\output-ports\operations\binary - Header Files\sdl\nodes\output-ports\operations\binary @@ -1148,6 +1145,27 @@ Header Files\sdl\nodes\output-ports\surface-interaction + + Header Files\emitter\sampling + + + Header Files\emitter\sampling + + + Header Files\image-plane\filters + + + Header Files\image-plane\filters + + + Header Files\image-plane\filters + + + Header Files\image-plane\filters + + + Header Files\sdl\nodes\output-ports\uv + diff --git a/project/mantaray_test/mantaray_test.vcxproj b/project/mantaray_test/mantaray_test.vcxproj index f18ebc29..d13ee3c6 100644 --- a/project/mantaray_test/mantaray_test.vcxproj +++ b/project/mantaray_test/mantaray_test.vcxproj @@ -72,6 +72,7 @@ + diff --git a/project/mantaray_test/mantaray_test.vcxproj.filters b/project/mantaray_test/mantaray_test.vcxproj.filters index 8555903b..87a8cc7e 100644 --- a/project/mantaray_test/mantaray_test.vcxproj.filters +++ b/project/mantaray_test/mantaray_test.vcxproj.filters @@ -65,6 +65,9 @@ Tests + + Tests + diff --git a/sdl/manta-lib/camera/cameras.mr b/sdl/manta-lib/camera/cameras.mr index 2d105540..f35ede48 100644 --- a/sdl/manta-lib/camera/cameras.mr +++ b/sdl/manta-lib/camera/cameras.mr @@ -11,7 +11,7 @@ module { private import "lenses.mr" private import "../types/atomic_types.mr" -private import "../sampler/samplers.mr" +private import "../signal-processing/samplers/samplers.mr" @doc: "Camera channel type" public node camera => __mantaray__camera { /* void */ } diff --git a/sdl/manta-lib/image/uv_operations.mr b/sdl/manta-lib/image/uv_operations.mr new file mode 100644 index 00000000..7f4a46aa --- /dev/null +++ b/sdl/manta-lib/image/uv_operations.mr @@ -0,0 +1,18 @@ +module { + @name: "UV Operations" + @project: "MantaRay" + @author: "Ange Yaghi" + @maintainer: "Ange Yaghi" + @copyright: "Copyright 2019, Ange Yaghi" + @doc: "Operations to transform UV coordinates" + @version: "0.0.1a" + @github: "github.com/ange-yaghi/manta-ray" +} + +private import "../types/atomic_types.mr" + +@doc: "UV wrap node" +public node uv_wrap => __mantaray__uv_wrap { + input __in [vector]; + alias output __out [vector]; +} diff --git a/sdl/manta-lib/mantaray.mr b/sdl/manta-lib/mantaray.mr index 2539ee93..58bd851b 100644 --- a/sdl/manta-lib/mantaray.mr +++ b/sdl/manta-lib/mantaray.mr @@ -13,6 +13,7 @@ public import "ray-tracer/ray_tracer.mr" public import "image/image_output.mr" public import "image/vector_map.mr" public import "image/image_file.mr" +public import "image/uv_operations.mr" public import "types/atomic_types.mr" public import "types/conversions.mr" @@ -20,15 +21,6 @@ public import "types/operations.mr" public import "dates/dates.mr" -public import "microfacet-models/microfacet_distributions.mr" - -public import "bsdf/bsdf.mr" -public import "bsdf/media-interface/media_interfaces.mr" -public import "bsdf/bilayer_bsdf.mr" -public import "bsdf/lambertian_bsdf.mr" -public import "bsdf/microfacet_reflection_bsdf.mr" -public import "bsdf/glass_bsdf.mr" - public import "mesh/mesh.mr" public import "mesh/obj_file.mr" public import "mesh/utilities.mr" @@ -39,24 +31,40 @@ public import "scene/scene.mr" public import "acceleration/kd_tree.mr" -public import "materials/material_library.mr" -public import "materials/material.mr" -public import "materials/bsdf_material.mr" -public import "materials/surface_interaction.mr" - public import "camera/cameras.mr" public import "camera/utilities.mr" public import "camera/diffraction.mr" public import "camera/apertures.mr" public import "camera/lenses.mr" -public import "sampler/samplers.mr" - public import "primitives/primitives.mr" -public import "color/color.mr" - -public import "signal-processing/convolution.mr" - public import "utilities/console.mr" public import "utilities/quick_render.mr" + +// ======================================================== +// Surface/Material Models +// ======================================================== +public import "surface/microfacet-models/microfacet_distributions.mr" + +public import "surface/bsdf/media-interface/media_interfaces.mr" + +public import "surface/bsdf/bsdf.mr" +public import "surface/bsdf/bilayer_bsdf.mr" +public import "surface/bsdf/lambertian_bsdf.mr" +public import "surface/bsdf/microfacet_reflection_bsdf.mr" +public import "surface/bsdf/glass_bsdf.mr" + +public import "surface/materials/material_library.mr" +public import "surface/materials/material.mr" +public import "surface/materials/bsdf_material.mr" +public import "surface/materials/surface_interaction.mr" + +public import "surface/color/color.mr" + +// ======================================================== +// Signal Processing +// ======================================================== +public import "signal-processing/convolution/convolution.mr" +public import "signal-processing/filters/filters.mr" +public import "signal-processing/samplers/samplers.mr" diff --git a/sdl/manta-lib/mesh/obj_file.mr b/sdl/manta-lib/mesh/obj_file.mr index 77461aa0..1585f380 100644 --- a/sdl/manta-lib/mesh/obj_file.mr +++ b/sdl/manta-lib/mesh/obj_file.mr @@ -10,7 +10,7 @@ module { } private import "mesh.mr" -private import "../materials/material_library.mr" +private import "../surface/materials/material_library.mr" private import "../types/atomic_types.mr" @doc: "Object file loader" diff --git a/sdl/manta-lib/primitives/primitives.mr b/sdl/manta-lib/primitives/primitives.mr index 884c1499..f2869d27 100644 --- a/sdl/manta-lib/primitives/primitives.mr +++ b/sdl/manta-lib/primitives/primitives.mr @@ -12,7 +12,7 @@ module { private import "../scene/scene_geometry.mr" private import "../types/atomic_types.mr" private import "../types/conversions.mr" -private import "../materials/material_library.mr" +private import "../surface/materials/material_library.mr" @doc: "Simple sphere primitive" public node sphere => __mantaray__sphere { diff --git a/sdl/manta-lib/ray-tracer/ray_tracer.mr b/sdl/manta-lib/ray-tracer/ray_tracer.mr index 490fa437..48af0878 100644 --- a/sdl/manta-lib/ray-tracer/ray_tracer.mr +++ b/sdl/manta-lib/ray-tracer/ray_tracer.mr @@ -11,10 +11,11 @@ module { private import "../scene/scene.mr" private import "../camera/cameras.mr" -private import "../materials/material_library.mr" +private import "../surface/materials/material_library.mr" private import "../types/atomic_types.mr" private import "../types/conversions.mr" private import "../image/vector_map.mr" +private import "../signal-processing/filters/filters.mr" @doc: "Unidirectional MantaRay ray-tracer" public node ray_tracer => __mantaray__ray_tracer { @@ -22,6 +23,7 @@ public node ray_tracer => __mantaray__ray_tracer { input scene [scene]; input camera [camera]; input materials [material_library]; + input filter [filter]: gaussian_filter(); // Optional inputs input multithreaded [bool]: true; diff --git a/sdl/manta-lib/scene/scene_object.mr b/sdl/manta-lib/scene/scene_object.mr index 03235b91..791495e4 100644 --- a/sdl/manta-lib/scene/scene_object.mr +++ b/sdl/manta-lib/scene/scene_object.mr @@ -11,7 +11,7 @@ module { private import "scene.mr" private import "scene_geometry.mr" -private import "../materials/material.mr" +private import "../surface/materials/material.mr" private import "../types/atomic_types.mr" @doc: "Scene object channel type" diff --git a/sdl/manta-lib/signal-processing/convolution.mr b/sdl/manta-lib/signal-processing/convolution/convolution.mr similarity index 87% rename from sdl/manta-lib/signal-processing/convolution.mr rename to sdl/manta-lib/signal-processing/convolution/convolution.mr index 430bfd99..68060071 100644 --- a/sdl/manta-lib/signal-processing/convolution.mr +++ b/sdl/manta-lib/signal-processing/convolution/convolution.mr @@ -9,8 +9,8 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../image/vector_map.mr" -private import "../types/atomic_types.mr" +private import "../../image/vector_map.mr" +private import "../../types/atomic_types.mr" public node convolve_2d => __mantaray__convolve_2d { input base [vector_map]; diff --git a/sdl/manta-lib/signal-processing/filters/filters.mr b/sdl/manta-lib/signal-processing/filters/filters.mr new file mode 100644 index 00000000..4da9cfc7 --- /dev/null +++ b/sdl/manta-lib/signal-processing/filters/filters.mr @@ -0,0 +1,34 @@ +module { + @name: "Filters" + @project: "MantaRay" + @author: "Ange Yaghi" + @maintainer: "Ange Yaghi" + @copyright: "Copyright 2019, Ange Yaghi" + @doc: "Defines all ImagePlane filters" + @version: "0.0.1a" + @github: "github.com/ange-yaghi/manta-ray" +} + +private import "../../types/atomic_types.mr" + +@doc: "Filter type" +public node filter => __mantaray__filter { /* void */ } + +@doc: "Box filter" +public node box_filter => __mantaray__box_filter { + input radius [float]: 0.5; + alias output __out [filter]; +} + +@doc: "Triangle filter" +public node triangle_filter => __mantaray__triangle_filter { + input radius [float]: 0.5; + alias output __out [filter]; +} + +@doc: "Gaussian filter" +public node gaussian_filter => __mantaray__gaussian_filter { + input radius [float]: 1.0; + input alpha [float]: 4.0; + alias output __out [filter]; +} diff --git a/sdl/manta-lib/sampler/samplers.mr b/sdl/manta-lib/signal-processing/samplers/samplers.mr similarity index 95% rename from sdl/manta-lib/sampler/samplers.mr rename to sdl/manta-lib/signal-processing/samplers/samplers.mr index 88cc98fa..4a1d828b 100644 --- a/sdl/manta-lib/sampler/samplers.mr +++ b/sdl/manta-lib/signal-processing/samplers/samplers.mr @@ -9,7 +9,7 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../types/atomic_types.mr" +private import "../../types/atomic_types.mr" @doc: "2D sampler channel type" public node sampler_2d => __mantaray__sampler { /* void */ } diff --git a/sdl/manta-lib/bsdf/bilayer_bsdf.mr b/sdl/manta-lib/surface/bsdf/bilayer_bsdf.mr similarity index 88% rename from sdl/manta-lib/bsdf/bilayer_bsdf.mr rename to sdl/manta-lib/surface/bsdf/bilayer_bsdf.mr index cc056203..b3283338 100644 --- a/sdl/manta-lib/bsdf/bilayer_bsdf.mr +++ b/sdl/manta-lib/surface/bsdf/bilayer_bsdf.mr @@ -11,8 +11,8 @@ module { private import "bsdf.mr" private import "../microfacet-models/microfacet_distributions.mr" -private import "../types/atomic_types.mr" as types -private import "../types/conversions.mr" +private import "../../types/atomic_types.mr" as types +private import "../../types/conversions.mr" @doc: "Bilayer BSDF for realistic surface simulation" public node bilayer_bsdf => __mantaray__bilayer_bsdf { diff --git a/sdl/manta-lib/bsdf/bsdf.mr b/sdl/manta-lib/surface/bsdf/bsdf.mr similarity index 100% rename from sdl/manta-lib/bsdf/bsdf.mr rename to sdl/manta-lib/surface/bsdf/bsdf.mr diff --git a/sdl/manta-lib/bsdf/glass_bsdf.mr b/sdl/manta-lib/surface/bsdf/glass_bsdf.mr similarity index 90% rename from sdl/manta-lib/bsdf/glass_bsdf.mr rename to sdl/manta-lib/surface/bsdf/glass_bsdf.mr index 75d1b809..162bc0b4 100644 --- a/sdl/manta-lib/bsdf/glass_bsdf.mr +++ b/sdl/manta-lib/surface/bsdf/glass_bsdf.mr @@ -12,8 +12,8 @@ module { private import "bsdf.mr" private import "media-interface/media_interfaces.mr" private import "../microfacet-models/microfacet_distributions.mr" -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" +private import "../../types/atomic_types.mr" +private import "../../types/conversions.mr" @doc: "Glass BSDF for glass transmission and reflection" public node glass_bsdf => __mantaray__glass_bsdf { diff --git a/sdl/manta-lib/bsdf/lambertian_bsdf.mr b/sdl/manta-lib/surface/bsdf/lambertian_bsdf.mr similarity index 100% rename from sdl/manta-lib/bsdf/lambertian_bsdf.mr rename to sdl/manta-lib/surface/bsdf/lambertian_bsdf.mr diff --git a/sdl/manta-lib/bsdf/media-interface/media_interfaces.mr b/sdl/manta-lib/surface/bsdf/media-interface/media_interfaces.mr similarity index 94% rename from sdl/manta-lib/bsdf/media-interface/media_interfaces.mr rename to sdl/manta-lib/surface/bsdf/media-interface/media_interfaces.mr index 8994d6e1..0ba14a03 100644 --- a/sdl/manta-lib/bsdf/media-interface/media_interfaces.mr +++ b/sdl/manta-lib/surface/bsdf/media-interface/media_interfaces.mr @@ -9,7 +9,7 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../../types/atomic_types.mr" +private import "../../../types/atomic_types.mr" @doc: "Media interface channel type" public node media_interface => __mantaray__media_interface { /* void */ } diff --git a/sdl/manta-lib/bsdf/microfacet_reflection_bsdf.mr b/sdl/manta-lib/surface/bsdf/microfacet_reflection_bsdf.mr similarity index 88% rename from sdl/manta-lib/bsdf/microfacet_reflection_bsdf.mr rename to sdl/manta-lib/surface/bsdf/microfacet_reflection_bsdf.mr index c3e59213..9275f878 100644 --- a/sdl/manta-lib/bsdf/microfacet_reflection_bsdf.mr +++ b/sdl/manta-lib/surface/bsdf/microfacet_reflection_bsdf.mr @@ -11,8 +11,8 @@ module { private import "bsdf.mr" private import "../microfacet-models/microfacet_distributions.mr" -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" +private import "../../types/atomic_types.mr" +private import "../../types/conversions.mr" @doc: "Single layer reflection BSDF" public node microfacet_reflection_bsdf => __mantaray__microfacet_reflection_bsdf { diff --git a/sdl/manta-lib/color/color.mr b/sdl/manta-lib/surface/color/color.mr similarity index 86% rename from sdl/manta-lib/color/color.mr rename to sdl/manta-lib/surface/color/color.mr index e760be62..c8dc17e6 100644 --- a/sdl/manta-lib/color/color.mr +++ b/sdl/manta-lib/surface/color/color.mr @@ -9,9 +9,9 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../types/atomic_types.mr" -private import "../types/conversions.mr" -private import "../types/operations.mr" +private import "../../types/atomic_types.mr" +private import "../../types/conversions.mr" +private import "../../types/operations.mr" @doc: "Convert gamma curved sRGB space colors to linear vectors" public node srgb => __mantaray__srgb { diff --git a/sdl/manta-lib/materials/bsdf_material.mr b/sdl/manta-lib/surface/materials/bsdf_material.mr similarity index 56% rename from sdl/manta-lib/materials/bsdf_material.mr rename to sdl/manta-lib/surface/materials/bsdf_material.mr index 449e1832..423f4143 100644 --- a/sdl/manta-lib/materials/bsdf_material.mr +++ b/sdl/manta-lib/surface/materials/bsdf_material.mr @@ -1,24 +1,25 @@ module { - @name: "BSDF Material" + @name: "Single BSDF Material" @project: "MantaRay" @author: "Ange Yaghi" @maintainer: "Ange Yaghi" @copyright: "Copyright 2019, Ange Yaghi" - @doc: "Defines builtin microfacet distributions" - @version: "0.0.1a" + @doc: "Defines single BSDF material" + @version: "0.1.0a" @github: "github.com/ange-yaghi/manta-ray" } -private import "../materials/material.mr" +private import "material_library.mr" +private import "material.mr" private import "../bsdf/bsdf.mr" -private import "../materials/material_library.mr" -private import "../types/atomic_types.mr" as types -private import "../types/conversions.mr" +private import "../bsdf/lambertian_bsdf.mr" +private import "../../types/atomic_types.mr" as types +private import "../../types/conversions.mr" public node bsdf_material => __mantaray__simple_bsdf_material { input name [types::string]: ""; modify library [material_library]; - input bsdf [bsdf]; + input bsdf [bsdf]: lambertian_bsdf(); // Defaults to Lambert input reflectance [types::vector]: 1.0; input emission [types::vector]: 0.0; diff --git a/sdl/manta-lib/materials/material.mr b/sdl/manta-lib/surface/materials/material.mr similarity index 100% rename from sdl/manta-lib/materials/material.mr rename to sdl/manta-lib/surface/materials/material.mr diff --git a/sdl/manta-lib/materials/material_library.mr b/sdl/manta-lib/surface/materials/material_library.mr similarity index 100% rename from sdl/manta-lib/materials/material_library.mr rename to sdl/manta-lib/surface/materials/material_library.mr diff --git a/sdl/manta-lib/materials/surface_interaction.mr b/sdl/manta-lib/surface/materials/surface_interaction.mr similarity index 94% rename from sdl/manta-lib/materials/surface_interaction.mr rename to sdl/manta-lib/surface/materials/surface_interaction.mr index 7eb3a442..bc33fb96 100644 --- a/sdl/manta-lib/materials/surface_interaction.mr +++ b/sdl/manta-lib/surface/materials/surface_interaction.mr @@ -10,7 +10,7 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../types/atomic_types.mr" +private import "../../types/atomic_types.mr" @doc: "Surface interaction probe node" public node surface_interaction => __mantaray__surface_interaction { diff --git a/sdl/manta-lib/microfacet-models/microfacet_distributions.mr b/sdl/manta-lib/surface/microfacet-models/microfacet_distributions.mr similarity index 90% rename from sdl/manta-lib/microfacet-models/microfacet_distributions.mr rename to sdl/manta-lib/surface/microfacet-models/microfacet_distributions.mr index fd93e011..80523fd8 100644 --- a/sdl/manta-lib/microfacet-models/microfacet_distributions.mr +++ b/sdl/manta-lib/surface/microfacet-models/microfacet_distributions.mr @@ -9,8 +9,8 @@ module { @github: "github.com/ange-yaghi/manta-ray" } -private import "../types/atomic_types.mr" as types -private import "../types/conversions.mr" +private import "../../types/atomic_types.mr" as types +private import "../../types/conversions.mr" @doc: "Microfacet distribution channel type" public node microfacet_distribution => __mantaray__microfacet_distribution { /* void */ } diff --git a/sdl/manta-lib/utilities/quick_render.mr b/sdl/manta-lib/utilities/quick_render.mr index b1613546..0679b22d 100644 --- a/sdl/manta-lib/utilities/quick_render.mr +++ b/sdl/manta-lib/utilities/quick_render.mr @@ -14,9 +14,9 @@ private import "console.mr" private import "../types/atomic_types.mr" private import "../types/conversions.mr" private import "../types/operations.mr" -private import "../materials/material_library.mr" -private import "../materials/bsdf_material.mr" -private import "../bsdf/lambertian_bsdf.mr" +private import "../surface/materials/material_library.mr" +private import "../surface/materials/bsdf_material.mr" +private import "../surface/bsdf/lambertian_bsdf.mr" private import "../camera/utilities.mr" private import "../camera/cameras.mr" private import "../scene/scene_object.mr" @@ -25,7 +25,7 @@ private import "../scene/scene.mr" private import "../acceleration/kd_tree.mr" private import "../dates/dates.mr" private import "../ray-tracer/ray_tracer.mr" -private import "../sampler/samplers.mr" +private import "../signal-processing/samplers/samplers.mr" private import "../image/image_output.mr" private import "../mesh/obj_file.mr" diff --git a/src/box_filter.cpp b/src/box_filter.cpp new file mode 100644 index 00000000..5dddfd84 --- /dev/null +++ b/src/box_filter.cpp @@ -0,0 +1,13 @@ +#include "../include/box_filter.h" + +manta::BoxFilter::BoxFilter() { + /* void */ +} + +manta::BoxFilter::~BoxFilter() { + /* void */ +} + +manta::math::Vector manta::BoxFilter::evaluate(const math::Vector2 &p) { + return math::constants::One; +} diff --git a/src/camera_ray_emitter.cpp b/src/camera_ray_emitter.cpp index 1525dc9e..f9da3e4c 100644 --- a/src/camera_ray_emitter.cpp +++ b/src/camera_ray_emitter.cpp @@ -13,3 +13,13 @@ manta::CameraRayEmitter::CameraRayEmitter() { manta::CameraRayEmitter::~CameraRayEmitter() { /* void */ } + +manta::math::Vector manta::CameraRayEmitter::transformToImagePlane(const math::Vector2 coordinates) const { + math::Vector u = math::mul(m_right, math::loadScalar(coordinates.x * m_pixelIncrement.x)); + math::Vector v = math::mul(m_up, math::loadScalar(coordinates.y * m_pixelIncrement.y)); + math::Vector samplePoint3d = math::add(u, v); + + math::Vector imagePlaneT = math::add(m_imagePlaneOrigin, samplePoint3d); + + return imagePlaneT; +} diff --git a/src/camera_ray_emitter_group.cpp b/src/camera_ray_emitter_group.cpp index 358f50fc..6df80187 100644 --- a/src/camera_ray_emitter_group.cpp +++ b/src/camera_ray_emitter_group.cpp @@ -34,7 +34,7 @@ void manta::CameraRayEmitterGroup::_evaluate() { static_cast(m_planeDistanceInput)->fullCompute((void *)&m_planeDistance); static_cast(m_sampleInput)->fullCompute((void *)&m_samples); - m_sampler = static_cast *>(m_samplerInput)->getReference(); + m_sampler = static_cast *>(m_samplerInput)->getReference(); m_output.setReference(this); } diff --git a/include/current_date_node.cpp b/src/current_date_node.cpp similarity index 92% rename from include/current_date_node.cpp rename to src/current_date_node.cpp index 91da9661..a7f8386a 100644 --- a/include/current_date_node.cpp +++ b/src/current_date_node.cpp @@ -1,4 +1,4 @@ -#include "current_date_node.h" +#include "../include/current_date_node.h" manta::CurrentDateNode::CurrentDateNode() { /* void */ diff --git a/src/filter.cpp b/src/filter.cpp new file mode 100644 index 00000000..23cf6911 --- /dev/null +++ b/src/filter.cpp @@ -0,0 +1,25 @@ +#include "../include/filter.h" + +manta::Filter::Filter() { + /* void */ +} + +manta::Filter::~Filter() { + /* void */ +} + +void manta::Filter::_initialize() { + m_output.setReference(this); +} + +void manta::Filter::_evaluate() { + piranha::native_float radius; + m_radiusInput->fullCompute((void *)&radius); + + m_extents.x = (math::real)radius; + m_extents.y = (math::real)radius; +} + +void manta::Filter::registerInputs() { + registerInput(&m_radiusInput, "radius"); +} diff --git a/src/gaussian_filter.cpp b/src/gaussian_filter.cpp new file mode 100644 index 00000000..f457a31b --- /dev/null +++ b/src/gaussian_filter.cpp @@ -0,0 +1,77 @@ +#include "../include/gaussian_filter.h" + +#include "../include/standard_allocator.h" + +#include + +manta::GaussianFilter::GaussianFilter() { + m_alpha = (math::real)0.0; + m_expX = (math::real)0.0; + m_expY = (math::real)0.0; + m_cache = nullptr; +} + +manta::GaussianFilter::~GaussianFilter() { + /* void */ +} + +void manta::GaussianFilter::configure(math::real alpha) { + m_alpha = alpha; + m_expX = std::exp(-m_alpha * m_extents.x * m_extents.x); + m_expY = std::exp(-m_alpha * m_extents.y * m_extents.y); + m_invR = 1 / m_extents.x; + + if (ENABLE_CACHE) { + computeCache(); + } +} + +manta::math::Vector manta::GaussianFilter::evaluate(const math::Vector2 &p) { + return (m_cache == nullptr) + ? math::loadScalar(gaussian(p.x, m_expX) * gaussian(p.y, m_expY)) + : math::loadScalar(gaussianCache(p.x) * gaussianCache(p.y)); +} + +manta::math::real manta::GaussianFilter::gaussian(math::real d, math::real expv) { + return std::max((math::real)0.0, (math::real)(std::exp(-m_alpha * d * d) - expv)); +} + +manta::math::real manta::GaussianFilter::gaussianCache(math::real d) { + constexpr int actualSteps = CACHE_STEPS - SAFETY_FACTOR; + int index = (int)(actualSteps * (std::abs(d) * m_invR)); + return m_cache[index]; +} + +void manta::GaussianFilter::computeCache() { + constexpr int actualSteps = CACHE_STEPS - SAFETY_FACTOR; + constexpr math::real step = (math::real)1.0 / actualSteps; + + m_cache = StandardAllocator::Global()->allocate(CACHE_STEPS); + for (int i = 0; i <= actualSteps; i++) { + math::real s = step * i * m_extents.x; + m_cache[i] = gaussian(s, m_expX); + } + + for (int i = actualSteps + 1; i < CACHE_STEPS; i++) { + m_cache[i] = (math::real)0.0; + } +} + +void manta::GaussianFilter::_initialize() { + Filter::_initialize(); +} + +void manta::GaussianFilter::_evaluate() { + Filter::_evaluate(); + + piranha::native_float alpha; + m_alphaInput->fullCompute((void *)&alpha); + + configure((math::real)alpha); +} + +void manta::GaussianFilter::registerInputs() { + Filter::registerInputs(); + + registerInput(&m_alphaInput, "alpha"); +} diff --git a/src/ggx_distribution.cpp b/src/ggx_distribution.cpp index 380d747e..8f784ab2 100644 --- a/src/ggx_distribution.cpp +++ b/src/ggx_distribution.cpp @@ -14,7 +14,9 @@ manta::GgxDistribution::~GgxDistribution() { /* void */ } -void manta::GgxDistribution::initializeSessionMemory(const IntersectionPoint *surfaceInteraction, NodeSessionMemory *memory, StackAllocator *stackAllocator) const { +void manta::GgxDistribution::initializeSessionMemory(const IntersectionPoint *surfaceInteraction, + NodeSessionMemory *memory, StackAllocator *stackAllocator) const +{ MicrofacetDistribution::initializeSessionMemory(surfaceInteraction, memory, stackAllocator); GgxMemory *phongMemory = reinterpret_cast((void *)memory->memory); diff --git a/src/grid_sampler.cpp b/src/grid_sampler.cpp index e49972bf..0fc8d1e9 100644 --- a/src/grid_sampler.cpp +++ b/src/grid_sampler.cpp @@ -11,41 +11,23 @@ manta::GridSampler::~GridSampler() { /* void */ } -void manta::GridSampler::generateSamples(int sampleCount, math::Vector *target) const { +void manta::GridSampler::generateSamples(int sampleCount, math::Vector2 *target) const { assert(m_gridWidth > 0); int latticePoints = m_gridWidth * m_gridWidth; int actualSampleCount = getTotalSampleCount(sampleCount); actualSampleCount /= latticePoints; - math::real xStep = m_boundaryWidth / m_gridWidth; - math::real yStep = m_boundaryHeight / m_gridWidth; - - // Find the origin - math::real offset; - if (m_gridWidth % 2 == 0) { - // Even sampling - offset = (math::real)0.5; - } - else { - offset = (math::real)0.0; - } - - int half = m_gridWidth / 2; - - offset = -half + offset; + math::real xStep = (math::real)1.0 / m_gridWidth; + math::real yStep = (math::real)1.0 / m_gridWidth; for (int s = 0; s < actualSampleCount; s++) { for (int i = 0; i < m_gridWidth; i++) { for (int j = 0; j < m_gridWidth; j++) { - math::real x = (j + offset) * xStep; - math::real y = (i + offset) * yStep; - - math::Vector u = math::mul(m_axis1, math::loadScalar(x)); - math::Vector v = math::mul(m_axis2, math::loadScalar(y)); - math::Vector rayTarget = math::add(u, v); + math::real x = (j + (math::real)0.5) * xStep; + math::real y = (i + (math::real)0.5) * yStep; - target[s * latticePoints + i * m_gridWidth + j] = rayTarget; + target[s * latticePoints + i * m_gridWidth + j] = math::Vector2(x, y); } } } diff --git a/src/image_file_node.cpp b/src/image_file_node.cpp index 09929173..1885799c 100644 --- a/src/image_file_node.cpp +++ b/src/image_file_node.cpp @@ -42,6 +42,11 @@ void manta::ImageFileNode::_evaluate() { SDL_Surface *image; image = IMG_Load(m_filename.c_str()); + if (image == nullptr) { + throwError("Image: " + m_filename + " could not be opened or was not found"); + return; + } + // Create a temporary pixel buffer Pixel **pixelData = StandardAllocator::Global()->allocate(image->h); for (int i = 0; i < image->h; i++) { diff --git a/src/image_plane.cpp b/src/image_plane.cpp index 1b8491d5..00b7edc5 100644 --- a/src/image_plane.cpp +++ b/src/image_plane.cpp @@ -1,6 +1,9 @@ #include "../include/image_plane.h" -#include "../include/convolution.h" +#include "../include/standard_allocator.h" +#include "../include/gaussian_filter.h" +#include "../include/triangle_filter.h" +#include "../include/box_filter.h" #include #include @@ -9,36 +12,47 @@ manta::ImagePlane::ImagePlane() { m_width = 0; m_height = 0; m_buffer = nullptr; + m_sampleWeightSums = nullptr; + m_filter = nullptr; } manta::ImagePlane::~ImagePlane() { assert(m_buffer == nullptr); + assert(m_sampleWeightSums == nullptr); } -void manta::ImagePlane::initialize(int width, int height, math::real physicalWidth, math::real physicalHeight) { +void manta::ImagePlane::initialize(int width, int height) { assert(width != 0); assert(height != 0); m_width = width; m_height = height; - m_physicalWidth = physicalWidth; - m_physicalHeight = physicalHeight; + int pixelCount = width * height; - m_buffer = (math::Vector *)_aligned_malloc(sizeof(math::Vector) * width * height, 16); + m_buffer = (math::Vector *)_aligned_malloc(sizeof(math::Vector) * pixelCount, 16); + m_sampleWeightSums = StandardAllocator::Global()->allocate (pixelCount); + + for (int i = 0; i < pixelCount; i++) { + m_buffer[i] = math::constants::Zero; + m_sampleWeightSums[i] = (math::real)0.0; + } assert(m_buffer != nullptr); } void manta::ImagePlane::destroy() { assert(m_buffer != nullptr); + assert(m_sampleWeightSums != nullptr); _aligned_free(m_buffer); + StandardAllocator::Global()->free(m_sampleWeightSums); // Reset member variables m_buffer = nullptr; + m_sampleWeightSums = nullptr; m_width = 0; - m_height = 0; + m_height = 0; } bool manta::ImagePlane::checkPixel(int x, int y) const { @@ -60,7 +74,7 @@ manta::math::Vector manta::ImagePlane::sample(int x, int y) const { } void manta::ImagePlane::copyFrom(const ImagePlane *source) { - initialize(m_width, m_height, m_physicalWidth, m_physicalHeight); + initialize(m_width, m_height); for (int x = 0; x < (m_width); x++) { for (int y = 0; y < (m_height); y++) { set(sample(x, y), x, y); @@ -69,7 +83,7 @@ void manta::ImagePlane::copyFrom(const ImagePlane *source) { } void manta::ImagePlane::createEmptyFrom(const ImagePlane *source) { - initialize(source->m_width, source->m_height, source->m_physicalWidth, source->m_physicalHeight); + initialize(source->m_width, source->m_height); } void manta::ImagePlane::clear(const math::Vector &v) { @@ -80,77 +94,85 @@ void manta::ImagePlane::clear(const math::Vector &v) { } } -manta::math::real manta::ImagePlane::getMax() const { - math::real maxIntensity = (math::real)0.0; - for (int x = 0; x < m_width; x++) { - for (int y = 0; y < m_height; y++) { - math::real intensity = math::getScalar(math::magnitudeSquared3(sample(x, y))); - if (intensity > maxIntensity) { - maxIntensity = intensity; +#define FAST_ABS(x) (((x) > 0) ? (x) : -(x)) + +void manta::ImagePlane::processSamples(ImageSample *samples, int sampleCount, StackAllocator *stack) { + struct Block { + math::Vector value; + math::real weight; + int x, y; + }; + + Block *blocks = (Block *)stack->allocate(sizeof(Block), 16); + Block *currentBlock = blocks; + int blockCount = 0; + + for (int i = 0; i < sampleCount; i++) { + const ImageSample &sample = samples[i]; + math::Vector2 extents = m_filter->getExtents(); + int left = (int)(floor(sample.imagePlaneLocation.x - extents.x)); + int right = (int)(ceil(sample.imagePlaneLocation.x + extents.x) + (math::real)0.5); + int top = (int)(floor(sample.imagePlaneLocation.y - extents.y)); + int bottom = (int)(ceil(sample.imagePlaneLocation.y + extents.y) + (math::real)0.5); + + for (int x = left; x <= right; x++) { + for (int y = top; y <= bottom; y++) { + bool inBounds = checkPixel(x, y); + if (!inBounds) continue; + + math::Vector2 p( + sample.imagePlaneLocation.x - (math::real)x, + sample.imagePlaneLocation.y - (math::real)y + ); + + if (FAST_ABS(p.x) > extents.x || FAST_ABS(p.y) > extents.y) continue; + + math::Vector weight = m_filter->evaluate(p); + currentBlock->value = math::mul(weight, sample.intensity); + currentBlock->weight = math::getScalar(weight); + currentBlock->x = x; + currentBlock->y = y; + currentBlock++; + blockCount++; } } } - return sqrt(maxIntensity); -} + std::unique_lock lock(m_lock); + for (int i = 0; i < blockCount; i++) { + const Block &block = blocks[i]; + + math::Vector &value = m_buffer[block.y * m_width + block.x]; + math::real &weightSum = m_sampleWeightSums[block.y * m_width + block.x]; -manta::math::real manta::ImagePlane::getMin() const { - math::real minIntensity = math::constants::REAL_MAX; - for (int x = 0; x < (m_width); x++) { - for (int y = 0; y < (m_height); y++) { - math::real intensity = math::getScalar(math::magnitudeSquared3(sample(x, y))); - if (intensity < minIntensity) { - minIntensity = intensity; - } - } - } - - return sqrt(minIntensity); -} - -manta::math::Vector manta::ImagePlane::getAverage() const { - math::Vector average = math::constants::Zero; - int n = 0; - for (int x = 0; x < (m_width); x++) { - for (int y = 0; y < (m_height); y++) { - average = math::add(average, math::div(math::sub(sample(x, y), average), math::loadScalar((math::real)n))); - } + value = math::add(value, block.value); + weightSum += block.weight; } - return average; + stack->free(blocks); } -void manta::ImagePlane::applyGammaCurve(math::real gamma) { +void manta::ImagePlane::normalize() { for (int x = 0; x < m_width; x++) { for (int y = 0; y < m_height; y++) { - math::Vector fragment = sample(x, y); - math::real r = pow(math::getX(fragment), gamma); - math::real g = pow(math::getY(fragment), gamma); - math::real b = pow(math::getZ(fragment), gamma); - set(math::loadVector(r, g, b), x, y); - } - } -} + math::Vector &value = m_buffer[y * m_width + x]; + math::real weightSum = m_sampleWeightSums[y * m_width + x]; -void manta::ImagePlane::add(const ImagePlane *b) { - for (int x = 0; x < m_width; x++) { - for (int y = 0; y < m_height; y++) { - math::Vector fragment = sample(x, y); - math::Vector fragmentB = b->sample(x, y); - fragment = math::add(fragment, fragmentB); - set(fragment, x, y); - } - } -} + value = math::div(value, math::loadScalar(weightSum)); -void manta::ImagePlane::scale(math::real scale) { - math::Vector scalev = math::loadScalar(scale); + constexpr math::Vector DEBUG_RED = { (math::real)1.0, (math::real)0.0, (math::real)0.0 }; + constexpr math::Vector DEBUG_BLUE = { (math::real)0.0, (math::real)0.0, (math::real)1.0 }; + constexpr math::Vector DEBUG_GREEN = { (math::real)0.0, (math::real)1.0, (math::real)0.0 }; - for (int x = 0; x < m_width; x++) { - for (int y = 0; y < m_height; y++) { - math::Vector fragment = sample(x, y); - fragment = math::mul(fragment, scalev); - set(fragment, x, y); + if (std::isnan(math::getX(value)) || std::isnan(math::getY(value)) || std::isnan(math::getZ(value))) { + value = DEBUG_RED; + } + else if (std::isinf(math::getX(value)) || std::isinf(math::getY(value)) || std::isinf(math::getZ(value))) { + value = DEBUG_GREEN; + } + else if (math::getX(value) < 0 || math::getY(value) < 0 || math::getZ(value) < 0) { + value = DEBUG_BLUE; + } } } } diff --git a/src/language_rules.cpp b/src/language_rules.cpp index d7a0cd72..bc417d49 100644 --- a/src/language_rules.cpp +++ b/src/language_rules.cpp @@ -45,6 +45,9 @@ #include "../include/opaque_media_interface.h" #include "../include/dielectric_media_interface.h" #include "../include/microfacet_glass_bsdf.h" +#include "../include/triangle_filter.h" +#include "../include/box_filter.h" +#include "../include/gaussian_filter.h" manta::LanguageRules::LanguageRules() { /* void */ @@ -100,6 +103,8 @@ void manta::LanguageRules::registerBuiltinNodeTypes() { "__mantaray__lens", &ObjectChannel::LensChannel); registerBuiltinType ( "__mantaray__media_interface", &ObjectChannel::MediaInterfaceChannel); + registerBuiltinType ( + "__mantaray__filter", &ObjectChannel::FilterChannel); // Constructors registerBuiltinType( @@ -168,6 +173,12 @@ void manta::LanguageRules::registerBuiltinNodeTypes() { "__mantaray__dielectric_media_interface"); registerBuiltinType ( "__mantaray__glass_bsdf"); + registerBuiltinType ( + "__mantaray__triangle_filter"); + registerBuiltinType ( + "__mantaray__box_filter"); + registerBuiltinType ( + "__mantaray__gaussian_filter"); // Actions registerBuiltinType ( @@ -211,6 +222,9 @@ void manta::LanguageRules::registerBuiltinNodeTypes() { registerBuiltinType( "__mantaray__vector_absolute"); + registerBuiltinType( + "__mantaray__uv_wrap"); + // Binary operations registerBuiltinType( "__mantaray__vector_add"); diff --git a/src/lens_camera_ray_emitter.cpp b/src/lens_camera_ray_emitter.cpp index 535c82f8..1c099df3 100644 --- a/src/lens_camera_ray_emitter.cpp +++ b/src/lens_camera_ray_emitter.cpp @@ -15,6 +15,10 @@ manta::LensCameraRayEmitter::~LensCameraRayEmitter() { } void manta::LensCameraRayEmitter::generateRays(RayContainer *rayContainer) const { + Lens::LensScanHint hint; + m_lens->lensScan(m_imagePlaneOrigin, 4, m_pixelIncrement.x, &hint); + if (hint.failed) return; + int totalRayCount = m_sampler->getTotalSampleCount(m_sampleCount); // Create all rays @@ -22,20 +26,26 @@ void manta::LensCameraRayEmitter::generateRays(RayContainer *rayContainer) const rayContainer->setDegree(0); LightRay *rays = rayContainer->getRays(); - math::Vector *sampleOrigins = - (math::Vector *)m_stackAllocator->allocate(sizeof(math::Vector) * totalRayCount, 16); + math::Vector2 *sampleOrigins = + (math::Vector2 *)m_stackAllocator->allocate(sizeof(math::Vector2) * totalRayCount, 1); m_sampler->generateSamples(totalRayCount, sampleOrigins); - Lens::LensScanHint hint; - m_lens->lensScan(m_position, 4, m_sampler->getBoundaryWidth(), &hint); - for (int i = 0; i < totalRayCount; i++) { - math::Vector position = math::add(m_position, sampleOrigins[i]); + LightRay &ray = rays[i]; + + const math::Vector2 samplePoint = sampleOrigins[i]; + math::Vector position = transformToImagePlane( + math::Vector2(samplePoint.x - (math::real)0.5, samplePoint.y - (math::real)0.5)); - rays[i].setIntensity(math::constants::Zero); - rays[i].setWeight(math::constants::One); + ray.setIntensity(math::constants::Zero); + ray.setWeight(math::constants::One); bool result = m_lens->generateOutgoingRay(position, &hint, &rays[i]); + + ray.setImagePlaneLocation( + math::Vector2( + -(samplePoint.x - (math::real)0.5) + (math::real)m_pixelX, + (samplePoint.y - (math::real)0.5) + (math::real)m_pixelY)); } m_stackAllocator->free((void *)sampleOrigins); diff --git a/src/lens_camera_ray_emitter_group.cpp b/src/lens_camera_ray_emitter_group.cpp index 279cc82e..3bd3fe26 100644 --- a/src/lens_camera_ray_emitter_group.cpp +++ b/src/lens_camera_ray_emitter_group.cpp @@ -18,24 +18,31 @@ void manta::LensCameraRayEmitterGroup::configure() { int nRays = resolutionX * resolutionY; - math::real sensorElementWidth = m_lens->getSensorWidth() / getResolutionX(); - math::real sensorElementHeight = m_lens->getSensorHeight() / getResolutionY(); - - m_sampler->setBoundaryWidth(sensorElementWidth); - m_sampler->setBoundaryHeight(sensorElementHeight); - m_sampler->setAxis1(m_lens->getSensorRight()); - m_sampler->setAxis2(m_lens->getSensorUp()); + m_xIncrement = m_lens->getSensorWidth() / getResolutionX(); + m_yIncrement = m_lens->getSensorHeight() / getResolutionY(); } -manta::CameraRayEmitter *manta::LensCameraRayEmitterGroup::createEmitter(int ix, int iy, - StackAllocator *stackAllocator) const { +manta::CameraRayEmitter *manta::LensCameraRayEmitterGroup:: + createEmitter(int ix, int iy, StackAllocator *stackAllocator) const +{ LensCameraRayEmitter *newEmitter = allocateEmitter(stackAllocator); - math::Vector sensorElement = m_lens->getSensorElement(ix, iy); + math::real x = (ix + (math::real)0.5) * m_xIncrement; + math::real y = (iy + (math::real)0.5) * m_yIncrement; + + math::Vector loc = math::mul(m_lens->getSensorRight(), math::loadScalar(- x + m_lens->getSensorWidth() / (math::real)2.0)); + loc = math::add(loc, math::mul(m_lens->getUp(), math::loadScalar(y - (math::real)m_lens->getSensorHeight() / (math::real)2.0))); + loc = math::add(loc, m_lens->getSensorLocation()); + newEmitter->setSampleCount(m_samples); - newEmitter->setPosition(sensorElement); + newEmitter->setPosition(m_position); + newEmitter->setImagePlaneOrigin(loc); newEmitter->setSampler(m_sampler); newEmitter->setLens(m_lens); + newEmitter->setRight(m_lens->getSensorRight()); + newEmitter->setUp(m_lens->getSensorUp()); + newEmitter->setPixelIncrement(math::Vector2(m_xIncrement, m_yIncrement)); + newEmitter->setImagePlaneCoordinates(ix, iy); return (CameraRayEmitter *)newEmitter; } @@ -46,7 +53,7 @@ void manta::LensCameraRayEmitterGroup::_initialize() { void manta::LensCameraRayEmitterGroup::_evaluate() { Lens *lens = getObject(m_lensInput); - m_sampler = getObject(m_samplerInput); + m_sampler = getObject(m_samplerInput); piranha::native_int samples; m_sampleInput->fullCompute((void *)&samples); diff --git a/src/multiply_node.cpp b/src/multiply_node.cpp deleted file mode 100644 index b15f590d..00000000 --- a/src/multiply_node.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "../include/multiply_node.h" - -manta::MultiplyNode::MultiplyNode() { - /* void */ -} - -manta::MultiplyNode::~MultiplyNode() { - /* void */ -} - -void manta::MultiplyNode::_initialize() { - /* void */ -} - -void manta::MultiplyNode::registerInputs() { - registerInput(m_output.getInputAConnection(), "__left"); - registerInput(m_output.getInputBConnection(), "__right"); -} - -void manta::MultiplyNode::registerOutputs() { - registerOutput(&m_output, "__out"); -} diff --git a/src/multiply_node_output.cpp b/src/multiply_node_output.cpp deleted file mode 100644 index 4ac9efa2..00000000 --- a/src/multiply_node_output.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "../include/multiply_node_output.h" - -#include - -void manta::MultiplyNodeOutput::sample(const IntersectionPoint *surfaceInteraction, void *_target) const { - math::Vector *target = reinterpret_cast(_target); - math::Vector a, b; - a = m_defaultA; - b = m_defaultB; - - VectorNodeOutput *inputA = static_cast(m_inputA); - VectorNodeOutput *inputB = static_cast(m_inputB); - - if (inputA != nullptr) { - inputA->sample(surfaceInteraction, (void *)&a); - } - if (inputB != nullptr) { - inputB->sample(surfaceInteraction, (void *)&b); - } - - *target = math::mul(a, b); -} - -void manta::MultiplyNodeOutput::discreteSample2D(int x, int y, void *_target) const { - math::Vector *target = reinterpret_cast(_target); - math::Vector a, b; - a = m_defaultA; - b = m_defaultB; - - VectorNodeOutput *inputA = static_cast(m_inputA); - VectorNodeOutput *inputB = static_cast(m_inputB); - - if (inputA != nullptr) { - inputA->discreteSample2d(x, y, (void *)&a); - } - if (inputB != nullptr) { - inputB->discreteSample2d(x, y, (void *)&b); - } - - *target = math::mul(a, b); -} - -void manta::MultiplyNodeOutput::getDataReference(const void **_target) const { - *_target = nullptr; -} - -void manta::MultiplyNodeOutput::_evaluateDimensions() { - if (m_inputA == nullptr && m_inputB == nullptr) { - setDimensions(1); - setDimensionSize(0, 1); - return; - } - - VectorNodeOutput *inputA = static_cast(m_inputA); - VectorNodeOutput *inputB = static_cast(m_inputB); - - if (m_inputA != nullptr) assert(inputA->areDimensionsEvaluated()); - if (m_inputB != nullptr) assert(inputB->areDimensionsEvaluated()); - - int dimensions = 0; - if (m_inputA != nullptr && inputA->getDimensions() > dimensions) dimensions = inputA->getDimensions(); - if (m_inputB != nullptr && inputB->getDimensions() > dimensions) dimensions = inputB->getDimensions(); - - setDimensions(dimensions); - - for (int i = 0; i < dimensions; i++) { - int size = 0; - if (m_inputA != nullptr && inputA->getSize(i) > size) size = inputA->getSize(i); - if (m_inputB != nullptr && inputB->getSize(i) > size) size = inputB->getSize(i); - - setDimensionSize(i, size); - } -} diff --git a/src/object_channel_types.cpp b/src/object_channel_types.cpp index 4a71880f..8bb0ce54 100644 --- a/src/object_channel_types.cpp +++ b/src/object_channel_types.cpp @@ -14,3 +14,4 @@ const piranha::ChannelType manta::ObjectChannel::CameraChannel("CameraChannel"); const piranha::ChannelType manta::ObjectChannel::ApertureChannel("ApertureChannel"); const piranha::ChannelType manta::ObjectChannel::LensChannel("LensChannel"); const piranha::ChannelType manta::ObjectChannel::MediaInterfaceChannel("MediaInterfaceChannel"); +const piranha::ChannelType manta::ObjectChannel::FilterChannel("FilterChannel"); diff --git a/src/power_node.cpp b/src/power_node.cpp deleted file mode 100644 index 462e0037..00000000 --- a/src/power_node.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "../include/power_node.h" - -#include - -manta::PowerNode::PowerNode() { - m_power = (math::real)1.0; - m_inputNode = nullptr; - m_powerNode = nullptr; - - m_output.setDefaultPower(m_power); - m_output.setInput(m_inputNode); - m_output.setPowerNode(m_powerNode); -} - -manta::PowerNode::PowerNode(math::real power, VectorNodeOutput *input) { - m_power = power; - m_inputNode = input; - m_powerNode = nullptr; - - m_output.setDefaultPower(m_power); - m_output.setInput(m_inputNode); - m_output.setPowerNode(m_powerNode); -} - -manta::PowerNode::~PowerNode() { - /* void */ -} - -void manta::PowerNode::_initialize() { - m_output.setDefaultPower(m_power); - m_output.setInput(m_inputNode); - m_output.setPowerNode(m_powerNode); -} - -void manta::PowerNode::registerInputs() { - registerInput((piranha::pNodeInput *)&m_inputNode, "Input"); - registerInput((piranha::pNodeInput *)&m_powerNode, "Power"); -} - -void manta::PowerNode::registerOutputs() { - registerOutput(&m_output, "Output"); -} diff --git a/src/power_node_output.cpp b/src/power_node_output.cpp deleted file mode 100644 index 193dc082..00000000 --- a/src/power_node_output.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "../include/power_node_output.h" - -void manta::PowerNodeOutput::sample(const IntersectionPoint *surfaceInteraction, void *_target) const { - VectorNodeOutput *input = static_cast(m_input); - VectorNodeOutput *powerInput = static_cast(m_powerNode); - - math::Vector base = math::constants::Zero; - math::real power; - if (input != nullptr) { - input->sample(surfaceInteraction, (void *)&base); - } - - if (powerInput != nullptr) { - math::Vector s; - powerInput->sample(surfaceInteraction, (void *)&s); - power = math::getScalar(s); - } - else { - power = m_defaultPower; - } - - math::real x_pow = ::pow(math::getX(base), power); - math::real y_pow = ::pow(math::getY(base), power); - math::real z_pow = ::pow(math::getZ(base), power); - - math::Vector *target = (math::Vector *)_target; - *target = math::loadVector(x_pow, y_pow, z_pow); -} - -void manta::PowerNodeOutput::discreteSample2D(int x, int y, void *_target) const { - VectorNodeOutput *input = static_cast(m_input); - VectorNodeOutput *powerInput = static_cast(m_powerNode); - - math::Vector base = math::constants::Zero; - math::real power; - if (input != nullptr) { - input->discreteSample2d(x, y, (void *)&base); - } - - if (powerInput != nullptr) { - math::Vector s; - powerInput->discreteSample2d(x, y, (void *)&s); - power = math::getScalar(s); - } - else { - power = m_defaultPower; - } - - math::real x_pow = ::pow(math::getX(base), power); - math::real y_pow = ::pow(math::getY(base), power); - math::real z_pow = ::pow(math::getZ(base), power); - - math::Vector *target = (math::Vector *)_target; - *target = math::loadVector(x_pow, y_pow, z_pow); -} - -void manta::PowerNodeOutput::fullOutput(const void **target) const { - /* void */ -} diff --git a/src/random_sampler.cpp b/src/random_sampler.cpp index 3dfb2255..94ebf6cf 100644 --- a/src/random_sampler.cpp +++ b/src/random_sampler.cpp @@ -8,19 +8,12 @@ manta::RandomSampler::~RandomSampler() { /* void */ } -void manta::RandomSampler::generateSamples(int sampleCount, math::Vector *target) const { +void manta::RandomSampler::generateSamples(int sampleCount, math::Vector2 *target) const { for (int s = 0; s < sampleCount; s++) { math::real r1 = math::uniformRandom(); math::real r2 = math::uniformRandom(); - math::real x = (r1 - (math::real)0.5) * m_boundaryWidth; - math::real y = (r2 - (math::real)0.5) * m_boundaryHeight; - - math::Vector u = math::mul(m_axis1, math::loadScalar(x)); - math::Vector v = math::mul(m_axis2, math::loadScalar(y)); - math::Vector rayTarget = math::add(u, v); - - target[s] = rayTarget; + target[s] = math::Vector2(r1, r2); } } diff --git a/src/raw_file.cpp b/src/raw_file.cpp index 9f96b122..42c5f81b 100644 --- a/src/raw_file.cpp +++ b/src/raw_file.cpp @@ -147,7 +147,7 @@ void *manta::RawFile::generateEmptyPixelArray(void *dataHeader, int version, int bool manta::RawFile::readPixelArray(void *dataHeader, void *pixelData, ImagePlane *buffer, int version) const { if (version == 0x1) { DataHeader_v1 *header = (DataHeader_v1 *)dataHeader; - buffer->initialize(header->width, header->height, (math::real)0.0, (math::real)0.0); + buffer->initialize(header->width, header->height); if (header->precision == 4) { FloatPixel_v1 *v = (FloatPixel_v1 *)pixelData; diff --git a/src/ray_tracer.cpp b/src/ray_tracer.cpp index 11cf1271..52880140 100644 --- a/src/ray_tracer.cpp +++ b/src/ray_tracer.cpp @@ -56,7 +56,7 @@ void manta::RayTracer::traceAll(const Scene *scene, CameraRayEmitterGroup *group math::real py = (math::real)1.0; math::real px = ((math::real)(resX) / resY); - target->initialize(resX, resY, px, py); + target->initialize(resX, resY); // Create jobs int emitterCount = group->getResolutionX() * group->getResolutionY(); @@ -95,6 +95,8 @@ void manta::RayTracer::traceAll(const Scene *scene, CameraRayEmitterGroup *group startWorkers(); waitForWorkers(); + target->normalize(); + // Print a single new line to terminate progress display // See RayTracer::incrementRayCompletion std::cout << std::endl; @@ -162,7 +164,7 @@ void manta::RayTracer::tracePixel(int px, int py, const Scene *scene, CameraRayE int resX = group->getResolutionX(); int resY = group->getResolutionY(); - target->initialize(resX, resY, (math::real)0.0, (math::real)0.0); + target->initialize(resX, resY); // Create the singular job for the pixel Job job; @@ -238,6 +240,7 @@ void manta::RayTracer::_evaluate() { bool deterministicSeed; CameraRayEmitterGroup *camera; Scene *scene; + Filter *filter; static_cast(m_multithreadedInput)->fullCompute((void *)&multithreaded); static_cast(m_threadCountInput)->fullCompute((void *)&threadCount); @@ -245,17 +248,16 @@ void manta::RayTracer::_evaluate() { static_cast(m_deterministicSeedInput)->fullCompute((void *)&deterministicSeed); static_cast(m_backgroundColorInput)->sample(nullptr, (void *)&m_backgroundColor); - m_materialManager = - static_cast *>(m_materialLibraryInput)->getReference(); - camera = - static_cast *>(m_cameraInput)->getReference(); - scene = - static_cast *>(m_sceneInput)->getReference(); + m_materialManager = getObject(m_materialLibraryInput); + camera = getObject(m_cameraInput); + scene = getObject(m_sceneInput); + filter = getObject(m_filterInput); configure(200 * MB, 50 * MB, threadCount, renderBlockSize, multithreaded); setDeterministicSeedMode(deterministicSeed); ImagePlane imagePlane; + imagePlane.setFilter(filter); traceAll(scene, camera, &imagePlane); VectorMap2D *vectorMap = new VectorMap2D(); @@ -278,6 +280,7 @@ void manta::RayTracer::registerInputs() { registerInput(&m_materialLibraryInput, "materials"); registerInput(&m_sceneInput, "scene"); registerInput(&m_cameraInput, "camera"); + registerInput(&m_filterInput, "filter"); } void manta::RayTracer::registerOutputs() { diff --git a/src/sample_container.cpp b/src/sample_container.cpp new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/sample_container.cpp @@ -0,0 +1 @@ + diff --git a/src/sampler_2d.cpp b/src/sampler_2d.cpp index 1c368215..3fd29b11 100644 --- a/src/sampler_2d.cpp +++ b/src/sampler_2d.cpp @@ -1,15 +1,9 @@ #include "../include/sampler_2d.h" -manta::Sampler2D::Sampler2D() { - m_axis1 = math::constants::Zero; - m_axis2 = math::constants::Zero; - - m_boundaryWidth = (math::real)0.0; - m_boundaryHeight = (math::real)0.0; - +manta::Sampler2d::Sampler2d() { m_output.setReference(this); } -manta::Sampler2D::~Sampler2D() { +manta::Sampler2d::~Sampler2d() { /* void */ } diff --git a/src/simple_bsdf_material.cpp b/src/simple_bsdf_material.cpp index 549c55c5..e98fe8e5 100644 --- a/src/simple_bsdf_material.cpp +++ b/src/simple_bsdf_material.cpp @@ -7,7 +7,7 @@ #include "../include/bsdf.h" manta::SimpleBSDFMaterial::SimpleBSDFMaterial() { - m_maxDegree = 4; + m_maxDegree = 8; m_emissionNode = nullptr; m_reflectanceNode = nullptr; @@ -52,8 +52,6 @@ void manta::SimpleBSDFMaterial::integrateRay(LightRay *ray, const RayContainer & } ray->setIntensity(totalLight); - //ray->setIntensity(math::mul(math::constants::Half, math::add(intersectionPoint.m_vertexNormal, math::constants::One))); - //ray->setIntensity(emission); } const manta::VectorNodeOutput *manta::SimpleBSDFMaterial::getReflectanceNode() const { diff --git a/src/simple_lens.cpp b/src/simple_lens.cpp index 74a9235c..d7f99315 100644 --- a/src/simple_lens.cpp +++ b/src/simple_lens.cpp @@ -231,6 +231,8 @@ bool manta::SimpleLens::generateOutgoingRay( const math::Vector &sensorElement, const LensScanHint *hint, LightRay *targetRay) const { constexpr int MAX_ATTEMPTS = 100000; + + if (hint->failed) return false; math::real maxR = hint->radius; diff --git a/src/simple_sampler.cpp b/src/simple_sampler.cpp index 90152a34..fd2317d2 100644 --- a/src/simple_sampler.cpp +++ b/src/simple_sampler.cpp @@ -8,9 +8,9 @@ manta::SimpleSampler::~SimpleSampler() { /* void */ } -void manta::SimpleSampler::generateSamples(int sampleCount, math::Vector *target) const { +void manta::SimpleSampler::generateSamples(int sampleCount, math::Vector2 *target) const { for (int i = 0; i < sampleCount; i++) { - target[i] = math::constants::Zero; + target[i] = math::Vector2((math::real)0.5, (math::real)0.5); } } diff --git a/src/standard_camera_ray_emitter.cpp b/src/standard_camera_ray_emitter.cpp index 5918a9a3..3348a1eb 100644 --- a/src/standard_camera_ray_emitter.cpp +++ b/src/standard_camera_ray_emitter.cpp @@ -21,13 +21,16 @@ void manta::StandardCameraRayEmitter::generateRays(RayContainer *rayContainer) c rayContainer->setDegree(0); LightRay *rays = rayContainer->getRays(); - math::Vector *samplePoints = - (math::Vector *)m_stackAllocator->allocate(nRays * sizeof(math::Vector), 16); + math::Vector2 *samplePoints = + (math::Vector2 *)m_stackAllocator->allocate(nRays * sizeof(math::Vector2)); m_sampler->generateSamples(nRays, samplePoints); for (int i = 0; i < nRays; i++) { LightRay *ray = &rays[i]; - math::Vector target = math::add(m_targetOrigin, samplePoints[i]); + const math::Vector2 &samplePoint = samplePoints[i]; + + math::Vector target = transformToImagePlane( + math::Vector2(samplePoint.x - (math::real)0.5, samplePoint.y - (math::real)0.5)); math::Vector dir = math::sub(target, m_position); dir = math::normalize(dir); @@ -35,6 +38,10 @@ void manta::StandardCameraRayEmitter::generateRays(RayContainer *rayContainer) c ray->setSource(m_position); ray->setIntensity(math::constants::Zero); ray->setWeight(math::constants::One); + ray->setImagePlaneLocation( + math::Vector2( + samplePoint.x - (math::real)0.5 + (math::real)m_pixelX, + -(samplePoint.y - (math::real)0.5) + (math::real)m_pixelY)); } m_stackAllocator->free((void *)samplePoints); diff --git a/src/standard_camera_ray_emitter_group.cpp b/src/standard_camera_ray_emitter_group.cpp index 5bf3c44f..d135e7da 100644 --- a/src/standard_camera_ray_emitter_group.cpp +++ b/src/standard_camera_ray_emitter_group.cpp @@ -20,27 +20,32 @@ void manta::StandardCameraRayEmitterGroup::configure() { m_right = math::cross(m_direction, m_up); m_planeCenter = math::add(m_position, math::mul(m_direction, math::loadScalar((math::real)m_planeDistance))); - m_sampler->setAxis1(m_right); - m_sampler->setAxis2(m_up); - m_sampler->setBoundaryHeight(m_yIncrement); - m_sampler->setBoundaryWidth(m_xIncrement); + //m_sampler->setAxis1(m_right); + //m_sampler->setAxis2(m_up); + //m_sampler->setBoundaryHeight(m_yIncrement); + //m_sampler->setBoundaryWidth(m_xIncrement); } -manta::CameraRayEmitter *manta::StandardCameraRayEmitterGroup::createEmitter(int ix, int iy, - StackAllocator *stackAllocator) const { +manta::CameraRayEmitter *manta::StandardCameraRayEmitterGroup:: + createEmitter(int ix, int iy, StackAllocator *stackAllocator) const +{ StandardCameraRayEmitter *newEmitter = allocateEmitter(stackAllocator); - math::real x = ix * m_xIncrement; - math::real y = iy * m_yIncrement; + math::real x = (ix + (math::real)0.5) * m_xIncrement; + math::real y = (iy + (math::real)0.5) * m_yIncrement; math::Vector loc = math::mul(m_right, math::loadScalar(x - m_planeWidth / (math::real)2.0)); - loc = math::sub(loc, math::mul(m_up, math::loadScalar(y - (math::real)m_planeHeight / (math::real)2.0))); + loc = math::add(loc, math::mul(m_up, math::loadScalar(-y + (math::real)m_planeHeight / (math::real)2.0))); loc = math::add(loc, m_planeCenter); newEmitter->setPosition(m_position); - newEmitter->setTargetOrigin(loc); + newEmitter->setImagePlaneOrigin(loc); newEmitter->setSampler(m_sampler); newEmitter->setSampleCount(m_samples); + newEmitter->setRight(m_right); + newEmitter->setUp(m_up); + newEmitter->setPixelIncrement(math::Vector2(m_xIncrement, m_yIncrement)); + newEmitter->setImagePlaneCoordinates(ix, iy); return newEmitter; } diff --git a/src/subtract_node_output.cpp b/src/subtract_node_output.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/triangle_filter.cpp b/src/triangle_filter.cpp new file mode 100644 index 00000000..96544977 --- /dev/null +++ b/src/triangle_filter.cpp @@ -0,0 +1,18 @@ +#include "../include/triangle_filter.h" + +#include + +manta::TriangleFilter::TriangleFilter() { + /* void */ +} + +manta::TriangleFilter::~TriangleFilter() { + /* void */ +} + +manta::math::Vector manta::TriangleFilter::evaluate(const math::Vector2 &p) { + math::real v = std::max((math::real)0.0, m_extents.x - std::abs(p.x)) * + std::max((math::real)0.0, m_extents.y - std::abs(p.y)); + + return math::loadScalar(v); +} diff --git a/src/vector_map_2d_node_output.cpp b/src/vector_map_2d_node_output.cpp index f2b66b0d..f3930061 100644 --- a/src/vector_map_2d_node_output.cpp +++ b/src/vector_map_2d_node_output.cpp @@ -18,14 +18,7 @@ void manta::VectorMap2DNodeOutput::sample(const IntersectionPoint *surfaceIntera math::real u = math::getX(surfaceInteraction->m_textureCoodinates); math::real v = 1 - math::getY(surfaceInteraction->m_textureCoodinates); - // Wrap coordinates - math::real fu = fmodf(u, (math::real)1.0); - math::real fv = fmodf(v, (math::real)1.0); - - if (fu < (math::real)0.0) fu += (math::real)1.0; - if (fv < (math::real)0.0) fv += (math::real)1.0; - - *target = m_map->triangleSample(fu, fv); + *target = m_map->triangleSample(u, v); } void manta::VectorMap2DNodeOutput::discreteSample2d(int x, int y, void *_target) const { diff --git a/src/worker.cpp b/src/worker.cpp index a5aa39c6..93404d09 100644 --- a/src/worker.cpp +++ b/src/worker.cpp @@ -92,6 +92,11 @@ void manta::Worker::work() { } void manta::Worker::doJob(const Job *job) { + constexpr int SAMPLE_BUFFER_CAPACITY = 0x1 << 7; + + int sampleCount = 0; + ImageSample *samples = (ImageSample *)m_stack->allocate(sizeof(ImageSample) * SAMPLE_BUFFER_CAPACITY, 16); + for (int x = job->startX; x <= job->endX; x++) { for (int y = job->startY; y <= job->endY; y++) { CameraRayEmitter *emitter = job->group->createEmitter(x, y, m_stack); @@ -126,35 +131,33 @@ void manta::Worker::doJob(const Job *job) { ray->calculateTransformations(); m_rayTracer->traceRay(job->scene, ray, 0, m_stack /**/ PATH_RECORDER_ARG /**/ STATISTICS_ROOT(&m_statistics)); + + ImageSample &sample = samples[sampleCount++]; + sample.imagePlaneLocation = ray->getImagePlaneLocation(); + sample.intensity = ray->getWeightedIntensity(); + + if (sampleCount >= SAMPLE_BUFFER_CAPACITY) { + job->target->processSamples(samples, sampleCount, m_stack); + sampleCount = 0; + } + END_TREE(); } - container.calculateIntensity(); - result = container.getIntensity(); - container.destroyRays(); + container.destroyRays(); } m_rayTracer->incrementRayCompletion(job); job->group->freeEmitter(emitter, m_stack); - - // Add the results to the scene buffer target - constexpr math::Vector DEBUG_RED = { (math::real)1.0, (math::real)0.0, (math::real)0.0 }; - constexpr math::Vector DEBUG_BLUE = { (math::real)0.0, (math::real)0.0, (math::real)1.0 }; - constexpr math::Vector DEBUG_GREEN = { (math::real)0.0, (math::real)1.0, (math::real)0.0 }; - - if (std::isnan(math::getX(result)) || std::isnan(math::getY(result)) || std::isnan(math::getZ(result))) { - result = DEBUG_RED; - } - else if (std::isinf(math::getX(result)) || std::isinf(math::getY(result)) || std::isinf(math::getZ(result))) { - result = DEBUG_GREEN; - } - else if (math::getX(result) < 0 || math::getY(result) < 0 || math::getZ(result) < 0) { - result = DEBUG_BLUE; - } - - job->target->set(result, x, y); } } + + if (sampleCount > 0) { + job->target->processSamples(samples, sampleCount, m_stack); + sampleCount = 0; + } + + m_stack->free((void *)samples); } std::string manta::Worker::getObjFname() { diff --git a/test/image_plane_tests.cpp b/test/image_plane_tests.cpp new file mode 100644 index 00000000..87620723 --- /dev/null +++ b/test/image_plane_tests.cpp @@ -0,0 +1,27 @@ +#include + +#include "utilities.h" + +#include "../include/image_plane.h" + +using namespace manta; + +TEST(ImagePlaneTests, ImagePlaneSanityCheck) { + ImagePlane imagePlane; + imagePlane.initialize(2, 2); + + ImageSample samples[4]; + samples[0].imagePlaneLocation = math::Vector2(0.0f, 0.0f); + samples[0].intensity = math::loadScalar(0.5f); + samples[1].imagePlaneLocation = math::Vector2(1.0f, 0.0f); + samples[1].intensity = math::loadScalar(0.5f); + samples[2].imagePlaneLocation = math::Vector2(0.0f, 1.0f); + samples[2].intensity = math::loadScalar(0.5f); + samples[3].imagePlaneLocation = math::Vector2(1.0f, 1.0f); + samples[3].intensity = math::loadScalar(0.5f); + + imagePlane.processSamples(samples, 4, nullptr); + imagePlane.normalize(); + + imagePlane.destroy(); +} diff --git a/test/node_tests.cpp b/test/node_tests.cpp index 957ef944..279e6725 100644 --- a/test/node_tests.cpp +++ b/test/node_tests.cpp @@ -2,7 +2,7 @@ #include "utilities.h" -#include "../include/multiply_node.h" +#include "../include/binary_node.h" #include "../include/vector_map_wrapper_node.h" #include "../include/step_node.h" @@ -10,58 +10,6 @@ using namespace manta; -TEST(NodeTests, MultiplyNodeTest) { - MultiplyNode node; - node.initialize(); - - node.getMainOutput()->setDefaultA(math::constants::One); - node.getMainOutput()->setDefaultB(math::constants::Double); - - node.evaluate(); - - // Check state - const VectorNodeOutput *o = static_cast(node.getOutput("Output")); - EXPECT_EQ(o->getDimensions(), 1); - EXPECT_EQ(o->getSize(0), 1); - - math::Vector result; - o->discreteSample2d(0, 0, (void *)&result); - CHECK_VEC_EQ(result, math::constants::Double, 1E-4); - - node.destroy(); -} - -TEST(NodeTests, MultiplyMapNodeTest) { - VectorMap2D map; - map.initialize(16, 16, math::constants::One); - VectorMapWrapperNode wrapper(&map); - wrapper.initialize(); - - MultiplyNode node; - node.initialize(); - - node.connectInput(wrapper.getOutput("Output"), "A", nullptr); - node.getMainOutput()->setDefaultB(math::constants::Double); - - node.evaluate(); - - // Check state - const VectorNodeOutput *o = static_cast(node.getOutput("Output")); - EXPECT_EQ(o->getDimensions(), 2); - EXPECT_EQ(o->getSize(0), 16); - EXPECT_EQ(o->getSize(1), 16); - - math::Vector result; - o->discreteSample2d(0, 0, (void *)&result); - CHECK_VEC_EQ(result, math::constants::Double, 1E-4); - - node.destroy(); - wrapper.destroy(); - - map.destroy(); -} - - TEST(NodeTests, StepNode) { VectorMap2D map; map.initialize(16, 16, math::constants::One); diff --git a/utilities/src/main.cpp b/utilities/src/main.cpp index 946687ea..b8d2dc75 100644 --- a/utilities/src/main.cpp +++ b/utilities/src/main.cpp @@ -24,8 +24,6 @@ int main() { std::cout << "Width: " << sceneBuffer.getWidth() << std::endl; std::cout << "Height: " << sceneBuffer.getHeight() << std::endl; - std::cout << "Max: " << sceneBuffer.getMax() << std::endl; - std::cout << "Min: " << sceneBuffer.getMin() << std::endl; // Remove the file extension for (int i = (int)fname.length(); i >= 0; i--) { @@ -55,7 +53,8 @@ int main() { std::cout << "Scale factor: "; std::cin >> scale; - temp.scale(scale); + // Deprecated + //temp.scale(scale); write = true; } @@ -77,7 +76,8 @@ int main() { std::cout << " Div: "; std::cin >> gamma_div; - temp.applyGammaCurve(gamma_num / gamma_div); + // Deprecated + //temp.applyGammaCurve(gamma_num / gamma_div); write = true; }