diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 362a833862..e76e1112e3 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -16,7 +16,7 @@ macro(SETUP_HIFI_LIBRARY) set(LIB_SRCS ${LIB_SRCS}) # create a library and set the property so it can be referenced later - add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC}) + add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC} ${AUTOSCRIBE_SHADER_LIB_SRC}) set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN}) list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core) diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index 97dc9c7bc8..f84bd97c13 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -1,11 +1,13 @@ -set(TARGET_NAME render-utils) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(Widgets OpenGL Network Script) - -include_glm() - -link_hifi_libraries(animation fbx shared gpu) - -# call macro to include our dependency includes and bubble them up via a property on our target -include_dependency_includes() +set(TARGET_NAME render-utils) + +AUTOSCRIBE_SHADER_LIB() + +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(Widgets OpenGL Network Script) + +include_glm() + +link_hifi_libraries(animation fbx shared gpu) + +# call macro to include our dependency includes and bubble them up via a property on our target +include_dependency_includes() \ No newline at end of file diff --git a/libraries/render-utils/src/Config.slh b/libraries/render-utils/src/Config.slh new file mode 100755 index 0000000000..b431b671a6 --- /dev/null +++ b/libraries/render-utils/src/Config.slh @@ -0,0 +1,22 @@ + +<@if not CONFIG_SLH@> +<@def CONFIG_SLH@> + +<@if GLPROFILE == PC_GL @> + <@def VERSION_HEADER #version 330 compatibility@> +<@elif GLPROFILE == MAC_GL @> + <@def VERSION_HEADER #version 120@> +<@else@> + <@def VERSION_HEADER #version 120@> +<@endif@> + +<@endif@> diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 6d313bc7aa..8a355f1f73 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -35,6 +35,8 @@ #include "GlowEffect.h" #include "Model.h" +#include "model_vert.h" +#include "model_frag.h" #define GLBATCH( call ) batch._##call //#define GLBATCH( call ) call diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf new file mode 100755 index 0000000000..967fccce2a --- /dev/null +++ b/libraries/render-utils/src/model.slf @@ -0,0 +1,29 @@ +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// model.frag +// fragment shader +// +// Created by Andrzej Kapolka on 10/14/13. +// 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 +// + +// the diffuse texture +uniform sampler2D diffuseMap; + +// the alpha threshold +uniform float alphaThreshold; + +// the interpolated normal +varying vec4 normal; + +void main(void) { + // set the diffuse, normal, specular data + vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st); + gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, mix(gl_Color.a, 1.0 - gl_Color.a, step(diffuse.a, alphaThreshold))); + gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0); + gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0); +} diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv new file mode 100755 index 0000000000..e1096194ff --- /dev/null +++ b/libraries/render-utils/src/model.slv @@ -0,0 +1,35 @@ +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// model.vert +// vertex shader +// +// Created by Andrzej Kapolka on 10/14/13. +// 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 +// + +const int MAX_TEXCOORDS = 2; + +uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; + +// the interpolated normal +varying vec4 normal; + +void main(void) { + // transform and store the normal for interpolation + normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0)); + + // pass along the diffuse color + // gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + gl_FrontColor = gl_Color; + + // and the texture coordinates + gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); + + // use standard pipeline transform + gl_Position = ftransform(); +} + diff --git a/tools/scribe/src/main.cpp b/tools/scribe/src/main.cpp index 55f23f8c55..6128b0bee1 100755 --- a/tools/scribe/src/main.cpp +++ b/tools/scribe/src/main.cpp @@ -192,15 +192,15 @@ int main (int argc, char** argv) { targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl; targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl; - targetStringStream << "const char " << targetName << "[] = {\n\""; + targetStringStream << "const char " << targetName << "[] = {\n"; std::stringstream destStringStreamAgain(destStringStream.str()); while (!destStringStreamAgain.eof()) { std::string line; std::getline(destStringStreamAgain, line); - targetStringStream << line << " \\n\\\n"; + targetStringStream << "\"" << line << "\\n\"" << std::endl; } - targetStringStream << "\"};" << std::endl << std::endl; + targetStringStream << "};" << std::endl << std::endl; targetStringStream << "#endif" << std::endl; } else {