first version of SCribe used for shaders in render-utils

This commit is contained in:
Sam Gateau 2014-12-23 16:27:02 -08:00
parent 03d8922d59
commit c5eb04336f
7 changed files with 105 additions and 15 deletions

View file

@ -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)

View file

@ -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()

View file

@ -0,0 +1,22 @@
<!
// Config.slh
// interface/src
//
// Created by Sam Gateau on 12/17/14.
// 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 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@>

View file

@ -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

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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 {