Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
how should i support embree
Browse files Browse the repository at this point in the history
  • Loading branch information
椎名深雪 committed Nov 3, 2019
1 parent 1dab800 commit 9f9c25c
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/dictionaries/shiinamiyuki.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ file(GLOB libcoreSource src/core/*.cpp
)

IF(USE_EMBREE)
add_compile_definitions(MYK_USE_EMBREE)
IF(EMBREE_FROM_SOUCE)
include(ExternalProject)
include(${PROJECT_SOURCE_DIR}/cmake/cmake-embree)
Expand All @@ -56,7 +57,6 @@ IF(USE_EMBREE)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:/Program Files/Intel/Embree3 x64")
ENDIF()
find_package(embree 3.6 REQUIRED)
#message(${Embree_FOUND})
IF(NOT embree_FOUND)
message(FATAL_ERROR "Embree 3.6 not found")
ENDIF()
Expand Down
70 changes: 70 additions & 0 deletions src/core/accelerators/embree-backend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// MIT License
//
// Copyright (c) 2019 椎名深雪
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "embree-backend.h"
#include <embree3/rtcore.h>
#ifdef MYK_USE_EMBREE

namespace miyuki::core{

void EmbreeAccelerator::build(const Mesh *mesh) {

}

bool EmbreeAccelerator::intersect(const Ray &ray, Intersection &isct) const {
return false;
}

Bounds3f EmbreeAccelerator::getBoundingBox() const {
return miyuki::Bounds3f();
}

void EmbreeTopLevelAccelerator::build(const std::vector<Shape *> &vector) {

}

bool EmbreeTopLevelAccelerator::intersect(const Ray &ray, Intersection &isct) const {
return false;
}

Bounds3f EmbreeTopLevelAccelerator::getBoundingBox() const {
return miyuki::Bounds3f();
}
}
#else
namespace miyuki::core{

void EmbreeAccelerator::build(const Mesh *mesh) {
MIYUKI_NOT_IMPLEMENTED();
}

bool EmbreeAccelerator::intersect(const Ray &ray, Intersection &isct) const {
MIYUKI_NOT_IMPLEMENTED();
return false;
}

Bounds3f EmbreeAccelerator::getBoundingBox() const {
MIYUKI_NOT_IMPLEMENTED();
return miyuki::Bounds3f();
}
}
#endif
51 changes: 51 additions & 0 deletions src/core/accelerators/embree-backend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// MIT License
//
// Copyright (c) 2019 椎名深雪
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#ifndef MIYUKIRENDERER_EMBREE_BACKEND_H
#define MIYUKIRENDERER_EMBREE_BACKEND_H

#include <api/accelerator.h>
#include <api/serialize.hpp>

namespace miyuki::core {
class EmbreeAccelerator final : public Accelerator {
public:
MYK_DECL_CLASS(EmbreeAccelerator, "EmbreeAccelerator", interface = "Accelerator")

void build(const Mesh *mesh) override;

bool intersect(const Ray &ray, Intersection &isct) const override;

Bounds3f getBoundingBox() const override;
};
class EmbreeTopLevelAccelerator final : public TopLevelAccelerator{
public:
MYK_DECL_CLASS(EmbreeTopLevelAccelerator, "EmbreeTopLevelAccelerator", interface = "TopLevelAccelerator")

void build(const std::vector<Shape *> &vector) override;

bool intersect(const Ray &ray, Intersection &isct) const override;

Bounds3f getBoundingBox() const override;
};
}
#endif //MIYUKIRENDERER_EMBREE_BACKEND_H
2 changes: 2 additions & 0 deletions src/core/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "samplers/sobol-sampler.h"
#include <api/graph.h>
#include <api/material.h>
#include "accelerators/embree-backend.h"

namespace miyuki::core {
void Initialize() {
Expand All @@ -46,6 +47,7 @@ namespace miyuki::core {
Register<RTAO>();
Register<RandomSampler>();
Register<SobolSampler>();
Register<EmbreeAccelerator>();
}

void Finalize() {
Expand Down

0 comments on commit 9f9c25c

Please sign in to comment.