├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── cleanCppExtensions.cmake └── useGoldLinker.cmake ├── conventions.md ├── data ├── .DS_Store ├── CMakeLists.txt ├── nodestyle.txt ├── shaders │ ├── runtime │ │ ├── DefaultLight.glsl │ │ ├── Fragment.glsl │ │ ├── MicrofacetFunction.glsl │ │ ├── PBRCommon.frag.glsl │ │ ├── PBRCommon.vert.glsl │ │ ├── Transform │ │ │ └── TransformStructs.glsl │ │ └── Vertex.glsl │ └── source │ │ ├── DefaultLight.glsl │ │ ├── Fragment.glsl │ │ ├── MaterialModel.glsl │ │ ├── MaterialModelFooter.txt │ │ ├── MaterialModelHeader.txt │ │ ├── MicrofacetFunction.glsl │ │ ├── PBRCommon.frag.glsl │ │ ├── PBRCommon.vert.glsl │ │ ├── Transform │ │ ├── ._TransformStructs.glsl │ │ └── TransformStructs.glsl │ │ └── Vertex.glsl └── textures │ ├── Brick.png │ └── ShaderGraph.png ├── doc ├── .DS_Store ├── .gitignore ├── CMakeLists.txt ├── design.md ├── directoryStructure.md ├── doxygen │ ├── Doxyfile.in │ ├── customdoxygen.css │ ├── footer.html │ └── header.html └── start_working.md ├── external ├── .DS_Store ├── CMakeLists.txt └── nodeeditor │ ├── .appveyor.yml │ ├── .codeclimate.yml │ ├── .gitignore │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── cmake │ └── NodeEditorConfig.cmake.in │ ├── examples │ ├── CMakeLists.txt │ ├── calculator │ │ ├── AdditionModel.hpp │ │ ├── CMakeLists.txt │ │ ├── Converters.cpp │ │ ├── Converters.hpp │ │ ├── DecimalData.hpp │ │ ├── DivisionModel.hpp │ │ ├── IntegerData.hpp │ │ ├── MathOperationDataModel.cpp │ │ ├── MathOperationDataModel.hpp │ │ ├── ModuloModel.cpp │ │ ├── ModuloModel.hpp │ │ ├── MultiplicationModel.hpp │ │ ├── NumberDisplayDataModel.cpp │ │ ├── NumberDisplayDataModel.hpp │ │ ├── NumberSourceDataModel.cpp │ │ ├── NumberSourceDataModel.hpp │ │ ├── SubtractionModel.hpp │ │ └── main.cpp │ ├── connection_colors │ │ ├── CMakeLists.txt │ │ ├── main.cpp │ │ ├── models.cpp │ │ └── models.hpp │ ├── example2 │ │ ├── CMakeLists.txt │ │ ├── TextData.hpp │ │ ├── TextDisplayDataModel.cpp │ │ ├── TextDisplayDataModel.hpp │ │ ├── TextSourceDataModel.cpp │ │ ├── TextSourceDataModel.hpp │ │ └── main.cpp │ ├── images │ │ ├── CMakeLists.txt │ │ ├── ImageLoaderModel.cpp │ │ ├── ImageLoaderModel.hpp │ │ ├── ImageShowModel.cpp │ │ ├── ImageShowModel.hpp │ │ ├── PixmapData.hpp │ │ └── main.cpp │ └── styles │ │ ├── CMakeLists.txt │ │ ├── main.cpp │ │ ├── models.cpp │ │ └── models.hpp │ ├── external │ ├── CMakeLists.txt │ └── Catch2 │ │ └── CMakeLists.txt │ ├── include │ └── nodes │ │ ├── Connection │ │ ├── ConnectionStyle │ │ ├── DataModelRegistry │ │ ├── FlowScene │ │ ├── FlowView │ │ ├── FlowViewStyle │ │ ├── Node │ │ ├── NodeData │ │ ├── NodeDataModel │ │ ├── NodeGeometry │ │ ├── NodePainterDelegate │ │ ├── NodeState │ │ ├── NodeStyle │ │ ├── TypeConverter │ │ └── internal │ │ ├── Compilation.hpp │ │ ├── Connection.hpp │ │ ├── ConnectionGeometry.hpp │ │ ├── ConnectionGraphicsObject.hpp │ │ ├── ConnectionState.hpp │ │ ├── ConnectionStyle.hpp │ │ ├── DataModelRegistry.hpp │ │ ├── Export.hpp │ │ ├── FlowScene.hpp │ │ ├── FlowView.hpp │ │ ├── FlowViewStyle.hpp │ │ ├── Node.hpp │ │ ├── NodeData.hpp │ │ ├── NodeDataModel.hpp │ │ ├── NodeGeometry.hpp │ │ ├── NodeGraphicsObject.hpp │ │ ├── NodePainterDelegate.hpp │ │ ├── NodeState.hpp │ │ ├── NodeStyle.hpp │ │ ├── OperatingSystem.hpp │ │ ├── PortType.hpp │ │ ├── QStringStdHash.hpp │ │ ├── QUuidStdHash.hpp │ │ ├── Serializable.hpp │ │ ├── Style.hpp │ │ ├── TypeConverter.hpp │ │ └── memory.hpp │ ├── pictures │ ├── calculator.png │ ├── chigraph.png │ ├── flow.png │ ├── spkgen.png │ ├── style_example.png │ └── vid1.png │ ├── resources │ ├── DefaultStyle.json │ ├── convert.png │ └── resources.qrc │ ├── src │ ├── Connection.cpp │ ├── ConnectionBlurEffect.cpp │ ├── ConnectionBlurEffect.hpp │ ├── ConnectionGeometry.cpp │ ├── ConnectionGraphicsObject.cpp │ ├── ConnectionPainter.cpp │ ├── ConnectionPainter.hpp │ ├── ConnectionState.cpp │ ├── ConnectionStyle.cpp │ ├── DataModelRegistry.cpp │ ├── FlowScene.cpp │ ├── FlowView.cpp │ ├── FlowViewStyle.cpp │ ├── Node.cpp │ ├── NodeConnectionInteraction.cpp │ ├── NodeConnectionInteraction.hpp │ ├── NodeDataModel.cpp │ ├── NodeGeometry.cpp │ ├── NodeGraphicsObject.cpp │ ├── NodePainter.cpp │ ├── NodePainter.hpp │ ├── NodeState.cpp │ ├── NodeStyle.cpp │ ├── Properties.cpp │ ├── Properties.hpp │ ├── StyleCollection.cpp │ └── StyleCollection.hpp │ └── test │ ├── CMakeLists.txt │ ├── include │ ├── ApplicationSetup.hpp │ ├── Stringify.hpp │ └── StubNodeDataModel.hpp │ ├── src │ ├── TestDataModelRegistry.cpp │ ├── TestDragging.cpp │ ├── TestFlowScene.cpp │ └── TestNodeGraphicsObject.cpp │ └── test_main.cpp ├── license.md ├── misc └── cleanCppProject.sublime-project ├── packaging ├── .DS_Store ├── CMakeLists.txt ├── MacOSXBundleInfo.plist.in ├── ShaderGraph.desktop ├── ShaderGraph.icns ├── ShaderGraph.ico ├── ShaderGraph.icon.in.rc ├── ShaderGraph.png └── dmg_background.png ├── source ├── .DS_Store ├── CMakeLists.txt ├── core │ ├── .DS_Store │ ├── Core.h │ ├── Defines.h │ └── log │ │ ├── .DS_Store │ │ ├── Log.cpp │ │ └── Log.h ├── detail │ ├── DetailDecl.h │ ├── DetailLeaf.cpp │ ├── DetailLeaf.h │ ├── DetailNode.cpp │ ├── DetailNode.h │ └── leaf │ │ ├── DetailBoolean.cpp │ │ ├── DetailBoolean.h │ │ ├── DetailScalar.cpp │ │ ├── DetailScalar.h │ │ ├── DetailText.cpp │ │ ├── DetailText.h │ │ ├── DetailUniform.cpp │ │ ├── DetailUniform.h │ │ ├── DetailVector.cpp │ │ └── DetailVector.h ├── main.cpp ├── model │ ├── Compilation.cpp │ ├── Compilation.h │ ├── Node.cpp │ ├── Node.h │ ├── NodeDecl.h │ ├── converter │ │ ├── Converter.cpp │ │ ├── Converter.h │ │ ├── ToTemplate.cpp │ │ └── ToTemplate.h │ ├── input │ │ ├── ColorNode.cpp │ │ ├── ColorNode.h │ │ ├── CoordinatesExpressions.cpp │ │ ├── CoordinatesExpressions.h │ │ ├── TextureNode.cpp │ │ ├── TextureNode.h │ │ ├── VectorNode.cpp │ │ └── VectorNode.h │ ├── math │ │ ├── Math.cpp │ │ └── Math.h │ ├── misc │ │ ├── VectorFunctions.cpp │ │ └── VectorFunctions.h │ ├── operator │ │ ├── BoolOperator.cpp │ │ ├── BoolOperator.h │ │ ├── CommonOperator.cpp │ │ ├── CommonOperator.h │ │ ├── Operator.cpp │ │ └── Operator.h │ └── output │ │ ├── MasterMaterialOutput.cpp │ │ └── MasterMaterialOutput.h ├── nodeeditor │ ├── FlowScene.cpp │ ├── FlowScene.h │ ├── FlowView.cpp │ ├── FlowView.h │ ├── NodeManager.cpp │ └── NodeManager.h ├── pin │ ├── BooleanPin.cpp │ ├── BooleanPin.h │ ├── FloatPin.cpp │ ├── FloatPin.h │ ├── IPin.h │ ├── Pin.h │ ├── PinDecl.h │ ├── TemplatePin.cpp │ ├── TemplatePin.h │ ├── VectorPin.cpp │ └── VectorPin.h ├── preview │ ├── .DS_Store │ ├── Camera.cpp │ ├── Camera.h │ ├── OpenGL.cpp │ ├── OpenGL.h │ ├── Scene.cpp │ ├── Scene.h │ ├── Shader.cpp │ ├── Shader.h │ ├── Texture.cpp │ └── Texture.h ├── qt │ ├── .DS_Store │ ├── GLWidget.cpp │ ├── GLWidget.h │ ├── WidgetNodeEditor.cpp │ ├── WidgetNodeEditor.h │ ├── Window.cpp │ ├── Window.h │ └── Window.ui ├── unittest │ ├── CMakeLists.txt │ └── testmain.cpp ├── vendor │ ├── .DS_Store │ ├── spdlog │ │ ├── async.h │ │ ├── async_logger.h │ │ ├── common.h │ │ ├── details │ │ │ ├── async_logger_impl.h │ │ │ ├── circular_q.h │ │ │ ├── console_globals.h │ │ │ ├── file_helper.h │ │ │ ├── fmt_helper.h │ │ │ ├── log_msg.h │ │ │ ├── logger_impl.h │ │ │ ├── mpmc_blocking_q.h │ │ │ ├── null_mutex.h │ │ │ ├── os.h │ │ │ ├── pattern_formatter.h │ │ │ ├── periodic_worker.h │ │ │ ├── registry.h │ │ │ └── thread_pool.h │ │ ├── fmt │ │ │ ├── bin_to_hex.h │ │ │ ├── bundled │ │ │ │ ├── LICENSE.rst │ │ │ │ ├── chrono.h │ │ │ │ ├── color.h │ │ │ │ ├── core.h │ │ │ │ ├── format-inl.h │ │ │ │ ├── format.h │ │ │ │ ├── locale.h │ │ │ │ ├── ostream.h │ │ │ │ ├── posix.h │ │ │ │ ├── printf.h │ │ │ │ ├── ranges.h │ │ │ │ └── time.h │ │ │ ├── fmt.h │ │ │ └── ostr.h │ │ ├── formatter.h │ │ ├── logger.h │ │ ├── sinks │ │ │ ├── android_sink.h │ │ │ ├── ansicolor_sink.h │ │ │ ├── base_sink.h │ │ │ ├── basic_file_sink.h │ │ │ ├── daily_file_sink.h │ │ │ ├── dist_sink.h │ │ │ ├── msvc_sink.h │ │ │ ├── null_sink.h │ │ │ ├── ostream_sink.h │ │ │ ├── rotating_file_sink.h │ │ │ ├── sink.h │ │ │ ├── stdout_color_sinks.h │ │ │ ├── stdout_sinks.h │ │ │ ├── syslog_sink.h │ │ │ └── wincolor_sink.h │ │ ├── spdlog.h │ │ ├── tweakme.h │ │ └── version.h │ └── stb │ │ ├── stb_image.cpp │ │ └── stb_image.h ├── version.cpp.in └── version.h └── test ├── .DS_Store └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Logs 35 | *.log 36 | 37 | # Folders 38 | build/ 39 | bin/ 40 | external/Catch/ 41 | external/glm/ 42 | .idea/ 43 | output/* 44 | 45 | data/ShaderGraph_Output.txt 46 | data/shaders/runtime/ 47 | data/shaders/runtime/Material.glsl 48 | 49 | # Files 50 | .DS_Store 51 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Enable C++ support 2 | sudo: required 3 | language: cpp 4 | 5 | matrix: 6 | include: 7 | # linux gcc release 8 | - env: 9 | - COMPILER=g++-8 10 | - PREFIX_PATH="~/Qt/5.10.0/gcc_64/lib/cmake" 11 | os: linux 12 | dist: xenial 13 | compiler: gcc 14 | addons: 15 | apt: 16 | sources: 17 | - ubuntu-toolchain-r-test 18 | packages: 19 | - cmake 20 | - g++-8 21 | 22 | # macos clang release 23 | - env: 24 | - PREFIX_PATH="/usr/local/opt/qt/lib/cmake" 25 | os: osx 26 | compiler: clang 27 | 28 | before_install: 29 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install gnu-which && brew install qt; fi 30 | - if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi 31 | - if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi 32 | - which $CXX 33 | - which $CC 34 | - $CXX --version 35 | - cmake --version 36 | - | 37 | if [ "$TRAVIS_OS_NAME" = "linux" ]; then 38 | sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-xenial 39 | sudo apt-get --yes update 40 | sudo apt-get --yes install qt510-meta-minimal qt510svg 41 | source /opt/qt510/bin/qt510-env.sh # see https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.10.1-xenial 42 | sudo apt-get install freeglut3-dev 43 | fi; 44 | 45 | install: 46 | - mkdir build && cd build 47 | # - cmake .. && make check && make package 48 | - cmake .. 49 | # Build steps 50 | script: 51 | - make 52 | 53 | # branches: 54 | # only: 55 | # - martin 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shader-Graph 2 | Software aimed at GLSL code generation 3 | 4 | 5 |  6 | 7 | ### Purpose 8 | 9 | Shader-Graph is a project developpement, suggested by Mathias Paulin a member of STORM team at IRIT (www.irit.fr). This software is a GUI node editor prototype aimed at GLSL code generation. 10 | 11 | 12 | ### Platforms 13 | 14 | * OSX (Apple Clang - LLVM 3.6), Linux (x64, gcc-8.0): [](https://travis-ci.com/sylvaindeker/Shader-Graph) 15 | 16 | 17 | 18 | ### Dependencies 19 | 20 | * gcc >= 8 21 | * Qt >= 5.2 22 | * CMake >= 3.10 23 | * Catch2 24 | 25 | ### Functionnalities 26 | 27 | 28 | ### Building 29 | #### Linux 30 | 31 | ~~~ 32 | git clone https://github.com/sylvaindeker/Shader-Graph.git 33 | cd Shader-Graph 34 | mkdir build 35 | cd build 36 | cmake .. 37 | make -j 38 | ~~~ 39 | -------------------------------------------------------------------------------- /cmake/useGoldLinker.cmake: -------------------------------------------------------------------------------- 1 | if (UNIX AND NOT APPLE) 2 | execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version) 3 | if ("${ld_version}" MATCHES "GNU gold") 4 | option(USE_GOLD_LINKER "Wheather the gold linker should be used" OFF) 5 | message(STATUS "USE_GOLD_LINKER ${USE_GOLD_LINKER}") 6 | if(USE_GOLD_LINKER) 7 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") 8 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") 9 | endif() 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/.DS_Store -------------------------------------------------------------------------------- /data/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # copy all from data to install dir /share 2 | # here can be images, models 3 | 4 | # install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/images 5 | # DESTINATION ./share/images 6 | # ) 7 | 8 | -------------------------------------------------------------------------------- /data/nodestyle.txt: -------------------------------------------------------------------------------- 1 | ( 2 | { 3 | "ConnectionStyle": 4 | { 5 | "UseDataDefinedColors": true 6 | } 7 | } 8 | ) -------------------------------------------------------------------------------- /data/shaders/runtime/Fragment.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Resulting Fragment Shader 3 | */ 4 | #include "Material.glsl" 5 | #include "PBRCommon.frag.glsl" 6 | -------------------------------------------------------------------------------- /data/shaders/runtime/PBRCommon.frag.glsl: -------------------------------------------------------------------------------- 1 | // This is the canonic fragmentShader any PBR material will use. 2 | // A specific material fragment shader implements the material interface (computeMaterialInternal) 3 | // and include this shader 4 | 5 | // For the moment, include all the ligh-type interfaces. Will change in the future for performances improvement 6 | #include "DefaultLight.glsl" 7 | 8 | // Fragment shader just ouput the fragment color 9 | out vec4 fragColor; 10 | 11 | in vec3 v_position; 12 | in vec3 v_texcoord; 13 | in vec3 v_normal; 14 | in vec3 v_tangent; 15 | in vec3 v_viewVector; 16 | in vec3 v_lightVector; 17 | 18 | void main() 19 | { 20 | // all vectors are in world space 21 | vec3 binormal = normalize(cross(v_normal, v_tangent)); 22 | vec3 normalWorld = getNormal(material, v_texcoord.xy, v_normal, v_tangent, binormal); 23 | vec3 binormalWorld = normalize(cross(normalWorld, v_tangent)); 24 | vec3 tangentWorld = normalize(cross(binormalWorld, normalWorld)); 25 | 26 | // A material is always evaluated in the fragment local Frame 27 | // compute matrix from World to local Frame 28 | mat3 world2local; 29 | world2local[0] = vec3(tangentWorld.x, binormalWorld.x, normalWorld.x); 30 | world2local[1] = vec3(tangentWorld.y, binormalWorld.y, normalWorld.y); 31 | world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z); 32 | 33 | // transform all vectors in local frame so that N = (0, 0, 1); 34 | vec3 wi = world2local * normalize(v_lightVector); // incident direction 35 | vec3 wo = world2local * normalize(v_viewVector); // outgoing direction 36 | 37 | // Compute the material response (evaluate the bsdf) 38 | vec3 materialColor = computeMaterialInternal(material, v_texcoord.xy, wi, wo); 39 | 40 | // Compute the light contribution 41 | vec3 contribution = lightContributionFrom(light, v_position); 42 | 43 | // Set the final color 44 | fragColor = vec4(materialColor * contribution, 1.0); 45 | 46 | // apply gamma correction 47 | float gamma = 2.2; 48 | fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/runtime/PBRCommon.vert.glsl: -------------------------------------------------------------------------------- 1 | //This is the basic vertexShader any PBR material can use 2 | #include "Transform/TransformStructs.glsl" 3 | 4 | //This is for a preview of the shader composition, but in time we must use more specific Light Shader 5 | #include "DefaultLight.glsl" 6 | 7 | // Inputs of vertex shaders are set by the application wrt the following locations 8 | layout (location = 0) in vec3 in_position; 9 | layout (location = 1) in vec3 in_normal; 10 | layout (location = 2) in vec3 in_texcoord; 11 | layout (location = 3) in vec3 in_tangent; 12 | layout (location = 4) in vec3 in_bitangent; 13 | 14 | // Set of matrices that should be used by the shader 15 | uniform Transform transform; 16 | 17 | // Ouputs of the vertex shader are defined by the following interface and location 18 | // Note that all outputs are in world space (will change in the future for performance improvement) 19 | out vec3 v_position; 20 | out vec3 v_texcoord; 21 | out vec3 v_normal; 22 | out vec3 v_tangent; 23 | out vec3 v_viewVector; 24 | out vec3 v_lightVector; 25 | 26 | void main() 27 | { 28 | // compute position in clip space 29 | gl_Position = transform.mvp * vec4(in_position, 1.0); 30 | 31 | // compute position, normal, tangent and eye in world space 32 | vec4 pos = transform.model * vec4(in_position, 1.0); 33 | pos /= pos.w; 34 | 35 | vec3 normal = normalize(mat3(transform.worldNormal) * in_normal); 36 | vec3 tangent = normalize(mat3(transform.model) * in_tangent); 37 | 38 | vec3 eye = -transform.view[3].xyz * mat3(transform.view); 39 | 40 | // ouput vertex components 41 | v_position = vec3(pos); 42 | v_texcoord = in_texcoord; 43 | 44 | v_normal = normal; 45 | v_tangent = tangent; 46 | 47 | v_viewVector = normalize(vec3(eye - vec3(pos))); 48 | v_lightVector = getLightDirection(light, vec3(pos)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/runtime/Transform/TransformStructs.glsl: -------------------------------------------------------------------------------- 1 | struct Transform 2 | { 3 | mat4 model; 4 | mat4 view; 5 | mat4 proj; 6 | mat4 mvp; 7 | mat4 modelView; 8 | mat4 worldNormal; 9 | mat4 viewNormal; 10 | }; 11 | -------------------------------------------------------------------------------- /data/shaders/runtime/Vertex.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Composite vertex shader for Plastic material 3 | */ 4 | #include "PBRCommon.vert.glsl" 5 | -------------------------------------------------------------------------------- /data/shaders/source/Fragment.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Resulting Fragment Shader 3 | */ 4 | #include "Material.glsl" 5 | #include "PBRCommon.frag.glsl" 6 | -------------------------------------------------------------------------------- /data/shaders/source/MaterialModelFooter.txt: -------------------------------------------------------------------------------- 1 | vec3 getNormal(Material material, vec2 texCoord, vec3 N, vec3 T, vec3 B) { 2 | if (material.tex.hasNormal == 1) { 3 | mat3 tbn; 4 | 5 | tbn[0] = T; 6 | tbn[1] = B; 7 | tbn[2] = N; 8 | 9 | vec3 normalLocal = normalize(vec3(texture(material.tex.normal, texCoord)) * 2 - 1); 10 | return normalize(tbn * normalLocal); 11 | } 12 | 13 | return normalize(N); 14 | } 15 | 16 | /* 17 | * Compute the response of the material according to the incomming (light) diretion wi and the 18 | * outgoing (view) direction wo at the position on surface texC. 19 | * Note that the directions are expressed in the local frame. 20 | */ 21 | vec3 computeMaterialInternal(Material material, vec2 texC, vec3 wi, vec3 wo) { 22 | float cosTi = CosTheta(wi); 23 | float cosTo = CosTheta(wo); 24 | 25 | if (cosTi == 0 || cosTo == 0) 26 | return vec3(0.f); 27 | 28 | 29 | bool reflect = (cosTi * cosTo > 0); 30 | vec3 result = vec3(0.f); 31 | 32 | vec3 kd = getKd(material, texC); 33 | 34 | if (reflect) { 35 | cosTi = abs(cosTi); 36 | cosTo = abs(cosTo); 37 | 38 | result = (kd * InvPi); 39 | 40 | vec3 wh = wi + wo; 41 | if (!(wh.x == 0 && wh.y == 0 && wh.z == 0)) { 42 | wh = normalize(wh); 43 | vec3 ks = getKs(material, texC); 44 | vec3 F0 = vec3(0.04); 45 | F0 = mix(F0, ks, vec3(getMetalness(material, texC))); 46 | vec3 F90 = kd; 47 | vec3 F = FresnelShlick(dot(wi, wh), F0, F90); 48 | vec2 rough = getRoughness(material, texC); 49 | float D = TRD_D(wh, rough.x, rough.y); 50 | float G = TRD_G(wo, wi, rough.x, rough.y); 51 | result += (F * D * G /(4 * cosTi * cosTo)); 52 | } 53 | } 54 | /* result + ambient */ 55 | return result * cosTi + 0.1 * kd; 56 | } 57 | 58 | // Define the uniform that could be accessed from th application 59 | uniform Material material; 60 | 61 | #endif//PLASTICMATERIAL_GLSL 62 | -------------------------------------------------------------------------------- /data/shaders/source/MaterialModelHeader.txt: -------------------------------------------------------------------------------- 1 | #ifndef PLASTICMATERIAL_GLSL 2 | #define PLASTICMATERIAL_GLSL 3 | /* 4 | * Implements material interface for Plastic material 5 | * see at https://www.pbrt.org/fileformat-v3.html#materials for parameters and 6 | * properties 7 | */ 8 | // Microfacet functions used 9 | #include "MicrofacetFunction.glsl" 10 | 11 | /* Material data structure 12 | * Defines the input of the material 13 | * All material parameters will be set by the application 14 | */ 15 | // Material parameters could be textured, 16 | struct MaterialTextures { 17 | int hasKd; 18 | int hasKs; 19 | int hasRoughness; 20 | int hasNormal; 21 | 22 | sampler2D kd; 23 | sampler2D ks; 24 | sampler2D roughness; 25 | sampler2D normal; 26 | }; 27 | 28 | // Main material description 29 | struct Material { 30 | vec4 kd; 31 | vec4 ks; 32 | float roughness; 33 | int remapRoughness; 34 | 35 | MaterialTextures tex; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /data/shaders/source/PBRCommon.frag.glsl: -------------------------------------------------------------------------------- 1 | // This is the canonic fragmentShader any PBR material will use. 2 | // A specific material fragment shader implements the material interface (computeMaterialInternal) 3 | // and include this shader 4 | 5 | // For the moment, include all the ligh-type interfaces. Will change in the future for performances improvement 6 | #include "DefaultLight.glsl" 7 | 8 | // Fragment shader just ouput the fragment color 9 | out vec4 fragColor; 10 | 11 | in vec3 v_position; 12 | in vec3 v_texcoord; 13 | in vec3 v_normal; 14 | in vec3 v_tangent; 15 | in vec3 v_viewVector; 16 | in vec3 v_lightVector; 17 | 18 | void main() 19 | { 20 | // all vectors are in world space 21 | vec3 binormal = normalize(cross(v_normal, v_tangent)); 22 | vec3 normalWorld = getNormal(material, v_texcoord.xy, v_normal, v_tangent, binormal); 23 | vec3 binormalWorld = normalize(cross(normalWorld, v_tangent)); 24 | vec3 tangentWorld = normalize(cross(binormalWorld, normalWorld)); 25 | 26 | // A material is always evaluated in the fragment local Frame 27 | // compute matrix from World to local Frame 28 | mat3 world2local; 29 | world2local[0] = vec3(tangentWorld.x, binormalWorld.x, normalWorld.x); 30 | world2local[1] = vec3(tangentWorld.y, binormalWorld.y, normalWorld.y); 31 | world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z); 32 | 33 | // transform all vectors in local frame so that N = (0, 0, 1); 34 | vec3 wi = world2local * normalize(v_lightVector); // incident direction 35 | vec3 wo = world2local * normalize(v_viewVector); // outgoing direction 36 | 37 | // Compute the material response (evaluate the bsdf) 38 | vec3 materialColor = computeMaterialInternal(material, v_texcoord.xy, wi, wo); 39 | 40 | // Compute the light contribution 41 | vec3 contribution = lightContributionFrom(light, v_position); 42 | 43 | // Set the final color 44 | fragColor = vec4(materialColor * contribution, 1.0); 45 | 46 | // apply gamma correction 47 | float gamma = 2.2; 48 | fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/source/PBRCommon.vert.glsl: -------------------------------------------------------------------------------- 1 | //This is the basic vertexShader any PBR material can use 2 | #include "Transform/TransformStructs.glsl" 3 | 4 | //This is for a preview of the shader composition, but in time we must use more specific Light Shader 5 | #include "DefaultLight.glsl" 6 | 7 | // Inputs of vertex shaders are set by the application wrt the following locations 8 | layout (location = 0) in vec3 in_position; 9 | layout (location = 1) in vec3 in_normal; 10 | layout (location = 2) in vec3 in_texcoord; 11 | layout (location = 3) in vec3 in_tangent; 12 | layout (location = 4) in vec3 in_bitangent; 13 | 14 | // Set of matrices that should be used by the shader 15 | uniform Transform transform; 16 | 17 | // Ouputs of the vertex shader are defined by the following interface and location 18 | // Note that all outputs are in world space (will change in the future for performance improvement) 19 | out vec3 v_position; 20 | out vec3 v_texcoord; 21 | out vec3 v_normal; 22 | out vec3 v_tangent; 23 | out vec3 v_viewVector; 24 | out vec3 v_lightVector; 25 | 26 | void main() 27 | { 28 | // compute position in clip space 29 | gl_Position = transform.mvp * vec4(in_position, 1.0); 30 | 31 | // compute position, normal, tangent and eye in world space 32 | vec4 pos = transform.model * vec4(in_position, 1.0); 33 | pos /= pos.w; 34 | 35 | vec3 normal = normalize(mat3(transform.worldNormal) * in_normal); 36 | vec3 tangent = normalize(mat3(transform.model) * in_tangent); 37 | 38 | vec3 eye = -transform.view[3].xyz * mat3(transform.view); 39 | 40 | // ouput vertex components 41 | v_position = vec3(pos); 42 | v_texcoord = in_texcoord; 43 | 44 | v_normal = normal; 45 | v_tangent = tangent; 46 | 47 | v_viewVector = normalize(vec3(eye - vec3(pos))); 48 | v_lightVector = getLightDirection(light, vec3(pos)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/source/Transform/._TransformStructs.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/shaders/source/Transform/._TransformStructs.glsl -------------------------------------------------------------------------------- /data/shaders/source/Transform/TransformStructs.glsl: -------------------------------------------------------------------------------- 1 | struct Transform 2 | { 3 | mat4 model; 4 | mat4 view; 5 | mat4 proj; 6 | mat4 mvp; 7 | mat4 modelView; 8 | mat4 worldNormal; 9 | mat4 viewNormal; 10 | }; 11 | -------------------------------------------------------------------------------- /data/shaders/source/Vertex.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Composite vertex shader for Plastic material 3 | */ 4 | #include "PBRCommon.vert.glsl" 5 | -------------------------------------------------------------------------------- /data/textures/Brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/textures/Brick.png -------------------------------------------------------------------------------- /data/textures/ShaderGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/textures/ShaderGraph.png -------------------------------------------------------------------------------- /doc/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/doc/.DS_Store -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /doc/directoryStructure.md: -------------------------------------------------------------------------------- 1 | # Directory structure 2 | 3 | * mainProjectFolder 4 | - **build** - user created, build takes place here 5 | + **dist** - here builded application is copied (by deafult, see CMAKE_INSTALL_PREFIX in main CMakeLists.txt) 6 | * **bin** 7 | * **share** 8 | - **data** - here folder data is copied 9 | * **doc** 10 | - doxygen lives here documentation 11 | - **cmake** - contains cmake scripts that can be included with include() 12 | + cleanCppExtensions.cmake - reusable helpers for source/CMakeLists.txt 13 | - **data** - contain data 14 | - **doc** - contains documentation 15 | + CMakeLists.txt - doc building 16 | + **doxygen** 17 | * doxygen settings, and modern style config 18 | - **packaging** 19 | + CMakeLists.txt - package creation 20 | + ShaderGraph.desktop - linux shortcut (app is then visible in launchers) 21 | + ShaderGraph.png - icon for linux shortcut 22 | + ShaderGraph.icon.in.rc - icon for windows description file (used in source/CMakeLists.txt) 23 | + ShaderGraph.ico - icon for windows shortcut (linked via ShaderGraph.icon.in.rc into the executable) 24 | - **source** - contain source files 25 | + CMakeLists.txt - source building 26 | + .ycm_extra_conf.py - for ycm smart autocompletion 27 | + **unittest* contains unittest build 28 | + CMakeLists.txt - unittest building 29 | + testmain.cpp - main unit tests function 30 | - **test** - integration tests, CTest, data sets for tests and unit tests 31 | + CMakeLists.txt - tests specification 32 | - **external** 33 | + CMakeLists.txt - external projects handling (eg. Download of Catch) 34 | - readme.md - main readme file 35 | - CMakeLists.md - Main CMake configuration 36 | - .clang-format - clang format config file 37 | - .clang-tidy - clang tidy config file 38 | - .travis.yml - continuous integration configuration for Travis CI 39 | - .gitlab-ci.yml - continuous integration configuration for Gitlab CI 40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
12 | 13 | 14 |