Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
1. Fixes for compiling and running on Linux
2. Fixed tiles not rendering correctly when window is resized
3. Fixed issues with instancing
  • Loading branch information
knightcrawler25 committed Jul 28, 2020
1 parent 626ba43 commit 9fa777d
Show file tree
Hide file tree
Showing 154 changed files with 493,111 additions and 37,431 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# Don't track content of these folders

.vs/
bin/*
!bin/assets
#bin/assets/*
#!bin/assets/*.scene
PathTracer/Release/
PathTracer/Debug/
build/*
118 changes: 39 additions & 79 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,44 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


file(GLOB_RECURSE SHADERS
${CMAKE_SOURCE_DIR}/src/shaders/*.glsl
)

file(GLOB_RECURSE SRC_FILES
${CMAKE_SOURCE_DIR}/PathTracer/*.h
${CMAKE_SOURCE_DIR}/PathTracer/*.cpp
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.cpp
)

file(GLOB EXT_FILES
${CMAKE_SOURCE_DIR}/thirdparty/SOIL/src/*.h
${CMAKE_SOURCE_DIR}/thirdparty/SOIL/src/*.c
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays/*.h
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays/*.cpp
${CMAKE_SOURCE_DIR}/thirdparty/stb/*.h
${CMAKE_SOURCE_DIR}/thirdparty/imgui/*.h
${CMAKE_SOURCE_DIR}/thirdparty/imgui/*.cpp
${CMAKE_SOURCE_DIR}/thirdparty/imguizmo/*.h
${CMAKE_SOURCE_DIR}/thirdparty/imguizmo/*.cpp
)

if (NOT EMSCRIPTEN)
file(GLOB EXT_FILES_SPECIFIC
${CMAKE_SOURCE_DIR}/thirdparty/imguizmo/*.cpp
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays/*.h
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays/*.cpp
${CMAKE_SOURCE_DIR}/thirdparty/gl3w/GL/*.c
)
set(SDL2_LIBRARIES "SDL2" "SDL2main")
endif()

set(SRCS ${SRC_FILES} ${EXT_FILES} ${SHADERS})

set(SDL2_LIBRARIES "SDL2" "SDL2main")
set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/thirdparty/SDL2/include)
set(SDL2_LIBDIR ${CMAKE_SOURCE_DIR}/thirdparty/SDL2/lib/x64)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/PathTracer
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/loaders
${CMAKE_SOURCE_DIR}/src/tests
${CMAKE_SOURCE_DIR}/thirdparty/glm
${CMAKE_SOURCE_DIR}/thirdparty/imgui
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays
${CMAKE_SOURCE_DIR}/thirdparty/glew/include
${CMAKE_SOURCE_DIR}/thirdparty/SOIL/include
${CMAKE_SOURCE_DIR}/thirdparty/stb
${CMAKE_SOURCE_DIR}/thirdparty/gl3w
${CMAKE_SOURCE_DIR}/thirdparty/imguizmo
${CMAKE_SOURCE_DIR}/thirdparty/RadeonRays
${CMAKE_SOURCE_DIR}/thirdparty/tinydir
${SDL2_INCLUDE_DIRS}
)

Expand All @@ -53,25 +56,7 @@ link_directories(
)
find_package(OpenGL)


#######################################################################################

#set (USE_MSVC_RUNTIME_LIBRARY_DLL true)
#IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
# #We statically link to reduce dependancies
# FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RETAIL)
# IF(${flag_var} MATCHES "/MD")
# STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
# ENDIF(${flag_var} MATCHES "/MD")
# IF(${flag_var} MATCHES "/MDd")
# STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
# ENDIF(${flag_var} MATCHES "/MDd")
# ENDFOREACH(flag_var)
#ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)

#######################################################################################

foreach(f ${SRC_FILES})
foreach(f ${SRCS})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_SOURCE_DIR} ${f})
Expand All @@ -85,9 +70,7 @@ foreach(f ${SRC_FILES})
source_group("${SRCGR}" FILES ${f})
endforeach()

set(ENABLE_HIDECONSOLE_BUILD TRUE CACHE BOOL "TRUE to hide console for Windows sys")

if(WINDOWS)
if(WIN32)
set(GUI_TYPE WIN32)
elseif(MACOSX)
set(GUI_TYPE MACOSX_BUNDLE)
Expand All @@ -101,9 +84,13 @@ endif()
SET(LINK_OPTIONS " ")
SET(EXE_NAME "PathTracer")

ADD_EXECUTABLE(${EXE_NAME} ${SRC_FILES} ${EXT_FILES} ${EXT_FILES_SPECIFIC})
ADD_EXECUTABLE(${EXE_NAME} ${SRCS})

if(WIN32)
TARGET_LINK_LIBRARIES(${EXE_NAME} ${OPENGL_LIBRARIES} ${SDL2_LIBRARIES})
else()
TARGET_LINK_LIBRARIES(${EXE_NAME} ${OPENGL_LIBRARIES} ${SDL2_LIBRARIES} dl)
endif()

#--------------------------------------------------------------------
# preproc
Expand All @@ -126,53 +113,26 @@ add_definitions(-DGLEW_STATIC)
# output dirs
#--------------------------------------------------------------------

set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin )
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin )
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/bin )
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR} )
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR} )
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_BINARY_DIR} )
set_target_properties(${EXE_NAME} PROPERTIES DEBUG_POSTFIX "_d")
set_target_properties(${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "RelWithDebInfo")
set_target_properties(${EXE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

#--------------------------------------------------------------------
# Hide the console window in visual studio projects
#--------------------------------------------------------------------
if(ENABLE_HIDECONSOLE_BUILD)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
endif()
set_target_properties(${EXE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

if(WINDOWS)
set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
if(WIN32)
set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
endif()

if (EMSCRIPTEN)
add_definitions(-DEMSCRIPTEN)
add_definitions(-D_X86_)
set(EMS_OPTS "-s USE_SDL=2 -s USE_WEBGL2=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_TRAP_MODE=clamp --bind -O2 --no-heap-copy -g4 --source-map-base localhost:8000")
add_definitions(${EMS_OPTS})
set(EMS_PRELOAD " --preload-file assets --preload-file shaders")
set(EMS_LINK "${EMS_OPTS} ${EMS_PRELOAD}")
set_target_properties(${EXE_NAME} PROPERTIES LINK_FLAGS ${EMS_LINK})

add_custom_command(TARGET ${EXE_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/assets ${CMAKE_CURRENT_BINARY_DIR}/assets
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets ${CMAKE_CURRENT_BINARY_DIR}/assets
)
add_custom_command(TARGET ${EXE_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/PathTracer/shaders ${CMAKE_CURRENT_BINARY_DIR}/shaders
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/shaders ${CMAKE_CURRENT_BINARY_DIR}/shaders
)

if(WIN32)
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/PathTracer/index.html ${CMAKE_CURRENT_BINARY_DIR}/index.html
COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_LIBDIR}/SDL2.dll ${CMAKE_CURRENT_BINARY_DIR}
)


endif()

if(ENABLE_HIDECONSOLE_BUILD)
MESSAGE(STATUS "Console is hidden")
else()
MESSAGE(STATUS "Console is visible")
endif()
19 changes: 19 additions & 0 deletions INSTALL-LINUX.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Instructions for building:

* apt-get install libsdl2-dev

* git clone https://github.com/knightcrawler25/GLSL-PathTracer.git

* cd GLSL-PathTracer

* mkdir build

* cmake ..

* make

* cd build

* To run the program: ./PathTracer

* Additional samples can be downloaded from: https://drive.google.com/file/d/1UFMMoVb5uB7WIvCeHOfQ2dCQSxNMXluB/view
13 changes: 6 additions & 7 deletions INSTALL-WIN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ Instructions for building:

* Select the main directory where CMakeLists.txt is as the source file location.

* Select the "bin" directory as the location to build the binaries.
* Select the "build" directory as the location to build the binaries.

* Press "Configure" button and select the version of Visual Studio you wish to
use. Note that the 64-bit compiles are separate from the 32-bit compiles
(e.g. look for "Visual Studio 12 2013 Win64"). Leave all other options on
use. (e.g. look for "Visual Studio xx 20xx Win64"). Leave all other options on
their default. Press "OK".

* Uncheck 'ENABLE_HIDECONSOLE_BUILD' if you wish to see the console logs. Then press "Generate".

* Open the .sln solution file in the "bin" directory.
* Open the .sln solution file in the "build" directory.

* Change to "Release" mode and Press "Build Solution" from the IDE.

* Right click on "PathTracer" program targets in the solution explorer and
select "Set as start up project".

* Run the program.
* Run the program.

* Additional samples can be downloaded from: https://drive.google.com/file/d/1UFMMoVb5uB7WIvCeHOfQ2dCQSxNMXluB/view
7 changes: 6 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
MIT License

Copyright (c) 2019 Asif Ali
Copyright(c) 2019-2020 Asif Ali

Authors/Contributors:

Asif Ali
Cedric Guillemet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 9fa777d

Please sign in to comment.