Merging with upstream and compiling on windows

This commit is contained in:
Sam Gateau 2015-07-31 16:14:53 -07:00
commit ca4dbdb996
49 changed files with 562 additions and 474 deletions

View file

@ -14,16 +14,13 @@
<@if GLPROFILE == PC_GL @>
<@def GPU_FEATURE_PROFILE GPU_CORE@>
<@def GPU_TRANSFORM_PROFILE GPU_CORE@>
<@def VERSION_HEADER #version 430 compatibility@>
<@def VERSION_HEADER #version 410 core@>
<@elif GLPROFILE == MAC_GL @>
<@def GPU_FEATURE_PROFILE GPU_LEGACY@>
<@def GPU_TRANSFORM_PROFILE GPU_LEGACY@>
<@def VERSION_HEADER #version 120
#extension GL_EXT_gpu_shader4 : enable@>
<@def GPU_FEATURE_PROFILE GPU_CORE@>
<@def GPU_TRANSFORM_PROFILE GPU_CORE@>
<@def VERSION_HEADER #version 410 core@>
<@else@>
<@def GPU_FEATURE_PROFILE GPU_CORE@>
<@def GPU_TRANSFORM_PROFILE GPU_CORE@>
<@def VERSION_HEADER #version 430 compatibility@>
<@endif@>
<@def VERSION_HEADER #version 410 core@>
<@endif@>

View file

