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

Commit

Permalink
update submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
椎名深雪 committed Dec 3, 2019
1 parent 13a98a7 commit ea92217
Show file tree
Hide file tree
Showing 84 changed files with 248 additions and 2,029 deletions.
26 changes: 5 additions & 21 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
[submodule "external/linalg"]
path = external/linalg
url = https://github.com/shiinamiyuki/linalg
[submodule "external/json"]
path = external/json
url = https://github.com/nlohmann/json
[submodule "external/stb"]
path = external/stb
url = https://github.com/nothings/stb
[submodule "external/tinyobjloader"]
path = external/tinyobjloader
url = https://github.com/syoyo/tinyobjloader
[submodule "external/pybind11"]
path = external/pybind11
url = https://github.com/pybind/pybind11
[submodule "external/cereal"]
path = external/cereal
url = https://github.com/USCiLab/cereal
[submodule "external/fmt"]
path = external/fmt
url = https://github.com/fmtlib/fmt
[submodule "external/lodepng"]
path = external/lodepng
url = https://github.com/lvandeve/lodepng

[submodule "external/cxxopts"]
path = external/cxxopts
url = https://github.com/jarro2783/cxxopts
[submodule "external/glfw"]
path = external/glfw
url = https://github.com/glfw/glfw

[submodule "external/miyuki.foundation"]
path = external/miyuki.foundation
url = https://github.com/shiinamiyuki/miyuki.foundation
34 changes: 11 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ if(MSVC)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target x86_64-pc-windows-gnu -femulated-tls ")
set(CXX_FS_LIBS stdc++fs)
ENDIF()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
Expand All @@ -24,27 +25,18 @@ find_package(Python3 REQUIRED)
find_package(PythonLibs 3 REQUIRED)

include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(src)
add_subdirectory(external/glfw)
include_directories(include)
add_subdirectory(external/gl3w)
add_subdirectory(external/fmt)
add_subdirectory(external/miyuki.foundation)

include_directories(external/sobol)
include_directories(external/pybind11/include)
include_directories(external/linalg)
include_directories(external/cereal/include)
include_directories(external/json/include)
include_directories(external/fmt/include)
include_directories(external/tinyobjloader/)
include_directories(external/stb/)
include_directories(external/lodepng/)
include_directories(external/cxxopts/include)
include_directories(external/gl3w/include)
include_directories(external/glfw/include)
include_directories(external/imgui/)
include_directories(external/glm)

