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,30 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
||||
project(perlin-shadows)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
include_directories(src)
|
||||
|
||||
link_libraries(-lGL -lglut -lGLEW -lGLU)
|
||||
|
||||
add_executable(perlin-shadows
|
||||
src/constants.h
|
||||
src/final.cpp
|
||||
src/geography.cpp
|
||||
src/geography.h
|
||||
src/grid.cpp
|
||||
src/grid.h
|
||||
src/noise_math.h
|
||||
src/renderer.cpp
|
||||
src/renderer.h
|
||||
src/camera.cpp
|
||||
src/camera.h
|
||||
src/shader.cpp
|
||||
src/shader.h
|
||||
src/point_light.cpp
|
||||
src/point_light.h
|
||||
src/renderable.cpp
|
||||
src/renderable.h
|
||||
add_executable(${CMAKE_PROJECT_NAME})
|
||||
target_sources(${CMAKE_PROJECT_NAME}
|
||||
PRIVATE
|
||||
src/constants.h
|
||||
src/final.cpp
|
||||
src/geography.cpp
|
||||
src/geography.h
|
||||
src/grid.cpp
|
||||
src/grid.h
|
||||
src/renderer.cpp
|
||||
src/renderer.h
|
||||
src/camera.cpp
|
||||
src/camera.h
|
||||
src/shader.cpp
|
||||
src/shader.h
|
||||
src/point_light.cpp
|
||||
src/point_light.h
|
||||
src/renderable.cpp
|
||||
src/renderable.h
|
||||
PRIVATE
|
||||
FILE_SET modules TYPE CXX_MODULES FILES
|
||||
src/noise.cppm
|
||||
)
|
||||
|
||||
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)
|
||||
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")
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <vector>
|
||||
|
||||
#include "constants.h"
|
||||
#include "noise_math.h"
|
||||
|
||||
import noise;
|
||||
|
||||
using namespace std;
|
||||
using namespace noise;
|
||||
|
||||
random_device Grid::device_;
|
||||
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:
|
||||
// https://en.wikipedia.org/wiki/Smoothstep#Variations Returns value in range
|
||||
|
@ -21,3 +23,5 @@
|
|||
const float bound_1) {
|
||||
return bound_0 + SmootherStep(x) * (bound_1 - bound_0);
|
||||
}
|
||||
|
||||
} // namespace noise
|
Loading…
Add table
Add a link
Reference in a new issue