@ -191,8 +191,8 @@ GLBackend::GLShader* compileShader(const Shader& shader) {
char* temp = new char[infoLength] ;
glGetShaderInfoLog(glshader, infoLength, NULL, temp);
qCDebug(gpulogging) << "GLShader::compileShader - failed to compile the gl shader object:";
qCDebug(gpulogging) << temp;
qWarning() << "GLShader::compileShader - failed to compile the gl shader object:";
qWarning() << temp;
/*
filestream.open("debugshader.glsl.info.txt");

View file

@ -0,0 +1,23 @@
<!
// Input.slh
// interface/src
//
// Created by Bradley Austin Davis on 2015/06/19.
// Copyright 2015 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_INPUTS_SLH@>
<@def GPU_INPUTS_SLH@>
layout(location = 0) in vec4 inPosition;
layout(location = 1) in vec4 inNormal;
layout(location = 2) in vec4 inColor;
layout(location = 3) in vec4 inTexCoord0;
layout(location = 4) in vec4 inTangent;
layout(location = 5) in ivec4 inSkinClusterIndex;
layout(location = 6) in vec4 inSkinClusterWeight;
layout(location = 7) in vec4 inTexCoord1;
layout(location = 9) in vec4 inInstanceScaleTranslate;
layout(location = 8) in mat4 inInstanceXfm;
<@endif@>

View file

@ -27,13 +27,17 @@ public:
// Possible input slots identifiers
enum InputSlot {
POSITION = 0,
NORMAL,
COLOR,
TEXCOORD,
TANGENT,
SKIN_CLUSTER_INDEX,
SKIN_CLUSTER_WEIGHT,
TEXCOORD1,
NORMAL = 1,
COLOR = 2,
TEXCOORD0 = 3,
TEXCOORD = TEXCOORD0,
TANGENT = 4,
SKIN_CLUSTER_INDEX = 5,
SKIN_CLUSTER_WEIGHT = 6,
TEXCOORD1 = 7,
INSTANCE_XFM = 8,
INSTANCE_SCALE = 9,
INSTANCE_TRANSLATE = 10,
NUM_INPUT_SLOTS,
};

View file

@ -1,6 +1,6 @@
set(TARGET_NAME model)
AUTOSCRIBE_SHADER_LIB(gpu)
AUTOSCRIBE_SHADER_LIB(gpu model)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library()

View file

@ -18,32 +18,17 @@ struct Material {
vec4 _spare;
};
uniform materialBuffer {
Material _mat;
};
Material getMaterial() {
return _mat;
}
float getMaterialOpacity(Material m) { return m._diffuse.a; }
vec3 getMaterialDiffuse(Material m) { return m._diffuse.rgb; }
vec3 getMaterialSpecular(Material m) { return m._specular.rgb; }
float getMaterialShininess(Material m) { return m._specular.a; }
<@if GPU_FEATURE_PROFILE == GPU_CORE@>
uniform materialBuffer {
Material _mat;
};
Material getMaterial() {
return _mat;
}
<@else@>
uniform vec4 materialBuffer[4];
Material getMaterial() {
Material mat;
mat._diffuse = materialBuffer[0];
mat._specular = materialBuffer[1];
mat._emissive = materialBuffer[2];
mat._spare = materialBuffer[3];
return mat;
}
<@endif@>
<@endif@>

View file

@ -2,6 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// skybox.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2015.
// Copyright 2015 High Fidelity, Inc.
@ -12,14 +13,22 @@
uniform samplerCube cubeMap;
varying vec3 normal;
varying vec2 texcoord;
varying vec3 color;
struct Skybox {
vec4 _color;
};
uniform skyboxBuffer {
Skybox _skybox;
};
in vec3 _normal;
out vec4 _fragColor;
void main(void) {
vec3 coord = normalize(normal);
vec4 texel = textureCube(cubeMap, coord);
vec3 pixel = pow(texel.xyz * color, vec3(1.0/2.2)); // manual Gamma correction
gl_FragData[0] = vec4(pixel, 0.0);
vec3 coord = normalize(_normal);
vec3 texel = texture(cubeMap, coord).rgb;
vec3 color = texel * _skybox._color.rgb;
vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
_fragColor = vec4(pixel, 0.0);
}

View file

@ -11,48 +11,24 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
struct Skybox {
vec4 _color;
};
<@if GPU_FEATURE_PROFILE == GPU_CORE @>
uniform skyboxBuffer {
Skybox _skybox;
};
Skybox getSkybox() {
return _skybox;
}
<@else@>
uniform vec4 skyboxBuffer[1];
Skybox getSkybox() {
Skybox _skybox;
_skybox._color = skyboxBuffer[0];
return _skybox;
}
<@endif@>
varying vec3 normal;
varying vec2 texcoord;
varying vec3 color;
void main(void) {
texcoord = gl_Vertex.xy;
Skybox skybox = getSkybox();
color = skybox._color.xyz;
out vec3 _normal;
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
vec3 clipDir = vec3(texcoord.xy, 0.0);
vec3 clipDir = vec3(inPosition.xy, 0.0);
vec3 eyeDir;
<$transformClipToEyeDir(cam, clipDir, eyeDir)$>;
<$transformEyeToWorldDir(cam, eyeDir, normal)$>;
// Position is supposed to cmoe in clip space
gl_Position = vec4(texcoord.xy, 0.0, 1.0);
}
<$transformClipToEyeDir(cam, clipDir, eyeDir)$>
<$transformEyeToWorldDir(cam, eyeDir, _normal)$>
// Position is supposed to come in clip space
gl_Position = vec4(inPosition.xy, 0.0, 1.0);
}

View file

@ -11,6 +11,10 @@
<@if not DEFERRED_BUFFER_WRITE_SLH@>
<@def DEFERRED_BUFFER_WRITE_SLH@>
layout(location = 0) out vec4 _fragColor0;
layout(location = 1) out vec4 _fragColor1;
layout(location = 2) out vec4 _fragColor2;
// the glow intensity
uniform float glowIntensity;
@ -28,9 +32,9 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular,
if (alpha != glowIntensity) {
discard;
}
gl_FragData[0] = vec4(diffuse.rgb, alpha);
gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
gl_FragData[2] = vec4(specular, shininess / 128.0);
_fragColor0 = vec4(diffuse.rgb, alpha);
_fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
_fragColor2 = vec4(specular, shininess / 128.0);
}
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess, vec3 emissive) {
@ -38,10 +42,10 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 s
discard;
}
gl_FragData[0] = vec4(diffuse.rgb, alpha);
//gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
gl_FragData[2] = vec4(emissive, shininess / 128.0);
_fragColor0 = vec4(diffuse.rgb, alpha);
//_fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
_fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
_fragColor2 = vec4(emissive, shininess / 128.0);
}
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
@ -49,9 +53,9 @@ void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 diffuse, vec
discard;
}
gl_FragData[0] = vec4(diffuse.rgb, alpha);
// gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
// gl_FragData[2] = vec4(specular, shininess / 128.0);
_fragColor0 = vec4(diffuse.rgb, alpha);
// _fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
// _fragColor2 = vec4(specular, shininess / 128.0);
}
<@endif@>

View file

@ -16,12 +16,7 @@
uniform samplerCube skyboxMap;
vec4 evalSkyboxLight(vec3 direction, float lod) {
<@if GPU_TRANSFORM_PROFILE == GPU_CORE@>
vec4 skytexel = textureCubeLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap));
<@else@>
vec4 skytexel = textureCube(skyboxMap, direction);
<@endif@>
vec4 skytexel = textureLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap));
return skytexel;
}

View file

@ -14,13 +14,25 @@
// the shadow texture
uniform sampler2DShadow shadowMap;
struct EyePlanes {
vec4 _S[1];
vec4 _T[1];
vec4 _R[1];
vec4 _Q[1];
};
uniform eyePlanes {
EyePlanes _eyePlanes;
};
EyePlanes getEyePlanes() {
return _eyePlanes;
}
// Fetching it
float fetchShadow(vec3 texcoord) {
<@if GPU_FEATURE_PROFILE == GPU_CORE @>
return texture(shadowMap, texcoord);
<@else@>
return shadow2D(shadowMap, texcoord).r;
<@endif@>
}
// the distances to the cascade sections
@ -44,17 +56,22 @@ vec2 samples[8] = vec2[8](
vec4 evalShadowTexcoord(vec4 position) {
// compute the corresponding texture coordinates
vec3 shadowTexcoord = vec3(dot(gl_EyePlaneS[0], position), dot(gl_EyePlaneT[0], position), dot(gl_EyePlaneR[0], position));
EyePlanes eyePlanes = getEyePlanes();
vec3 shadowTexcoord = vec3(dot(eyePlanes._S[0], position), dot(eyePlanes._T[0], position), dot(eyePlanes._R[0], position));
return vec4(shadowTexcoord, 0.0);
}
vec4 evalCascadedShadowTexcoord(vec4 position) {
EyePlanes eyePlanes = getEyePlanes();
// compute the index of the cascade to use and the corresponding texture coordinates
int shadowIndex = int(dot(step(vec3(position.z), shadowDistances), vec3(1.0, 1.0, 1.0)));
vec3 shadowTexcoord = vec3(dot(gl_EyePlaneS[shadowIndex], position), dot(gl_EyePlaneT[shadowIndex], position),
dot(gl_EyePlaneR[shadowIndex], position));
vec3 shadowTexcoord = vec3(
dot(eyePlanes._S[shadowIndex], position),
dot(eyePlanes._T[shadowIndex], position),
dot(eyePlanes._R[shadowIndex], position));
return vec4(shadowTexcoord, shadowIndex);
return vec4(shadowTexcoord, shadowIndex);
}
float evalShadowAttenuationPCF(vec4 shadowTexcoord) {

View file

@ -12,7 +12,11 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
out vec2 _texCoord0;
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
_texCoord0 = inTexCoord0.st;
gl_Position = inPosition;
}

View file

@ -14,6 +14,8 @@
<@include gpu/Transform.slh@>
<@include gpu/Inputs.slh@>
<$declareStandardTransform()$>
uniform mat4 texcoordMat;
@ -22,7 +24,7 @@ void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>;
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>;
vec4 projected = gl_Position / gl_Position.w;
gl_TexCoord[0] = vec4(dot(projected, texcoordMat[0]) * gl_Position.w,

View file

@ -17,8 +17,11 @@
<@include DeferredGlobalLight.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Light mapped or not ?
@ -29,7 +32,7 @@ void main(void) {
frag.diffuse,
frag.specularVal.xyz);
gl_FragColor = vec4(color, 1.0);
_fragColor = vec4(color, 1.0);
} else {
vec3 color = evalAmbienSphereGlobalColor(1.0,
frag.position.xyz,
@ -38,6 +41,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,8 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
@ -29,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -43,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,9 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
@ -30,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -44,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -17,12 +17,15 @@
<@include DeferredGlobalLight.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4( evalLightmappedColor(
_fragColor = vec4( evalLightmappedColor(
1.0,
frag.normal,
frag.diffuse,
@ -36,6 +39,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,8 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
@ -29,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -43,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,9 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
@ -30,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -44,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -17,8 +17,11 @@
<@include DeferredGlobalLight.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Light mapped or not ?
@ -29,7 +32,7 @@ void main(void) {
frag.diffuse,
frag.specularVal.xyz);
gl_FragColor = vec4(color, 1.0);
_fragColor = vec4(color, 1.0);
} else {
vec3 color = evalSkyboxGlobalColor(1.0,
frag.position.xyz,
@ -38,6 +41,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,8 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
@ -29,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -43,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -20,9 +20,11 @@
// Everything about shadow
<@include Shadow.slh@>
in vec2 _texCoord0;
out vec4 _fragColor;
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
DeferredFragment frag = unpackDeferredFragment(_texCoord0);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
@ -30,7 +32,7 @@ void main(void) {
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
_fragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
@ -44,6 +46,6 @@ void main(void) {
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
_fragColor = vec4(color, frag.normalVal.a);
}
}

View file

@ -18,22 +18,22 @@
// the diffuse texture
uniform sampler2D diffuseMap;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec3 color;
in vec4 _position;
in vec4 _normal;
in vec3 _color;
in vec2 _texCoord0;
void main(void) {
// Fetch diffuse map
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
Material mat = getMaterial();
packDeferredFragment(
normalize(interpolatedNormal.xyz),
normalize(_normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -11,6 +11,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
@ -19,27 +21,22 @@ const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// interpolated eye position
varying vec4 interpolatedPosition;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec3 color;
out vec4 _position;
out vec3 _normal;
out vec3 _color;
out vec2 _texCoord0;
void main(void) {
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, gl_Vertex, interpolatedPosition, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
}

View file

@ -23,25 +23,22 @@ uniform sampler2D diffuseMap;
uniform sampler2D emissiveMap;
uniform vec2 emissiveParams;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec3 color;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
out vec4 _position;
out vec2 _texCoord0;
out vec2 _texCoord1;
out vec3 _normal;
out vec3 _color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec4 emissive = texture2D(emissiveMap, interpolatedTexcoord1.st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec4 emissive = texture(emissiveMap, _texCoord1);
Material mat = getMaterial();
packDeferredFragmentLightmap(
normalize(interpolatedNormal.xyz),
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -12,6 +12,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
@ -20,32 +22,23 @@ const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
attribute vec2 texcoord1;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
varying vec3 color;
out vec4 _position;
out vec2 _texCoord0;
out vec2 _texCoord1;
out vec3 _normal;
out vec3 _color;
void main(void) {
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
// interpolatedTexcoord1 = vec2(texcoordMatrices[1] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0)).xy;
interpolatedTexcoord1 = vec2(texcoordMatrices[1] * vec4(texcoord1.xy, 0.0, 1.0)).xy;
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
_texCoord1 = (texcoordMatrices[1] * vec4(inTexCoord1.st, 0.0, 1.0)).st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
}

View file

@ -26,35 +26,32 @@ uniform sampler2D normalMap;
uniform sampler2D emissiveMap;
uniform vec2 emissiveParams;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
in vec4 _position;
in vec2 _texCoord0;
in vec2 _texCoord1;
in vec3 _normal;
in vec3 _tangent;
in vec3 _color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
vec3 normalizedTangent = normalize(vec3(interpolatedTangent));
vec3 normalizedNormal = normalize(_normal);
vec3 normalizedTangent = normalize(_tangent);
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) - vec3(0.5, 0.5, 0.5);
vec3 localNormal = vec3(texture(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5);
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec4 emissive = texture2D(emissiveMap, interpolatedTexcoord1.st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec4 emissive = texture(emissiveMap, _texCoord1);
Material mat = getMaterial();
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -12,6 +12,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
@ -20,41 +22,24 @@ const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the tangent vector
attribute vec3 tangent;
attribute vec2 texcoord1;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
varying vec3 color;
out vec4 _position;
out vec2 _texCoord0;
out vec2 _texCoord1;
out vec3 _normal;
out vec3 _tangent;
out vec3 _color;
void main(void) {
// transform and store the normal and tangent for interpolation
//interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
//interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
interpolatedTexcoord1 = vec2(texcoordMatrices[1] * vec4(texcoord1.xy, 0.0, 1.0)).xy;
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
_texCoord1 = (texcoordMatrices[1] * vec4(inTexCoord1.st, 0.0, 1.0)).st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
<$transformModelToEyeDir(cam, obj, tangent, interpolatedTangent.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
<$transformModelToEyeDir(cam, obj, inTangent.xyz, _tangent)$>
}

View file

@ -29,37 +29,33 @@ uniform sampler2D normalMap;
// the specular map texture
uniform sampler2D specularMap;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
in vec4 _position;
in vec2 _texCoord0;
in vec2 _texCoord1;
in vec3 _normal;
in vec3 _tangent;
in vec3 _color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
vec3 normalizedTangent = normalize(vec3(interpolatedTangent));
vec3 normalizedNormal = normalize(_normal);
vec3 normalizedTangent = normalize(_tangent);
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) - vec3(0.5, 0.5, 0.5);
vec3 localNormal = vec3(texture(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5);
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec3 specular = texture2D(specularMap, gl_TexCoord[0].st).rgb;
vec4 emissive = texture2D(emissiveMap, interpolatedTexcoord1.st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec3 specular = texture(specularMap, _texCoord0).rgb;
vec4 emissive = texture(emissiveMap, _texCoord1);
Material mat = getMaterial();
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -26,25 +26,24 @@ uniform vec2 emissiveParams;
// the specular texture
uniform sampler2D specularMap;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
in vec4 _position;
in vec2 _texCoord0;
in vec2 _texCoord1;
in vec3 _normal;
in vec3 _color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec3 specular = texture2D(specularMap, gl_TexCoord[0].st).rgb;
vec4 emissive = texture2D(emissiveMap, interpolatedTexcoord1.st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec3 specular = texture(specularMap, _texCoord0).rgb;
vec4 emissive = texture(emissiveMap, _texCoord1);
Material mat = getMaterial();
packDeferredFragmentLightmap(
normalize(interpolatedNormal.xyz),
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -22,31 +22,29 @@ uniform sampler2D diffuseMap;
// the normal map texture
uniform sampler2D normalMap;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
in vec4 _position;
in vec4 _texCoord0;
in vec4 _normal;
in vec4 _tangent;
in vec3 _color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
vec3 normalizedTangent = normalize(vec3(interpolatedTangent));
vec3 normalizedNormal = normalize(_normal.xyz);
vec3 normalizedTangent = normalize(_tangent.xyz);
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = normalize(vec3(texture2D(normalMap, gl_TexCoord[0].st)) - vec3(0.5, 0.5, 0.5));
vec3 localNormal = normalize(vec3(texture(normalMap, _texCoord0.st)) - vec3(0.5, 0.5, 0.5));
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec4 diffuse = texture(diffuseMap, _texCoord0.st);
Material mat = getMaterial();
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -2,7 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// model.vert
// model_normal_map.vert
// vertex shader
//
// Created by Andrzej Kapolka on 10/14/13.
@ -12,6 +12,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
@ -20,38 +22,23 @@ const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the tangent vector
attribute vec3 tangent;
// interpolated eye position
varying vec4 interpolatedPosition;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
out vec4 _position;
out vec2 _texCoord0;
out vec3 _normal;
out vec3 _tangent;
out vec3 _color;
void main(void) {
// transform and store the normal and tangent for interpolation
//interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
//interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.rgb;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.xy, 0.0, 1.0)).st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, gl_Vertex, interpolatedPosition, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
<$transformModelToEyeDir(cam, obj, tangent, interpolatedTangent.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
<$transformModelToEyeDir(cam, obj, inTangent.xyz, _tangent)$>
}

View file

@ -25,33 +25,31 @@ uniform sampler2D normalMap;
// the specular map texture
uniform sampler2D specularMap;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
in vec4 _position;
in vec2 _texCoord0;
in vec3 _normal;
in vec3 _tangent;
in vec3 _color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
vec3 normalizedTangent = normalize(vec3(interpolatedTangent));
vec3 normalizedNormal = normalize(_normal);
vec3 normalizedTangent = normalize(_tangent);
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = normalize(vec3(texture2D(normalMap, gl_TexCoord[0].st)) - vec3(0.5, 0.5, 0.5));
vec3 localNormal = normalize(vec3(texture2D(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5));
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec3 specular = texture2D(specularMap, gl_TexCoord[0].st).rgb;
vec4 diffuse = texture2D(diffuseMap, _texCoord0);
vec3 specular = texture2D(specularMap, _texCoord0).rgb;
Material mat = getMaterial();
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -12,7 +12,9 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
out vec4 _fragColor;
void main(void) {
// fixed color for now (we may eventually want to use texture alpha)
gl_FragColor = vec4(1.0, 1.0, 1.0, 0.0);
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
}

View file

@ -1,5 +1,5 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// model_shadow.vert
@ -11,12 +11,16 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
}

View file

@ -22,22 +22,23 @@ uniform sampler2D diffuseMap;
// the specular texture
uniform sampler2D specularMap;
// the interpolated normal
varying vec4 interpolatedNormal;
out vec4 _position;
out vec2 _texCoord0;
out vec3 _normal;
out vec3 _color;
varying vec3 color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec3 specular = texture2D(specularMap, gl_TexCoord[0].st).rgb;
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec3 specular = texture(specularMap, _texCoord0).rgb;
Material mat = getMaterial();
packDeferredFragment(
normalize(interpolatedNormal.xyz),
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialDiffuse(mat) * diffuse.rgb * _color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -11,34 +11,6 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<!/*<@include DeferredBufferWrite.slh@>
<@include model/Material.slh@>
// the diffuse texture
uniform sampler2D diffuseMap;
varying vec4 interpolatedNormal;
varying vec3 color;
void main(void) {
// Fetch diffuse map
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
Material mat = getMaterial();
packDeferredFragmentTranslucent(
normalize(interpolatedNormal.xyz),
getMaterialOpacity(mat) * diffuse.a,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
// set the diffuse data
// gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].st);
}*/!>
<@include model/Material.slh@>
// Everything about global lighting
@ -99,34 +71,31 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 d
// the diffuse texture
uniform sampler2D diffuseMap;
// the interpolated view position
varying vec4 interpolatedPosition;
in vec4 _position;
in vec2 _texCoord0;
in vec3 _normal;
in vec3 _color;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec3 color;
out vec4 _fragColor;
void main(void) {
vec3 fragPosition = interpolatedPosition.xyz;
vec3 fragPosition = _position.xyz;
// Fetch diffuse map
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
vec4 diffuse = texture(diffuseMap, _texCoord0);
Material mat = getMaterial();
vec3 fragNormal = normalize(interpolatedNormal.xyz);
vec3 fragNormal = normalize(_normal);
float fragOpacity = getMaterialOpacity(mat) * diffuse.a;
vec3 fragDiffuse = getMaterialDiffuse(mat) * diffuse.rgb * color;
vec3 fragDiffuse = getMaterialDiffuse(mat) * diffuse.rgb * _color;
vec3 fragSpecular = getMaterialSpecular(mat);
float fragGloss = getMaterialShininess(mat);
vec4 fragColor = evalGlobalColor(1.0,
_fragColor = evalGlobalColor(1.0,
fragPosition,
fragNormal,
fragDiffuse,
fragSpecular,
fragGloss,
fragOpacity);
gl_FragColor = fragColor;
}

View file

@ -2,7 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// spot_light.frag
// point_light.frag
// fragment shader
//
// Created by Andrzej Kapolka on 9/18/14.
@ -24,9 +24,12 @@
// The view Matrix
uniform mat4 invViewMat;
in vec4 _texCoord0;
out vec4 _fragColor;
void main(void) {
// Grab the fragment data from the uv
vec2 texCoord = gl_TexCoord[0].st / gl_TexCoord[0].q;
vec2 texCoord = _texCoord0.st / _texCoord0.q;
DeferredFragment frag = unpackDeferredFragment(texCoord);
// Kill if in front of the light volume
@ -62,14 +65,14 @@ void main(void) {
// Final Lighting color
vec3 fragColor = shading.w * (frag.diffuse + shading.xyz);
gl_FragColor = vec4(fragColor * radialAttenuation * getLightColor(light) * getLightIntensity(light), 0.0);
_fragColor = vec4(fragColor * radialAttenuation * getLightColor(light) * getLightIntensity(light), 0.0);
if (getLightShowContour(light) > 0.0) {
// Show edge
float edge = abs(2.0 * ((getLightRadius(light) - fragLightDistance) / (0.1)) - 1.0);
if (edge < 1) {
float edgeCoord = exp2(-8.0*edge*edge);
gl_FragColor = vec4(edgeCoord * edgeCoord * getLightShowContour(light) * getLightColor(light), 0.0);
_fragColor = vec4(edgeCoord * edgeCoord * getLightShowContour(light) * getLightColor(light), 0.0);
}
}
}

View file

@ -13,14 +13,17 @@
//
<@include DeferredBufferWrite.slh@>
<@include model/Material.slh@>
// the interpolated normal
varying vec4 interpolatedNormal;
in vec3 _normal;
in vec3 _color;
void main(void) {
Material material = getMaterial();
packDeferredFragment(
normalize(interpolatedNormal.xyz),
normalize(_normal.xyz),
glowIntensity,
gl_Color.rgb,
DEFAULT_SPECULAR, DEFAULT_SHININESS);
_color.rgb,
DEFAULT_SPECULAR, DEFAULT_SHININESS);
}

View file

@ -12,24 +12,25 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
// the interpolated normal
varying vec4 interpolatedNormal;
out vec3 _normal;
out vec3 _color;
out vec2 _texCoord0;
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
// pass along the diffuse color
gl_FrontColor = gl_Color;
_color = inColor.rgb;
_texCoord0 = inTexCoord0.st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
}

View file

@ -13,19 +13,23 @@
//
<@include DeferredBufferWrite.slh@>
<@include model/Material.slh@>
// the diffuse texture
uniform sampler2D originalTexture;
// the interpolated normal
varying vec4 interpolatedNormal;
in vec3 _normal;
in vec3 _color;
in vec2 _texCoord0;
void main(void) {
vec4 texel = texture2D(originalTexture, gl_TexCoord[0].st);
Material material = getMaterial();
vec4 texel = texture(originalTexture, _texCoord0);
packDeferredFragment(
normalize(interpolatedNormal.xyz),
glowIntensity * texel.a,
gl_Color.rgb * texel.rgb,
DEFAULT_SPECULAR, DEFAULT_SHININESS);
normalize(_normal.xyz),
glowIntensity * texel.a,
_color.rgb * texel.rgb,
DEFAULT_SPECULAR, DEFAULT_SHININESS);
}