file(GLOB MiyukiAPI src/api/*.h src/api/*.hpp src/api/detail/*.hpp src/api/detail/*.h)
file(GLOB MiyukiAPI include/miyuki.renderer/*.h include/miyuki.renderer/*.hpp include/miyuki.renderer/detail/*.hpp include/miyuki.renderer/detail/*.h)
file(GLOB libcoreSource src/core/*.cpp
src/core/accelerators/*.*
src/core/shaders/*.*
Expand Down Expand Up @@ -80,23 +72,19 @@ IF(USE_EMBREE)
ENDIF()
ENDIF()
add_library(core ${MiyukiAPI} ${libcoreSource})
target_link_libraries(core fmt)
target_link_libraries(core foundation ${CXX_FS_LIBS})
add_executable(myk-cli src/standalone-renderer/main.cpp ${MiyukiAPI})
add_executable(mesh-importer src/mesh-importer/importer.cpp ${MiyukiAPI})
target_link_libraries(mesh-importer core ${EMBREE_LIBRARY})
target_link_libraries(myk-cli core ${EMBREE_LIBRARY})

file(GLOB IMGUI_SRC external/imgui/*.cpp)
file(GLOB IMGUI_SRC external/imgui/*.cpp
external/imgui/examples/imgui_impl_opengl3.cpp
external/imgui/examples/imgui_impl_glfw.cpp)
add_compile_definitions(IMGUI_IMPL_OPENGL_LOADER_GL3W)
include_directories(external/gl3w/include)
add_library(imgui ${IMGUI_SRC}
external/imgui/examples/imgui_impl_opengl3.cpp
external/imgui/examples/imgui_impl_glfw.cpp
)

target_link_libraries(imgui gl3w)

file(GLOB UI_SRC src/ui/*.*)

add_executable(miyuki.studio src/miyuki.studio/main.cpp ${UI_SRC} ${MiyukiAPI})
target_link_libraries(miyuki.studio core ${EMBREE_LIBRARY} imgui glfw)
add_executable(miyuki.studio src/miyuki.studio/main.cpp ${UI_SRC} ${MiyukiAPI} ${IMGUI_SRC})
target_link_libraries(miyuki.studio core ${EMBREE_LIBRARY} glfw gl3w)
1 change: 0 additions & 1 deletion external/cereal
Submodule cereal deleted from 02eace
1 change: 0 additions & 1 deletion external/fmt
Submodule fmt deleted from 088985
1 change: 0 additions & 1 deletion external/glfw
Submodule glfw deleted from 28d850
1 change: 0 additions & 1 deletion external/glm
Submodule glm deleted from 8a3428
1 change: 0 additions & 1 deletion external/json
Submodule json deleted from ea60d4
1 change: 0 additions & 1 deletion external/linalg
Submodule linalg deleted from 52f195
1 change: 0 additions & 1 deletion external/lodepng
Submodule lodepng deleted from 957506
1 change: 1 addition & 0 deletions external/miyuki.foundation
Submodule miyuki.foundation added at 2384ee
1 change: 0 additions & 1 deletion external/stb
Submodule stb deleted from f67165
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef MIYUKIRENDERER_ACCELERATOR_H
#define MIYUKIRENDERER_ACCELERATOR_H

#include <api/shape.h>
#include <miyuki.renderer/shape.h>

namespace miyuki::core {
class Scene;
Expand Down
4 changes: 2 additions & 2 deletions src/api/bsdf.h → include/miyuki.renderer/bsdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#ifndef MIYUKIRENDERER_BSDF_H
#define MIYUKIRENDERER_BSDF_H

#include <api/object.hpp>
#include <api/spectrum.h>
#include <miyuki.foundation/object.hpp>
#include <miyuki.renderer/spectrum.h>


namespace miyuki::core {
Expand Down
4 changes: 2 additions & 2 deletions src/api/camera.h → include/miyuki.renderer/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#ifndef MIYUKIRENDERER_CAMERA_H
#define MIYUKIRENDERER_CAMERA_H

#include <api/object.hpp>
#include <api/ray.h>
#include <miyuki.foundation/object.hpp>
#include <miyuki.renderer/ray.h>

namespace miyuki::core {
struct CameraSample {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fresnel.h → include/miyuki.renderer/fresnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// SOFTWARE.
#pragma once

#include <api/math.hpp>
#include <api/object.hpp>
#include <miyuki.foundation/math.hpp>
#include <miyuki.foundation/object.hpp>

namespace miyuki::core {
class Frensel : public Object {
Expand Down
18 changes: 9 additions & 9 deletions src/api/graph.h → include/miyuki.renderer/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
#ifndef MIYUKIRENDERER_GRAPH_H
#define MIYUKIRENDERER_GRAPH_H

#include <api/bsdf.h>
#include <api/camera.h>
#include <api/object.hpp>
#include <api/integrator.h>
#include <api/property.hpp>
#include <api/sampler.h>
#include <api/scene.h>
#include <api/serialize.hpp>
#include <api/shape.h>
#include <miyuki.renderer/bsdf.h>
#include <miyuki.renderer/camera.h>
#include <miyuki.foundation/object.hpp>
#include <miyuki.renderer/integrator.h>
#include <miyuki.foundation/property.hpp>
#include <miyuki.renderer/sampler.h>
#include <miyuki.renderer/scene.h>
#include <miyuki.foundation/serialize.hpp>
#include <miyuki.renderer/shape.h>
#include <cereal/types/vector.hpp>

namespace miyuki::core {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef MIYUKIRENDERER_INTEGRATOR_H
#define MIYUKIRENDERER_INTEGRATOR_H

#include <api/object.hpp>
#include <miyuki.foundation/object.hpp>

namespace miyuki::core {
class Camera;
Expand Down
6 changes: 3 additions & 3 deletions src/api/light.h → include/miyuki.renderer/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#ifndef MIYUKIRENDERER_LIGHT_H
#define MIYUKIRENDERER_LIGHT_H

#include <api/spectrum.h>
#include <api/ray.h>
#include <api/object.hpp>
#include <miyuki.renderer/spectrum.h>
#include <miyuki.renderer/ray.h>
#include <miyuki.foundation/object.hpp>

namespace miyuki::core {
struct VisibilityTester;
Expand Down
8 changes: 4 additions & 4 deletions src/api/material.h → include/miyuki.renderer/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#ifndef MIYUKIRENDERER_MATERIAL_H
#define MIYUKIRENDERER_MATERIAL_H

#include <api/bsdf.h>
#include <api/shader.h>
#include <api/property.hpp>
#include <api/serialize.hpp>
#include <miyuki.renderer/bsdf.h>
#include <miyuki.renderer/shader.h>
#include <miyuki.foundation/property.hpp>
#include <miyuki.foundation/serialize.hpp>


namespace miyuki::core {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <api/defs.h>
#include <api/material.h>
#include <api/object.hpp>
#include <miyuki.foundation/defs.h>
#include <miyuki.renderer/material.h>
#include <miyuki.foundation/object.hpp>
namespace miyuki ::core {
class Mesh;

Expand Down
47 changes: 23 additions & 24 deletions src/api/mesh.h → include/miyuki.renderer/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#ifndef MIYUKIRENDERER_MESH_H
#define MIYUKIRENDERER_MESH_H

#include <api/accelerator.h>
#include <api/material.h>
#include <api/serialize.hpp>
#include <api/shape.h>
#include <miyuki.renderer/accelerator.h>
#include <miyuki.renderer/material.h>
#include <miyuki.foundation/serialize.hpp>
#include <miyuki.renderer/shape.h>
#include <cereal/types/unordered_map.hpp>

namespace miyuki::core {
Expand Down Expand Up @@ -59,25 +59,25 @@ namespace miyuki::core {
[[nodiscard]] const Vec3f Ng() const {
Vec3f e1 = (vertex(1) - vertex(0));
Vec3f e2 = (vertex(2) - vertex(0));
return e1.cross(e2).normalized();
return normalize(cross(e1, e2));
}

bool intersect(const Ray &ray, Intersection &isct) const {
float u, v;
Vec3f e1 = (vertex(1) - vertex(0));
Vec3f e2 = (vertex(2) - vertex(0));
auto Ng = e1.cross(e2).normalized();
float denom = (ray.d.dot(Ng));
float t = -(ray.o - vertex(0)).dot(Ng) / denom;
auto Ng = normalize(cross(e1, e2));
float denom = dot(ray.d, Ng);
float t = -dot(ray.o - vertex(0), Ng) / denom;
if (denom == 0)
return false;
if (t < ray.tMin)
return false;
Vec3f p = ray.o + t * ray.d;
double det = e1.cross(e2).length();
auto u0 = e1.cross(p - vertex(0));
auto v0 = Vec3f(p - vertex(0)).cross(e2);
if (u0.dot(Ng) < 0 || v0.dot(Ng) < 0)
double det = length(cross(e1, e2));
auto u0 = cross(e1, p - vertex(0));
auto v0 = cross(Vec3f(p - vertex(0)), e2);
if (dot(u0, Ng) < 0 || dot(v0, Ng) < 0)
return false;
v = u0.length() / det;
u = v0.length() / det;
Expand Down Expand Up @@ -109,12 +109,10 @@ namespace miyuki::core {
sample.uv = uv;
sample.pdf = 1 / area();
sample.p = (1 - uv.x - uv.y) * vertex(0) + uv.x * vertex(1) + uv.y * vertex(1);
Vec3f e1 = (vertex(1) - vertex(0));
Vec3f e2 = (vertex(2) - vertex(0));
sample.normal = e1.cross(e2).normalized();
sample.normal = Ng();
}

[[nodiscard]] Float area() const { return Vec3f(vertex(1) - vertex(0)).cross(vertex(2) - vertex(0)).length(); }
[[nodiscard]] Float area() const { return length(cross(Vec3f(vertex(1) - vertex(0)),(vertex(2) - vertex(0)))); }

[[nodiscard]] BSDF *getBSDF() const { return nullptr; }

Expand All @@ -125,19 +123,20 @@ namespace miyuki::core {
}

[[nodiscard]] Normal3f normalAt(const Point2f &uv) const {
return lerp3(normal(0), normal(1), normal(2), uv[0], uv[1]).normalized();
return normalize(lerp3(normal(0), normal(1), normal(2), uv[0], uv[1]));
}

[[nodiscard]] Point2f texCoordAt(const Point2f &uv) const {
return lerp3(texCoord(0), texCoord(1), texCoord(2), uv[0], uv[1]);
}
};

class MeshBase : public Object {};
class MeshBase : public Object {
};

class Mesh final : public MeshBase {
class Mesh final : public MeshBase {

public:
public:
bool _loaded = false;
std::vector<MeshTriangle> triangles;
VertexData _vertex_data;
Expand All @@ -157,7 +156,7 @@ namespace miyuki::core {

void fromBinary(const std::vector<char> &buffer);

void foreach (const std::function<void(MeshTriangle *)> &func);
void foreach(const std::function<void(MeshTriangle *)> &func);

bool loadFromFile(const std::string &filename);

Expand All @@ -168,17 +167,17 @@ namespace miyuki::core {
};

class MeshInstance final : public MeshBase {
public:
public:
MYK_DECL_CLASS(MeshInstance, "MeshInstance", interface = "MeshBase")

Transform transform, invTransform;
std::shared_ptr<Mesh> mesh;

MYK_AUTO_SER(transform, mesh)

void foreach (const std::function<void(MeshTriangle *)> &func) { mesh->foreach (func); }
void foreach(const std::function<void(MeshTriangle *)> &func) { mesh->foreach(func); }

protected:
protected:
void preprocess() override { invTransform = transform.inverse(); }
};

Expand Down
10 changes: 5 additions & 5 deletions src/api/ray.h → include/miyuki.renderer/ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#ifndef MIYUKIRENDERER_RAY_H
#define MIYUKIRENDERER_RAY_H

#include <api/defs.h>
#include <api/math.hpp>
#include <miyuki.foundation/defs.h>
#include <miyuki.foundation/math.hpp>

namespace miyuki::core {
struct Ray {
Expand Down Expand Up @@ -72,12 +72,12 @@ namespace miyuki::core {
}

// w should be normalized
Ray spawnRay(const Vec3f &w) const {
auto t = RayBias / w.absDot(Ng);
[[nodiscard]] Ray spawnRay(const Vec3f &w) const {
auto t = RayBias / abs(dot(w, Ng));
return Ray(p, w, t, MaxFloat);
}

Ray spawnTo(const Point3f &p) const {
[[nodiscard]] Ray spawnTo(const Point3f &p) const {
return Ray(this->p, (p - this->p), RayBias, 1);
}
};
Expand Down
Loading

0 comments on commit ea92217

Please sign in to comment.