Convert noise_math.h into C++20 module
This commit is contained in:
parent
9a7969b63a
commit
39950b4677
3 changed files with 32 additions and 23 deletions
|
@ -1,20 +1,19 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
||||||
project(perlin-shadows)
|
project(perlin-shadows)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
include_directories(src)
|
|
||||||
|
|
||||||
link_libraries(-lGL -lglut -lGLEW -lGLU)
|
link_libraries(-lGL -lglut -lGLEW -lGLU)
|
||||||
|
|
||||||
add_executable(perlin-shadows
|
add_executable(${CMAKE_PROJECT_NAME})
|
||||||
|
target_sources(${CMAKE_PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
src/constants.h
|
src/constants.h
|
||||||
src/final.cpp
|
src/final.cpp
|
||||||
src/geography.cpp
|
src/geography.cpp
|
||||||
src/geography.h
|
src/geography.h
|
||||||
src/grid.cpp
|
src/grid.cpp
|
||||||
src/grid.h
|
src/grid.h
|
||||||
src/noise_math.h
|
|
||||||
src/renderer.cpp
|
src/renderer.cpp
|
||||||
src/renderer.h
|
src/renderer.h
|
||||||
src/camera.cpp
|
src/camera.cpp
|
||||||
|
@ -25,6 +24,9 @@ add_executable(perlin-shadows
|
||||||
src/point_light.h
|
src/point_light.h
|
||||||
src/renderable.cpp
|
src/renderable.cpp
|
||||||
src/renderable.h
|
src/renderable.h
|
||||||
|
PRIVATE
|
||||||
|
FILE_SET modules TYPE CXX_MODULES FILES
|
||||||
|
src/noise.cppm
|
||||||
)
|
)
|
||||||
|
|
||||||
file(READ src/shader/phong.vert PHONG_VERT)
|
file(READ src/shader/phong.vert PHONG_VERT)
|
||||||
|
@ -36,4 +38,5 @@ file(READ src/shader/shadow.frag SHADOW_FRAG)
|
||||||
file(READ src/shader/shadow.geom SHADOW_GEOM)
|
file(READ src/shader/shadow.geom SHADOW_GEOM)
|
||||||
configure_file(src/point_light.in.h src/point_light.h @ONLY)
|
configure_file(src/point_light.in.h src/point_light.h @ONLY)
|
||||||
|
|
||||||
|
include_directories(src)
|
||||||
target_include_directories(perlin-shadows PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/src")
|
target_include_directories(perlin-shadows PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "noise_math.h"
|
|
||||||
|
import noise;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace noise;
|
||||||
|
|
||||||
random_device Grid::device_;
|
random_device Grid::device_;
|
||||||
default_random_engine::result_type Grid::base_random_{0};
|
default_random_engine::result_type Grid::base_random_{0};
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
export module noise;
|
||||||
|
|
||||||
|
export namespace noise {
|
||||||
|
|
||||||
// Based on Ken Perlin's smoother step function:
|
// Based on Ken Perlin's smoother step function:
|
||||||
// https://en.wikipedia.org/wiki/Smoothstep#Variations Returns value in range
|
// https://en.wikipedia.org/wiki/Smoothstep#Variations Returns value in range
|
||||||
|
@ -21,3 +23,5 @@
|
||||||
const float bound_1) {
|
const float bound_1) {
|
||||||
return bound_0 + SmootherStep(x) * (bound_1 - bound_0);
|
return bound_0 + SmootherStep(x) * (bound_1 - bound_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace noise
|
Loading…
Add table
Add a link
Reference in a new issue