View file

@ -12,7 +12,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
const int MAX_TEXCOORDS = 2;
@ -22,38 +25,31 @@ const int INDICES_PER_VERTEX = 4;
uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
attribute vec4 clusterIndices;
attribute vec4 clusterWeights;
// interpolated eye position
varying vec4 interpolatedPosition;
// the interpolated normal
varying vec4 interpolatedNormal;
varying vec3 color;
out vec4 _position;
out vec2 _texCoord0;
out vec3 _normal;
out vec3 _color;
void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
float clusterWeight = clusterWeights[i];
position += clusterMatrix * gl_Vertex * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
float clusterWeight = inSkinClusterWeight[i].x;
position += clusterMatrix * inPosition * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
}
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.rgb;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, position, interpolatedPosition, gl_Position)$>
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
_normal = interpolatedNormal.xyz;
}

View file

@ -12,7 +12,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
const int MAX_TEXCOORDS = 2;
@ -22,40 +25,29 @@ const int INDICES_PER_VERTEX = 4;
uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the tangent vector
attribute vec3 tangent;
attribute vec4 clusterIndices;
attribute vec4 clusterWeights;
// interpolated eye position
varying vec4 interpolatedPosition;
// the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
out vec4 _position;
out vec2 _texCoord0;
out vec3 _normal;
out vec3 _tangent;
out vec3 _color;
void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
float clusterWeight = clusterWeights[i];
position += clusterMatrix * gl_Vertex * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight;
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
float clusterWeight = inSkinClusterWeight[i].x;
position += clusterMatrix * inPosition * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
interpolatedTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight;
}
// pass along the diffuse color
color = gl_Color.xyz;
_color = inColor.rgb;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
_texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st;
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
@ -63,10 +55,10 @@ void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, position, interpolatedPosition, gl_Position)$>
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
<$transformModelToEyeDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
_normal = interpolatedNormal.xyz;
_tangent = interpolatedTangent.xyz;
}

