mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 07:22:31 +02:00
Support include path to shaders from the hifi libraries to cmake
This commit is contained in:
parent
798817f34a
commit
e2e61c64b1
41 changed files with 137 additions and 52 deletions
|
@ -15,12 +15,21 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
|
|||
list(APPEND SHADER_INCLUDE_FILES ${includeFile})
|
||||
endforeach()
|
||||
|
||||
#Extract the unique include shader paths
|
||||
foreach(SHADER_INCLUDE ${SHADER_INCLUDE_FILES})
|
||||
get_filename_component(INCLUDE_DIR ${SHADER_INCLUDE} PATH)
|
||||
list(APPEND SHADER_INCLUDES_PATHS ${INCLUDE_DIR})
|
||||
endforeach()
|
||||
|
||||
|
||||
#Extract the unique include shader paths
|
||||
set(INCLUDES ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
|
||||
#message(Hifi for includes ${INCLUDES})
|
||||
foreach(EXTRA_SHADER_INCLUDE ${INCLUDES})
|
||||
list(APPEND SHADER_INCLUDES_PATHS ${EXTRA_SHADER_INCLUDE})
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES SHADER_INCLUDES_PATHS)
|
||||
#message(ready for includes ${SHADER_INCLUDES_PATHS})
|
||||
|
||||
# make the scribe include arguments
|
||||
set(SCRIBE_INCLUDES)
|
||||
|
@ -64,6 +73,17 @@ endfunction()
|
|||
|
||||
|
||||
macro(AUTOSCRIBE_SHADER_LIB)
|
||||
|
||||
file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}")
|
||||
foreach(HIFI_LIBRARY ${ARGN})
|
||||
#if (NOT TARGET ${HIFI_LIBRARY})
|
||||
# file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}/src/)
|
||||
#endif ()
|
||||
|
||||
#file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src/*.slh)
|
||||
list(APPEND HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src)
|
||||
endforeach()
|
||||
#message(${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
|
||||
|
||||
file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh)
|
||||
file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
set(TARGET_NAME gpu)
|
||||
|
||||
AUTOSCRIBE_SHADER_LIB(gpu)
|
||||
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
|
|
4
libraries/render-utils/src/Config.slh → libraries/gpu/src/gpu/Config.slh
Executable file → Normal file
4
libraries/render-utils/src/Config.slh → libraries/gpu/src/gpu/Config.slh
Executable file → Normal file
|
@ -8,8 +8,8 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
!>
|
||||
<@if not CONFIG_SLH@>
|
||||
<@def CONFIG_SLH@>
|
||||
<@if not GPU_CONFIG_SLH@>
|
||||
<@def GPU_CONFIG_SLH@>
|
||||
|
||||
<@if GLPROFILE == PC_GL @>
|
||||
<@def VERSION_HEADER #version 330 compatibility@>
|
60
libraries/gpu/src/gpu/Transform.slh
Normal file
60
libraries/gpu/src/gpu/Transform.slh
Normal file
|
@ -0,0 +1,60 @@
|
|||
<!
|
||||
// gpu/TransformState.slh
|
||||
//
|
||||
// Created by Sam Gateau on 2/10/15.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
!>
|
||||
<@if not GPU_TRANSFORM_STATE_SLH@>
|
||||
<@def GPU_TRANSFORM_STATE_SLH@>
|
||||
|
||||
struct TransformObject {
|
||||
mat4 _model;
|
||||
mat4 _modelInverseTranspose;
|
||||
};
|
||||
|
||||
struct TransformCamera {
|
||||
mat4 _view;
|
||||
mat4 _viewInverseTranspose;
|
||||
mat4 _proj;
|
||||
mat4 _projInverseTranspose;
|
||||
mat4 _viewProj;
|
||||
mat4 _viewProjInverseTranspose;
|
||||
};
|
||||
|
||||
vec4 transform(TransformCamera camera, TransformObject object, vec4 pos) {
|
||||
return camera._proj * (camera._view * (object._model * pos)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
<@if GLPROFILE == PC_GL@>
|
||||
uniform transformStateBuffer {
|
||||
TransformState xform;
|
||||
};
|
||||
TransformState getTransformState() {
|
||||
return xform;
|
||||
}
|
||||
<@elif GLPROFILE == MAC_GL@>
|
||||
uniform vec4 transformStateBuffer[2];
|
||||
TransformState getTransformState() {
|
||||
TransformState xform;
|
||||
xform._diffuse = transformStateBuffer[0];
|
||||
xform._specular = transformStateBuffer[1];
|
||||
return xform;
|
||||
}
|
||||
<@else@>
|
||||
uniform vec4 transformStateBuffer[2];
|
||||
TransformState getMaterial() {
|
||||
TransformState xform;
|
||||
xform._diffuse = transformStateBuffer[0];
|
||||
xform._specular = transformStateBuffer[1];
|
||||
return xform;
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
|
||||
|
||||
<@endif@>
|
|
@ -1,4 +1,6 @@
|
|||
set(TARGET_NAME model)
|
||||
|
||||
AUTOSCRIBE_SHADER_LIB(gpu)
|
||||
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
|
4
libraries/render-utils/src/Light.slh → libraries/model/src/model/Light.slh
Executable file → Normal file
4
libraries/render-utils/src/Light.slh → libraries/model/src/model/Light.slh
Executable file → Normal file
|
@ -8,8 +8,8 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
!>
|
||||
<@if not LIGHT_SLH@>
|
||||
<@def LIGHT_SLH@>
|
||||
<@if not MODEL_LIGHT_SLH@>
|
||||
<@def MODEL_LIGHT_SLH@>
|
||||
|
||||
struct Light {
|
||||
vec4 _position;
|
4
libraries/render-utils/src/Material.slh → libraries/model/src/model/Material.slh
Executable file → Normal file
4
libraries/render-utils/src/Material.slh → libraries/model/src/model/Material.slh
Executable file → Normal file
|
@ -8,8 +8,8 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
!>
|
||||
<@if not MATERIAL_SLH@>
|
||||
<@def MATERIAL_SLH@>
|
||||
<@if not MODEL_MATERIAL_SLH@>
|
||||
<@def MODEL_MATERIAL_SLH@>
|
||||
|
||||
struct Material {
|
||||
vec4 _diffuse;
|
|
@ -1,6 +1,6 @@
|
|||
set(TARGET_NAME render-utils)
|
||||
|
||||
AUTOSCRIBE_SHADER_LIB()
|
||||
AUTOSCRIBE_SHADER_LIB(gpu model)
|
||||
|
||||
# pull in the resources.qrc file
|
||||
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
|
||||
|
|
|
@ -49,7 +49,7 @@ vec4 evalSphericalLight(SphericalHarmonics sh, vec3 direction ) {
|
|||
uniform SphericalHarmonics ambientSphere;
|
||||
|
||||
// Everything about light
|
||||
<@include Light.slh@>
|
||||
<@include model/Light.slh@>
|
||||
|
||||
// The view Matrix
|
||||
uniform mat4 invViewMat;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// model.frag
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// model.vert
|
||||
|
@ -11,6 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Material.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -19,7 +19,7 @@
|
|||
<@include DeferredLighting.slh@>
|
||||
|
||||
// Everything about light
|
||||
<@include Light.slh@>
|
||||
<@include model/Light.slh@>
|
||||
|
||||
// The view Matrix
|
||||
uniform mat4 invViewMat;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// sdf_text.frag
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// sdf_text.vert
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<@include Config.slh@>
|
||||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
|
@ -19,7 +19,7 @@
|
|||
<@include DeferredLighting.slh@>
|
||||
|
||||
// Everything about light
|
||||
<@include Light.slh@>
|
||||
<@include model/Light.slh@>
|
||||
|
||||
// The view Matrix
|
||||
uniform mat4 invViewMat;
|
||||
|
|
Loading…
Reference in a new issue