View file

@ -24,9 +24,12 @@
// The view Matrix
uniform mat4 invViewMat;
in vec4 _texCoord0;
out vec4 _fragColor;
void main(void) {
// Grab the fragment data from the uv
vec2 texCoord = gl_TexCoord[0].st / gl_TexCoord[0].q;
vec2 texCoord = _texCoord0.st / _texCoord0.q;
DeferredFragment frag = unpackDeferredFragment(texCoord);
// Kill if in front of the light volume
@ -70,7 +73,7 @@ void main(void) {
// Final Lighting color
vec3 fragColor = shading.w * (frag.diffuse + shading.xyz);
gl_FragColor = vec4(fragColor * angularAttenuation * radialAttenuation * getLightColor(light) * getLightIntensity(light), 0.0);
_fragColor = vec4(fragColor * angularAttenuation * radialAttenuation * getLightColor(light) * getLightIntensity(light), 0.0);
if (getLightShowContour(light) > 0.0) {
// Show edges
@ -80,7 +83,7 @@ void main(void) {
float edge = abs(2.0 * (edgeDist / (0.1)) - 1.0);
if (edge < 1) {
float edgeCoord = exp2(-8.0*edge*edge);
gl_FragColor = vec4(edgeCoord * edgeCoord * getLightColor(light), 0.0);
_fragColor = vec4(edgeCoord * edgeCoord * getLightColor(light), 0.0);
}
}
}

View file

@ -14,11 +14,14 @@
// the texture
uniform sampler2D colorMap;
varying vec2 varTexcoord;
varying vec4 varColor;
in vec3 _position;
in vec3 _normal;
in vec2 _texCoord0;
in vec4 _color;
out vec4 _fragColor;
void main(void) {
vec4 color = texture2D(colorMap, varTexcoord);
gl_FragColor = color * varColor;
vec4 color = texture(colorMap, _texCoord0);
_fragColor = color * _color;
}

View file

@ -12,24 +12,25 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
varying vec3 varPosition;
varying vec3 varNormal;
varying vec2 varTexcoord;
varying vec4 varColor;
out vec3 _position;
out vec3 _normal;
out vec2 _texCoord0;
out vec4 _color;
void main(void) {
varTexcoord = gl_MultiTexCoord0.xy;
varColor = gl_Color;
_texCoord0 = inTexCoord0.st;
_color = inColor;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
<$transformModelToEyeDir(cam, obj, gl_Normal, varNormal)$>
varNormal = normalize(varNormal);
varPosition = gl_Vertex.xyz;
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
_position = inPosition.xyz;
}

View file

@ -10,4 +10,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(render-utils gpu shared)
copy_dlls_beside_windows_executable()
include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/")
message(${PROJECT_BINARY_DIR})
copy_dlls_beside_windows_executable()

View file

@ -11,11 +11,10 @@
#include <unordered_map>
#include <memory>
#include <glm/glm.hpp>
#include <mutex>
#include <QApplication>
#include <QDir>
#include <QElapsedTimer>
#include <QWindow>
#include <QtGlobal>
#include <QFile>
#include <QImage>
#include <QLoggingCategory>
@ -33,11 +32,64 @@
#include <QTime>
#include <QTimer>
#include <QWindow>
#include <QElapsedTimer>
#include <QDir>
#include <QGuiApplication>
#include <PathUtils.h>
#include "gpu/Batch.h"
#include "gpu/Context.h"
#include "../model/Skybox_vert.h"
#include "..//model/Skybox_frag.h"
#include "simple_vert.h"
#include "simple_frag.h"
#include "simple_textured_frag.h"
#include "deferred_light_vert.h"
#include "deferred_light_limited_vert.h"
#include "directional_light_frag.h"
#include "directional_light_shadow_map_frag.h"
#include "directional_light_cascaded_shadow_map_frag.h"
#include "directional_ambient_light_frag.h"
#include "directional_ambient_light_shadow_map_frag.h"
#include "directional_ambient_light_cascaded_shadow_map_frag.h"
#include "directional_skybox_light_frag.h"
#include "directional_skybox_light_shadow_map_frag.h"
#include "directional_skybox_light_cascaded_shadow_map_frag.h"
#include "point_light_frag.h"
#include "spot_light_frag.h"
#include "standardTransformPNTC_vert.h"
#include "standardDrawTexture_frag.h"
#include "model_vert.h"
#include "model_shadow_vert.h"
#include "model_normal_map_vert.h"
#include "model_lightmap_vert.h"
#include "model_lightmap_normal_map_vert.h"
#include "skin_model_vert.h"
#include "skin_model_shadow_vert.h"
#include "skin_model_normal_map_vert.h"
#include "model_frag.h"
#include "model_shadow_frag.h"
#include "model_normal_map_frag.h"
#include "model_normal_specular_map_frag.h"
#include "model_specular_map_frag.h"
#include "model_lightmap_frag.h"
#include "model_lightmap_normal_map_frag.h"
#include "model_lightmap_normal_specular_map_frag.h"
#include "model_lightmap_specular_map_frag.h"
#include "model_translucent_frag.h"
class RateCounter {
std::vector<float> times;
QElapsedTimer timer;
@ -111,8 +163,8 @@ public:
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
format.setDepthBufferSize(16);
format.setStencilBufferSize(8);
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
format.setVersion(4, 1);
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
setFormat(format);
@ -153,7 +205,7 @@ public:
makeCurrent();
setFramePosition(QPoint(-1000, 0));
// setFramePosition(QPoint(-1000, 0));
resize(QSize(800, 600));
}
@ -184,6 +236,13 @@ static const glm::vec3 COLORS[4] = { { 1.0, 1.0, 1.0 }, { 0.5, 1.0, 0.5 }, {
1.0, 0.5, 0.5 }, { 0.5, 0.5, 1.0 } };
void testShaderBuild(const char* vs_src, const char * fs_src) {
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(vs_src)));
auto fs = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(fs_src)));
auto pr = gpu::ShaderPointer(gpu::Shader::createProgram(vs, fs));
gpu::Shader::makeProgram(*pr);
}
void QTestWindow::draw() {
if (!isVisible()) {
return;
@ -193,6 +252,46 @@ void QTestWindow::draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
static std::once_flag once;
std::call_once(once, [&]{
testShaderBuild(Skybox_vert, Skybox_frag);
testShaderBuild(simple_vert, simple_frag);
testShaderBuild(simple_vert, simple_textured_frag);
testShaderBuild(deferred_light_vert, directional_light_frag);
testShaderBuild(deferred_light_vert, directional_light_shadow_map_frag);
testShaderBuild(deferred_light_vert, directional_light_cascaded_shadow_map_frag);
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
testShaderBuild(deferred_light_vert, directional_ambient_light_shadow_map_frag);
testShaderBuild(deferred_light_vert, directional_ambient_light_cascaded_shadow_map_frag);
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
testShaderBuild(deferred_light_vert, directional_skybox_light_shadow_map_frag);
testShaderBuild(deferred_light_vert, directional_skybox_light_cascaded_shadow_map_frag);
testShaderBuild(deferred_light_limited_vert, point_light_frag);
testShaderBuild(deferred_light_limited_vert, spot_light_frag);
testShaderBuild(standardTransformPNTC_vert, standardDrawTexture_frag);
testShaderBuild(model_vert, model_frag);
testShaderBuild(model_normal_map_vert, model_normal_map_frag);
testShaderBuild(model_vert, model_specular_map_frag);
testShaderBuild(model_normal_map_vert, model_normal_specular_map_frag);
testShaderBuild(model_vert, model_translucent_frag);
testShaderBuild(model_normal_map_vert, model_translucent_frag);
testShaderBuild(model_lightmap_vert, model_lightmap_frag);
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_map_frag);
testShaderBuild(model_lightmap_vert, model_lightmap_specular_map_frag);
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_specular_map_frag);
testShaderBuild(skin_model_vert, model_frag);
testShaderBuild(skin_model_normal_map_vert, model_normal_map_frag);
testShaderBuild(skin_model_vert, model_specular_map_frag);
testShaderBuild(skin_model_normal_map_vert, model_normal_specular_map_frag);
testShaderBuild(skin_model_vert, model_translucent_frag);
testShaderBuild(skin_model_normal_map_vert, model_translucent_frag);
testShaderBuild(model_shadow_vert, model_shadow_frag);
});
// renderText();
_context->swapBuffers(this);
glFinish();
@ -203,8 +302,26 @@ void QTestWindow::draw() {
}
}
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
if (!message.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(message.toLocal8Bit().constData());
OutputDebugStringA("\n");
#else
std::cout << message.toLocal8Bit().constData() << std::endl;
#endif
}
}
const char * LOG_FILTER_RULES = R"V0G0N(
hifi.gpu=true
)V0G0N";
int main(int argc, char** argv) {
QGuiApplication app(argc, argv);
qInstallMessageHandler(messageHandler);
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
QTestWindow window;
QTimer timer;
timer.setInterval(1);

View file

@ -188,7 +188,6 @@ int main (int argc, char** argv) {
std::ostringstream targetStringStream;
if (makeCPlusPlus) {
targetStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl;
targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl;
targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl;