diff --git a/interface/src/ui/overlays/Circle3DOverlay.cpp b/interface/src/ui/overlays/Circle3DOverlay.cpp index 53f1b4ce21..3356c528f1 100644 --- a/interface/src/ui/overlays/Circle3DOverlay.cpp +++ b/interface/src/ui/overlays/Circle3DOverlay.cpp @@ -145,7 +145,8 @@ void Circle3DOverlay::render(RenderArgs* args) { geometryCache->updateVertices(_quadVerticesID, points, color); } - geometryCache->renderVertices(batch, gpu::QUAD_STRIP, _quadVerticesID); + // FIXME CORE + // geometryCache->renderVertices(batch, gpu::QUAD_STRIP, _quadVerticesID); } else { if (_lineVerticesID == GeometryCache::UNKNOWN_ID) { diff --git a/libraries/entities-renderer/src/textured_particle.slf b/libraries/entities-renderer/src/textured_particle.slf index 543aa643aa..58a3103323 100644 --- a/libraries/entities-renderer/src/textured_particle.slf +++ b/libraries/entities-renderer/src/textured_particle.slf @@ -11,10 +11,12 @@ uniform sampler2D colorMap; -varying vec4 varColor; -varying vec2 varTexCoord; +in vec4 _color; +in vec2 _texCoord0; + +out vec4 outFragColor; void main(void) { - vec4 color = texture2D(colorMap, varTexCoord); - gl_FragColor = color * varColor; + vec4 color = texture(colorMap, _texCoord0); + outFragColor = color * _color; } diff --git a/libraries/entities-renderer/src/textured_particle.slv b/libraries/entities-renderer/src/textured_particle.slv index 7564feb1ce..c741af559d 100644 --- a/libraries/entities-renderer/src/textured_particle.slv +++ b/libraries/entities-renderer/src/textured_particle.slv @@ -10,19 +10,21 @@ // 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 vec4 varColor; -varying vec2 varTexCoord; +out vec4 _color; +out vec2 _texCoord0; void main(void) { // pass along the color & uvs to fragment shader - varColor = gl_Color; - varTexCoord = gl_MultiTexCoord0.xy; + _color = inColor; + _texCoord0 = inTexCoord0.xy; TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> } diff --git a/libraries/entities-renderer/src/untextured_particle.slf b/libraries/entities-renderer/src/untextured_particle.slf index bb3ed77e3f..11f25bb693 100644 --- a/libraries/entities-renderer/src/untextured_particle.slf +++ b/libraries/entities-renderer/src/untextured_particle.slf @@ -9,8 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -varying vec4 varColor; +in vec4 _color; + +out vec4 outFragColor; void main(void) { - gl_FragColor = varColor; + outFragColor = _color; } diff --git a/libraries/entities-renderer/src/untextured_particle.slv b/libraries/entities-renderer/src/untextured_particle.slv index 2975dab046..3d1d99c0dc 100644 --- a/libraries/entities-renderer/src/untextured_particle.slv +++ b/libraries/entities-renderer/src/untextured_particle.slv @@ -8,17 +8,19 @@ // 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 vec4 varColor; +out vec4 _color; void main(void) { // pass along the diffuse color - varColor = gl_Color; + _color = inColor; TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> } \ No newline at end of file diff --git a/libraries/gpu/src/gpu/DrawColoredTexture.slf b/libraries/gpu/src/gpu/DrawColoredTexture.slf index b60c7d9575..5460cf56eb 100755 --- a/libraries/gpu/src/gpu/DrawColoredTexture.slf +++ b/libraries/gpu/src/gpu/DrawColoredTexture.slf @@ -15,8 +15,9 @@ uniform sampler2D colorMap; uniform vec4 color; -varying vec2 varTexcoord; +in vec2 varTexcoord; +out vec4 outFragColor; void main(void) { - gl_FragColor = texture2D(colorMap, varTexcoord) * color; + outFragColor = texture(colorMap, varTexcoord) * color; } diff --git a/libraries/gpu/src/gpu/DrawTexcoordRectTransformUnitQuad.slv b/libraries/gpu/src/gpu/DrawTexcoordRectTransformUnitQuad.slv index 284f68dd93..e0ca81cb61 100755 --- a/libraries/gpu/src/gpu/DrawTexcoordRectTransformUnitQuad.slv +++ b/libraries/gpu/src/gpu/DrawTexcoordRectTransformUnitQuad.slv @@ -19,7 +19,7 @@ uniform vec4 texcoordRect; -varying vec2 varTexcoord; +out vec2 varTexcoord; void main(void) { const vec4 UNIT_QUAD[4] = vec4[4]( diff --git a/libraries/gpu/src/gpu/DrawTexture.slf b/libraries/gpu/src/gpu/DrawTexture.slf index e456c49649..cfa18abc27 100755 --- a/libraries/gpu/src/gpu/DrawTexture.slf +++ b/libraries/gpu/src/gpu/DrawTexture.slf @@ -14,8 +14,9 @@ uniform sampler2D colorMap; -varying vec2 varTexcoord; +in vec2 varTexcoord; +out vec4 outFragColor; void main(void) { - gl_FragColor = texture2D(colorMap, varTexcoord); + outFragColor = texture(colorMap, varTexcoord); } diff --git a/libraries/gpu/src/gpu/DrawTextureOpaque.slf b/libraries/gpu/src/gpu/DrawTextureOpaque.slf index 1ce3a34c02..b6539e7de2 100755 --- a/libraries/gpu/src/gpu/DrawTextureOpaque.slf +++ b/libraries/gpu/src/gpu/DrawTextureOpaque.slf @@ -15,8 +15,9 @@ uniform sampler2D colorMap; -varying vec2 varTexcoord; +in vec2 varTexcoord; +out vec4 outFragColor; void main(void) { - gl_FragColor = vec4(texture2D(colorMap, varTexcoord).xyz, 1.0); + outFragColor = vec4(texture(colorMap, varTexcoord).xyz, 1.0); } diff --git a/libraries/gpu/src/gpu/DrawTransformUnitQuad.slv b/libraries/gpu/src/gpu/DrawTransformUnitQuad.slv index 2d1e4584a7..24e0cc25f3 100755 --- a/libraries/gpu/src/gpu/DrawTransformUnitQuad.slv +++ b/libraries/gpu/src/gpu/DrawTransformUnitQuad.slv @@ -16,7 +16,7 @@ <$declareStandardTransform()$> -varying vec2 varTexcoord; +out vec2 varTexcoord; void main(void) { const vec4 UNIT_QUAD[4] = vec4[4]( diff --git a/libraries/gpu/src/gpu/DrawViewportQuadTransformTexcoord.slv b/libraries/gpu/src/gpu/DrawViewportQuadTransformTexcoord.slv index e91b8a7644..81af3ffaf8 100755 --- a/libraries/gpu/src/gpu/DrawViewportQuadTransformTexcoord.slv +++ b/libraries/gpu/src/gpu/DrawViewportQuadTransformTexcoord.slv @@ -16,7 +16,7 @@ <$declareStandardTransform()$> -varying vec2 varTexcoord; +out vec2 varTexcoord; void main(void) { const vec4 UNIT_QUAD[4] = vec4[4]( diff --git a/libraries/gpu/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h index 981a560965..697111a990 100644 --- a/libraries/gpu/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -213,8 +213,6 @@ enum Primitive { TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, - QUADS, - QUAD_STRIP, NUM_PRIMITIVES, }; diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index c74a94e03e..1eb9fd5167 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -74,14 +74,18 @@ void GLBackend::init() { qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); -#ifdef WIN32 +#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) + glewExperimental = true; GLenum err = glewInit(); + glGetError(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err)); } qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); +#endif +#if defined(Q_OS_WIN) if (wglewGetExtension("WGL_EXT_swap_control")) { int swapInterval = wglGetSwapIntervalEXT(); qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); @@ -89,13 +93,6 @@ void GLBackend::init() { #endif #if defined(Q_OS_LINUX) - GLenum err = glewInit(); - if (GLEW_OK != err) { - /* Problem: glewInit failed, something is seriously wrong. */ - qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err)); - } - qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); - // TODO: Write the correct code for Linux... /* if (wglewGetExtension("WGL_EXT_swap_control")) { int swapInterval = wglGetSwapIntervalEXT(); @@ -200,7 +197,6 @@ void GLBackend::do_draw(Batch& batch, uint32 paramOffset) { GLenum mode = _primitiveToGLmode[primitiveType]; uint32 numVertices = batch._params[paramOffset + 1]._uint; uint32 startVertex = batch._params[paramOffset + 0]._uint; - glDrawArrays(mode, startVertex, numVertices); (void) CHECK_GL_ERROR(); } @@ -510,6 +506,7 @@ void Batch::_glLineWidth(GLfloat width) { DO_IT_NOW(_glLineWidth, 1); } void GLBackend::do_glLineWidth(Batch& batch, uint32 paramOffset) { - glLineWidth(batch._params[paramOffset]._float); + // FIXME CORE + //glLineWidth(batch._params[paramOffset]._float); (void) CHECK_GL_ERROR(); } diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index c0bae76d78..ccfbf4af85 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -327,8 +327,6 @@ protected: bool _invalidProj; bool _invalidViewport; - GLenum _lastMode; - TransformStageState() : _transformObjectBuffer(0), _transformCameraBuffer(0), @@ -339,8 +337,7 @@ protected: _invalidModel(true), _invalidView(true), _invalidProj(false), - _invalidViewport(false), - _lastMode(GL_TEXTURE) {} + _invalidViewport(false) {} } _transform; // Uniform Stage diff --git a/libraries/gpu/src/gpu/GLBackendShader.cpp b/libraries/gpu/src/gpu/GLBackendShader.cpp index 3eb6eabbff..ef800ff314 100755 --- a/libraries/gpu/src/gpu/GLBackendShader.cpp +++ b/libraries/gpu/src/gpu/GLBackendShader.cpp @@ -35,71 +35,44 @@ void makeBindings(GLBackend::GLShader* shader) { GLint loc = -1; //Check for gpu specific attribute slotBindings - loc = glGetAttribLocation(glprogram, "position"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::POSITION, "position"); + loc = glGetAttribLocation(glprogram, "inPosition"); + if (loc >= 0 && loc != gpu::Stream::POSITION) { + glBindAttribLocation(glprogram, gpu::Stream::POSITION, "inPosition"); } - loc = glGetAttribLocation(glprogram, "attribPosition"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::POSITION, "attribPosition"); + loc = glGetAttribLocation(glprogram, "inNormal"); + if (loc >= 0 && loc != gpu::Stream::NORMAL) { + glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "inNormal"); } - //Check for gpu specific attribute slotBindings - loc = glGetAttribLocation(glprogram, "gl_Vertex"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::POSITION, "gl_Vertex"); + loc = glGetAttribLocation(glprogram, "inColor"); + if (loc >= 0 && loc != gpu::Stream::COLOR) { + glBindAttribLocation(glprogram, gpu::Stream::COLOR, "inColor"); } - loc = glGetAttribLocation(glprogram, "normal"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "normal"); - } - loc = glGetAttribLocation(glprogram, "attribNormal"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "attribNormal"); + loc = glGetAttribLocation(glprogram, "inTexCoord0"); + if (loc >= 0 && loc != gpu::Stream::TEXCOORD) { + glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "inTexCoord0"); } - loc = glGetAttribLocation(glprogram, "color"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::COLOR, "color"); - } - loc = glGetAttribLocation(glprogram, "attribColor"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::COLOR, "attribColor"); + loc = glGetAttribLocation(glprogram, "inTangent"); + if (loc >= 0 && loc != gpu::Stream::TANGENT) { + glBindAttribLocation(glprogram, gpu::Stream::TANGENT, "inTangent"); } - loc = glGetAttribLocation(glprogram, "texcoord"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "texcoord"); - } - loc = glGetAttribLocation(glprogram, "attribTexcoord"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "attribTexcoord"); - } - - loc = glGetAttribLocation(glprogram, "tangent"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::TANGENT, "tangent"); + loc = glGetAttribLocation(glprogram, "inTexCoord1"); + if (loc >= 0 && loc != gpu::Stream::TEXCOORD1) { + glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "inTexCoord1"); } - loc = glGetAttribLocation(glprogram, "texcoord1"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "texcoord1"); - } - loc = glGetAttribLocation(glprogram, "attribTexcoord1"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "texcoord1"); + loc = glGetAttribLocation(glprogram, "inSkinClusterIndex"); + if (loc >= 0 && loc != gpu::Stream::SKIN_CLUSTER_INDEX) { + glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_INDEX, "inSkinClusterIndex"); } - loc = glGetAttribLocation(glprogram, "clusterIndices"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_INDEX, "clusterIndices"); - } - - loc = glGetAttribLocation(glprogram, "clusterWeights"); - if (loc >= 0) { - glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_WEIGHT, "clusterWeights"); + loc = glGetAttribLocation(glprogram, "inSkinClusterWeight"); + if (loc >= 0 && loc != gpu::Stream::SKIN_CLUSTER_WEIGHT) { + glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_WEIGHT, "inSkinClusterWeight"); } // Link again to take into account the assigned attrib location @@ -114,7 +87,6 @@ void makeBindings(GLBackend::GLShader* shader) { // now assign the ubo binding, then DON't relink! //Check for gpu specific uniform slotBindings -#if (GPU_TRANSFORM_PROFILE == GPU_CORE) loc = glGetUniformBlockIndex(glprogram, "transformObjectBuffer"); if (loc >= 0) { glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_OBJECT_SLOT); @@ -126,22 +98,6 @@ void makeBindings(GLBackend::GLShader* shader) { glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT); shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT; } -#else - loc = glGetUniformLocation(glprogram, "transformObject_model"); - if (loc >= 0) { - shader->_transformObject_model = loc; - } - - loc = glGetUniformLocation(glprogram, "transformCamera_viewInverse"); - if (loc >= 0) { - shader->_transformCamera_viewInverse = loc; - } - - loc = glGetUniformLocation(glprogram, "transformCamera_viewport"); - if (loc >= 0) { - shader->_transformCamera_viewport = loc; - } -#endif } GLBackend::GLShader* compileShader(const Shader& shader) { @@ -635,8 +591,6 @@ bool isUnusedSlot(GLint binding) { int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindings, Shader::SlotSet& buffers) { GLint buffersCount = 0; -#if (GPU_FEATURE_PROFILE == GPU_CORE) - glGetProgramiv(glprogram, GL_ACTIVE_UNIFORM_BLOCKS, &buffersCount); // fast exit @@ -689,7 +643,6 @@ int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindin Element element(SCALAR, gpu::UINT32, gpu::UNIFORM_BUFFER); buffers.insert(Shader::Slot(name, binding, element, Resource::BUFFER)); } -#endif return buffersCount; } @@ -750,11 +703,7 @@ bool GLBackend::makeProgram(Shader& shader, const Shader::BindingSet& slotBindin Shader::SlotSet uniforms; Shader::SlotSet textures; Shader::SlotSet samplers; -#if (GPU_FEATURE_PROFILE == GPU_CORE) makeUniformSlots(object->_program, slotBindings, uniforms, textures, samplers); -#else - makeUniformSlots(object->_program, slotBindings, uniforms, textures, samplers, buffers); -#endif Shader::SlotSet inputs; makeInputSlots(object->_program, slotBindings, inputs); diff --git a/libraries/gpu/src/gpu/GLBackendShared.h b/libraries/gpu/src/gpu/GLBackendShared.h index 888fd1164d..7ce54665be 100644 --- a/libraries/gpu/src/gpu/GLBackendShared.h +++ b/libraries/gpu/src/gpu/GLBackendShared.h @@ -23,8 +23,6 @@ static const GLenum _primitiveToGLmode[gpu::NUM_PRIMITIVES] = { GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, - GL_QUADS, - GL_QUAD_STRIP, }; static const GLenum _elementTypeToGLType[gpu::NUM_TYPES] = { diff --git a/libraries/gpu/src/gpu/GLBackendState.cpp b/libraries/gpu/src/gpu/GLBackendState.cpp index 22c61b2365..a74f269fb3 100644 --- a/libraries/gpu/src/gpu/GLBackendState.cpp +++ b/libraries/gpu/src/gpu/GLBackendState.cpp @@ -484,7 +484,8 @@ void GLBackend::syncPipelineStateCache() { glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // Point size is always on - glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + // FIXME CORE + //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glEnable(GL_PROGRAM_POINT_SIZE_EXT); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); @@ -582,11 +583,12 @@ void GLBackend::do_setStateMultisampleEnable(bool enable) { void GLBackend::do_setStateAntialiasedLineEnable(bool enable) { if (_pipeline._stateCache.antialisedLineEnable != enable) { + // FIXME CORE if (enable) { - glEnable(GL_POINT_SMOOTH); + // glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); } else { - glDisable(GL_POINT_SMOOTH); + // glDisable(GL_POINT_SMOOTH); glDisable(GL_LINE_SMOOTH); } (void) CHECK_GL_ERROR(); diff --git a/libraries/gpu/src/gpu/GLBackendTransform.cpp b/libraries/gpu/src/gpu/GLBackendTransform.cpp index e05e0fc1c0..735f9a6b34 100755 --- a/libraries/gpu/src/gpu/GLBackendTransform.cpp +++ b/libraries/gpu/src/gpu/GLBackendTransform.cpp @@ -73,14 +73,7 @@ void GLBackend::syncTransformStateCache() { glGetIntegerv(GL_VIEWPORT, (GLint*) &_transform._viewport); - GLint currentMode; - glGetIntegerv(GL_MATRIX_MODE, ¤tMode); - _transform._lastMode = currentMode; - - glGetFloatv(GL_PROJECTION_MATRIX, (float*) &_transform._projection); - Mat4 modelView; - glGetFloatv(GL_MODELVIEW_MATRIX, (float*) &modelView); auto modelViewInv = glm::inverse(modelView); _transform._view.evalFromRawMatrix(modelViewInv); _transform._model.setIdentity(); diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index 5590c4cc8d..c442a314fc 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -21,8 +21,8 @@ #include #include -#define GPU_FEATURE_PROFILE GPU_LEGACY -#define GPU_TRANSFORM_PROFILE GPU_LEGACY +#define GPU_FEATURE_PROFILE GPU_CORE +#define GPU_TRANSFORM_PROFILE GPU_CORE #elif defined(WIN32) #include diff --git a/libraries/gpu/src/gpu/Inputs.slh b/libraries/gpu/src/gpu/Inputs.slh index 49511ca8d2..843d1059f2 100644 --- a/libraries/gpu/src/gpu/Inputs.slh +++ b/libraries/gpu/src/gpu/Inputs.slh @@ -18,6 +18,4 @@ 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@> diff --git a/libraries/model/src/model/Atmosphere.slh b/libraries/model/src/model/Atmosphere.slh index cc1b7017b0..0af5fa27f3 100755 --- a/libraries/model/src/model/Atmosphere.slh +++ b/libraries/model/src/model/Atmosphere.slh @@ -6,53 +6,53 @@ // // 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 MODEL_ATMOSPHERE_SLH@> -<@def MODEL_ATMOSPHERE_SLH@> - - - +<@def MODEL_ATMOSPHERE_SLH@> + + + struct Atmosphere { vec4 _invWaveLength; vec4 _radiuses; vec4 _scales; vec4 _scatterings; vec4 _control; -}; - -const int numSamples = 2; +}; + +const int numSamples = 2; vec3 getAtmosphereInvWaveLength(Atmosphere a) { return a._invWaveLength.xyz; } // 1 / pow(wavelength, 4) for the red, green, and blue channels @@ -68,88 +68,88 @@ float getAtmosphereKrESun(Atmosphere a) { return a._scatterings.x; } // Kr * ESu float getAtmosphereKmESun(Atmosphere a) { return a._scatterings.y; } // Km * ESun float getAtmosphereKr4PI(Atmosphere a) { return a._scatterings.z; } // Kr * 4 * PI float getAtmosphereKm4PI(Atmosphere a) { return a._scatterings.w; } // Km * 4 * PI - + float getAtmosphereNumSamples(Atmosphere a) { return a._control.x; } // numSamples vec2 getAtmosphereGAndG2(Atmosphere a) { return a._control.yz; } // g and g2 -float atmosphereScale(float scaleDepth, float fCos) -{ - float x = 1.0 - fCos; - return scaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25)))); -} - -vec4 evalAtmosphereContribution(Atmosphere atmospheric, vec3 position, vec3 cameraPos, vec3 lightPos) { - float fInnerRadius = getAtmosphereInnerRadius(atmospheric); - float fSamples = getAtmosphereNumSamples(atmospheric); - - vec3 v3InvWavelength = getAtmosphereInvWaveLength(atmospheric); - vec4 scatteringCoefs = getAtmosphereScattering(atmospheric); - float fKrESun = scatteringCoefs.x; - float fKmESun = scatteringCoefs.y; - float fKr4PI = scatteringCoefs.z; - float fKm4PI = scatteringCoefs.w; - - vec2 gAndg2 = getAtmosphereGAndG2(atmospheric); - float g = gAndg2.x; - float g2 = gAndg2.y; - - float fScale = getAtmosphereScale(atmospheric); - float fScaleDepth = getAtmosphereScaleDepth(atmospheric); - float fScaleOverScaleDepth = getAtmosphereScaleOverScaleDepth(atmospheric); - - // Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere) - vec3 v3Pos = position; - vec3 v3Ray = v3Pos - cameraPos; - float fFar = length(v3Ray); - v3Ray /= fFar; - - // Calculate the ray's starting position, then calculate its scattering offset - vec3 v3Start = cameraPos; - float fHeight = length(v3Start); - float fDepthStart = exp(fScaleOverScaleDepth * (fInnerRadius - fHeight)); - float fStartAngle = dot(v3Ray, v3Start) / fHeight; - float fStartOffset = fDepthStart * atmosphereScale(fScaleDepth, fStartAngle); - - // Initialize the scattering loop variables - //gl_FrontColor = vec4(0.0, 0.0, 0.0, 0.0); - float fSampleLength = fFar / fSamples; - float fScaledLength = fSampleLength * fScale; - - vec3 v3SampleRay = v3Ray * fSampleLength; - vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5; - - // Now loop through the sample rays - vec3 v3FrontColor = vec3(0.0, 0.0, 0.0); - // int nSamples = numSamples; - int nSamples = int(fSamples); - for(int i=0; i uniform atmosphereBuffer { @@ -171,75 +171,75 @@ Atmosphere getAtmosphere() { return atmosphere; } <@endif@> - - - + + + <@endif@> diff --git a/libraries/render-utils/src/DeferredBuffer.slh b/libraries/render-utils/src/DeferredBuffer.slh index 885fa96543..b9112def10 100755 --- a/libraries/render-utils/src/DeferredBuffer.slh +++ b/libraries/render-utils/src/DeferredBuffer.slh @@ -50,10 +50,10 @@ struct DeferredFragment { DeferredFragment unpackDeferredFragment(vec2 texcoord) { DeferredFragment frag; - frag.depthVal = texture2D(depthMap, texcoord).r; - frag.normalVal = texture2D(normalMap, texcoord); - frag.diffuseVal = texture2D(diffuseMap, texcoord); - frag.specularVal = texture2D(specularMap, texcoord); + frag.depthVal = texture(depthMap, texcoord).r; + frag.normalVal = texture(normalMap, texcoord); + frag.diffuseVal = texture(diffuseMap, texcoord); + frag.specularVal = texture(specularMap, texcoord); // compute the view space position using the depth float z = near / (frag.depthVal * depthScale - 1.0); diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index 9bb2208b40..fe8e74361a 100755 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -16,7 +16,9 @@ uniform samplerCube skyboxMap; vec4 evalSkyboxLight(vec3 direction, float lod) { - vec4 skytexel = textureLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap)); + // FIXME + //vec4 skytexel = textureLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap)); + vec4 skytexel = texture(skyboxMap, direction); return skytexel; } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index def5f38db4..edc6b4601b 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1040,8 +1040,9 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co float vertexBuffer[vertices * FLOATS_PER_VERTEX] = { minCorner.x, minCorner.y, maxCorner.x, minCorner.y, + minCorner.x, maxCorner.y, maxCorner.x, maxCorner.y, - minCorner.x, maxCorner.y }; + }; const int NUM_COLOR_SCALARS_PER_QUAD = 4; int compactColor = ((int(color.x * 255.0f) & 0xFF)) | @@ -1057,7 +1058,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co batch.setInputFormat(details.streamFormat); batch.setInputStream(0, *details.stream); - batch.draw(gpu::QUADS, 4, 0); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); } void GeometryCache::renderUnitCube(gpu::Batch& batch) { @@ -1133,8 +1134,9 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co float vertexBuffer[vertices * FLOATS_PER_VERTEX] = { minCorner.x, minCorner.y, texCoordMinCorner.x, texCoordMinCorner.y, maxCorner.x, minCorner.y, texCoordMaxCorner.x, texCoordMinCorner.y, + minCorner.x, maxCorner.y, texCoordMinCorner.x, texCoordMaxCorner.y, maxCorner.x, maxCorner.y, texCoordMaxCorner.x, texCoordMaxCorner.y, - minCorner.x, maxCorner.y, texCoordMinCorner.x, texCoordMaxCorner.y }; + }; const int NUM_COLOR_SCALARS_PER_QUAD = 4; @@ -1151,7 +1153,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co batch.setInputFormat(details.streamFormat); batch.setInputStream(0, *details.stream); - batch.draw(gpu::QUADS, 4, 0); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); } void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { @@ -1205,8 +1207,9 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co float vertexBuffer[vertices * FLOATS_PER_VERTEX] = { minCorner.x, minCorner.y, minCorner.z, maxCorner.x, minCorner.y, minCorner.z, + minCorner.x, maxCorner.y, maxCorner.z, maxCorner.x, maxCorner.y, maxCorner.z, - minCorner.x, maxCorner.y, maxCorner.z }; + }; const int NUM_COLOR_SCALARS_PER_QUAD = 4; int compactColor = ((int(color.x * 255.0f) & 0xFF)) | @@ -1222,7 +1225,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co batch.setInputFormat(details.streamFormat); batch.setInputStream(0, *details.stream); - batch.draw(gpu::QUADS, 4, 0); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); } void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, @@ -1296,9 +1299,9 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons float vertexBuffer[vertices * FLOATS_PER_VERTEX] = { - topLeft.x, topLeft.y, topLeft.z, texCoordTopLeft.x, texCoordTopLeft.y, bottomLeft.x, bottomLeft.y, bottomLeft.z, texCoordBottomLeft.x, texCoordBottomLeft.y, bottomRight.x, bottomRight.y, bottomRight.z, texCoordBottomRight.x, texCoordBottomRight.y, + topLeft.x, topLeft.y, topLeft.z, texCoordTopLeft.x, texCoordTopLeft.y, topRight.x, topRight.y, topRight.z, texCoordTopRight.x, texCoordTopRight.y, }; @@ -1315,7 +1318,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons batch.setInputFormat(details.streamFormat); batch.setInputStream(0, *details.stream); - batch.draw(gpu::QUADS, 4, 0); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); } void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 1e4f3f7190..3bf7cee6c8 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -2096,7 +2096,8 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran } if (part.quadIndices.size() > 0) { - batch.drawIndexed(gpu::QUADS, part.quadIndices.size(), offset); + // FIXME CORE + // batch.drawIndexed(gpu::QUADS, part.quadIndices.size(), offset); offset += part.quadIndices.size() * sizeof(int); } diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 4bed667e38..decb434177 100755 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -93,7 +93,7 @@ float evalShadowAttenuationPCF(vec4 shadowTexcoord) { )); } - return shadowAttenuation; + return shadowAttenuation; } float evalShadowAttenuationBasic(vec4 shadowTexcoord) { @@ -104,11 +104,11 @@ float evalShadowAttenuationBasic(vec4 shadowTexcoord) { fetchShadow(shadowTexcoord.xyz + radiusScale * shadowScale * vec3(samples[2], 0.0)) + fetchShadow(shadowTexcoord.xyz + radiusScale * shadowScale * vec3(samples[3], 0.0)) )); - return shadowAttenuation; + return shadowAttenuation; } float evalShadowAttenuation(vec4 shadowTexcoord) { - return evalShadowAttenuationBasic(shadowTexcoord); + return evalShadowAttenuationBasic(shadowTexcoord); } diff --git a/libraries/render-utils/src/SkyFromAtmosphere.slf b/libraries/render-utils/src/SkyFromAtmosphere.slf index 1e1718677c..c2a3635f07 100755 --- a/libraries/render-utils/src/SkyFromAtmosphere.slf +++ b/libraries/render-utils/src/SkyFromAtmosphere.slf @@ -33,16 +33,16 @@ // Copyright (c) 2004 Sean O'Neil // -uniform vec3 v3CameraPos; // The camera's current position -uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels -uniform float fInnerRadius; // The inner (planetary) radius -uniform float fKrESun; // Kr * ESun -uniform float fKmESun; // Km * ESun -uniform float fKr4PI; // Kr * 4 * PI -uniform float fKm4PI; // Km * 4 * PI -uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) -uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) -uniform float fScaleOverScaleDepth; // fScale / fScaleDepth +uniform vec3 v3CameraPos; // The camera's current position +uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels +uniform float fInnerRadius; // The inner (planetary) radius +uniform float fKrESun; // Kr * ESun +uniform float fKmESun; // Km * ESun +uniform float fKr4PI; // Kr * 4 * PI +uniform float fKm4PI; // Km * 4 * PI +uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) +uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) +uniform float fScaleOverScaleDepth; // fScale / fScaleDepth const int nSamples = 2; const float fSamples = 2.0; @@ -51,7 +51,8 @@ uniform vec3 v3LightPos; uniform float g; uniform float g2; -varying vec3 position; +in vec3 position; +out vec4 outFragColor; float scale(float fCos) @@ -97,7 +98,7 @@ void main (void) v3SamplePoint += v3SampleRay; } - // Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader + // Finally, scale the Mie and Rayleigh colors and set up the in variables for the pixel shader vec3 secondaryFrontColor = v3FrontColor * fKmESun; vec3 frontColor = v3FrontColor * (v3InvWavelength * fKrESun); vec3 v3Direction = v3CameraPos - v3Pos; @@ -106,6 +107,6 @@ void main (void) float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5); vec3 finalColor = frontColor.rgb + fMiePhase * secondaryFrontColor.rgb; - gl_FragColor.a = finalColor.b; - gl_FragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2)); + outFragColor.a = finalColor.b; + outFragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2)); } diff --git a/libraries/render-utils/src/SkyFromAtmosphere.slv b/libraries/render-utils/src/SkyFromAtmosphere.slv index 29c907b94c..c78f3b0a15 100755 --- a/libraries/render-utils/src/SkyFromAtmosphere.slv +++ b/libraries/render-utils/src/SkyFromAtmosphere.slv @@ -33,32 +33,33 @@ // Copyright (c) 2004 Sean O'Neil // +<@include gpu/Inputs.slh@> <@include gpu/Transform.slh@> <$declareStandardTransform()$> -uniform vec3 v3CameraPos; // The camera's current position -uniform vec3 v3LightPos; // The direction vector to the light source -uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels -uniform float fOuterRadius; // The outer (atmosphere) radius -uniform float fInnerRadius; // The inner (planetary) radius -uniform float fKrESun; // Kr * ESun -uniform float fKmESun; // Km * ESun -uniform float fKr4PI; // Kr * 4 * PI -uniform float fKm4PI; // Km * 4 * PI -uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) -uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) -uniform float fScaleOverScaleDepth; // fScale / fScaleDepth +uniform vec3 v3CameraPos; // The camera's current position +uniform vec3 v3LightPos; // The direction vector to the light source +uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels +uniform float fOuterRadius; // The outer (atmosphere) radius +uniform float fInnerRadius; // The inner (planetary) radius +uniform float fKrESun; // Kr * ESun +uniform float fKmESun; // Km * ESun +uniform float fKr4PI; // Kr * 4 * PI +uniform float fKm4PI; // Km * 4 * PI +uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) +uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) +uniform float fScaleOverScaleDepth; // fScale / fScaleDepth const int nSamples = 2; const float fSamples = 2.0; -varying vec3 position; +out vec3 position; void main(void) { - // Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere) - position = gl_Vertex.xyz * fOuterRadius; + // Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere) + position = inPosition.xyz * fOuterRadius; // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/SkyFromSpace.slf b/libraries/render-utils/src/SkyFromSpace.slf index 2373511932..e3569a2914 100755 --- a/libraries/render-utils/src/SkyFromSpace.slf +++ b/libraries/render-utils/src/SkyFromSpace.slf @@ -1,4 +1,5 @@ -#version 120 +<@include gpu/Config.slh@> +<$VERSION_HEADER$> // // For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html: @@ -32,20 +33,20 @@ // Copyright (c) 2004 Sean O'Neil // -uniform vec3 v3CameraPos; // The camera's current position -uniform vec3 v3LightPos; // The direction vector to the light source -uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels -uniform float fCameraHeight2; // fCameraHeight^2 -uniform float fOuterRadius; // The outer (atmosphere) radius -uniform float fOuterRadius2; // fOuterRadius^2 -uniform float fInnerRadius; // The inner (planetary) radius -uniform float fKrESun; // Kr * ESun -uniform float fKmESun; // Km * ESun -uniform float fKr4PI; // Kr * 4 * PI -uniform float fKm4PI; // Km * 4 * PI -uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) -uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) -uniform float fScaleOverScaleDepth; // fScale / fScaleDepth +uniform vec3 v3CameraPos; // The camera's current position +uniform vec3 v3LightPos; // The direction vector to the light source +uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels +uniform float fCameraHeight2; // fCameraHeight^2 +uniform float fOuterRadius; // The outer (atmosphere) radius +uniform float fOuterRadius2; // fOuterRadius^2 +uniform float fInnerRadius; // The inner (planetary) radius +uniform float fKrESun; // Kr * ESun +uniform float fKmESun; // Km * ESun +uniform float fKr4PI; // Kr * 4 * PI +uniform float fKm4PI; // Km * 4 * PI +uniform float fScale; // 1 / (fOuterRadius - fInnerRadius) +uniform float fScaleDepth; // The scale depth (i.e. the altitude at which the atmosphere's average density is found) +uniform float fScaleOverScaleDepth; // fScale / fScaleDepth uniform float g; uniform float g2; @@ -53,63 +54,65 @@ uniform float g2; const int nSamples = 2; const float fSamples = 2.0; -varying vec3 position; +in vec3 position; + +out vec4 outFragColor; float scale(float fCos) { - float x = 1.0 - fCos; - return fScaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25)))); + float x = 1.0 - fCos; + return fScaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25)))); } void main (void) { // Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere) - vec3 v3Pos = position; - vec3 v3Ray = v3Pos - v3CameraPos; - float fFar = length(v3Ray); - v3Ray /= fFar; + vec3 v3Pos = position; + vec3 v3Ray = v3Pos - v3CameraPos; + float fFar = length(v3Ray); + v3Ray /= fFar; - // Calculate the closest intersection of the ray with the outer atmosphere (which is the near point of the ray passing through the atmosphere) - float B = 2.0 * dot(v3CameraPos, v3Ray); - float C = fCameraHeight2 - fOuterRadius2; - float fDet = max(0.0, B*B - 4.0 * C); - float fNear = 0.5 * (-B - sqrt(fDet)); + // Calculate the closest intersection of the ray with the outer atmosphere (which is the near point of the ray passing through the atmosphere) + float B = 2.0 * dot(v3CameraPos, v3Ray); + float C = fCameraHeight2 - fOuterRadius2; + float fDet = max(0.0, B*B - 4.0 * C); + float fNear = 0.5 * (-B - sqrt(fDet)); - // Calculate the ray's starting position, then calculate its scattering offset - vec3 v3Start = v3CameraPos + v3Ray * fNear; - fFar -= fNear; - float fStartAngle = dot(v3Ray, v3Start) / fOuterRadius; - float fStartDepth = exp(-1.0 / fScaleDepth); - float fStartOffset = fStartDepth * scale(fStartAngle); + // Calculate the ray's starting position, then calculate its scattering offset + vec3 v3Start = v3CameraPos + v3Ray * fNear; + fFar -= fNear; + float fStartAngle = dot(v3Ray, v3Start) / fOuterRadius; + float fStartDepth = exp(-1.0 / fScaleDepth); + float fStartOffset = fStartDepth * scale(fStartAngle); - // Initialize the scattering loop variables - //gl_FrontColor = vec4(0.0, 0.0, 0.0, 0.0); - float fSampleLength = fFar / fSamples; - float fScaledLength = fSampleLength * fScale; - vec3 v3SampleRay = v3Ray * fSampleLength; - vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5; + // Initialize the scattering loop variables + //gl_FrontColor = vec4(0.0, 0.0, 0.0, 0.0); + float fSampleLength = fFar / fSamples; + float fScaledLength = fSampleLength * fScale; + vec3 v3SampleRay = v3Ray * fSampleLength; + vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5; - // Now loop through the sample rays - vec3 v3FrontColor = vec3(0.0, 0.0, 0.0); - for(int i=0; i <@include gpu/Transform.slh@> <$declareStandardTransform()$> -uniform float fOuterRadius; // The outer (atmosphere) radius +uniform float fOuterRadius; // The outer (atmosphere) radius -varying vec3 position; +out vec3 position; void main(void) { - position = gl_Vertex.xyz * fOuterRadius; + position = inPosition.xyz * fOuterRadius; // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/ambient_occlusion.slf b/libraries/render-utils/src/ambient_occlusion.slf index f45fd9b6a0..649fb16c56 100644 --- a/libraries/render-utils/src/ambient_occlusion.slf +++ b/libraries/render-utils/src/ambient_occlusion.slf @@ -21,7 +21,7 @@ // Based on NVidia HBAO implementation in D3D11 // http://www.nvidia.co.uk/object/siggraph-2008-HBAO.html -varying vec2 varTexcoord; +in vec2 varTexcoord; uniform sampler2D depthTexture; uniform sampler2D normalTexture; @@ -47,12 +47,15 @@ const float AOStrength = 1.9; const float R = 0.3; const float R2 = 0.3*0.3; const float NegInvR2 = - 1.0 / (0.3*0.3); -const float TanBias = tan(30.0 * PI / 180.0); +// can't use tan to initialize a const value +const float TanBias = 0.57735027; // tan(30.0 * PI / 180.0); const float MaxRadiusPixels = 50.0; const int NumDirections = 6; const int NumSamples = 4; +out vec4 outFragColor; + float ViewSpaceZFromDepth(float d){ // [0,1] -> [-1,1] clip space d = d * 2.0 - 1.0; @@ -67,14 +70,14 @@ vec3 UVToViewSpace(vec2 uv, float z){ } vec3 GetViewPos(vec2 uv){ - float z = ViewSpaceZFromDepth(texture2D(depthTexture, uv).r); + float z = ViewSpaceZFromDepth(texture(depthTexture, uv).r); return UVToViewSpace(uv, z); } vec3 GetViewPosPoint(ivec2 uv){ vec2 coord = vec2(gl_FragCoord.xy) + uv; //float z = texelFetch(texture0, coord, 0).r; - float z = texture2D(depthTexture, uv).r; + float z = texture(depthTexture, uv).r; return UVToViewSpace(uv, z); } @@ -241,5 +244,5 @@ void main(void){ ao = 1.0 - ao / numDirections * AOStrength; } - gl_FragColor = vec4(vec3(ao), 1.0); + outFragColor = vec4(vec3(ao), 1.0); } \ No newline at end of file diff --git a/libraries/render-utils/src/ambient_occlusion.slv b/libraries/render-utils/src/ambient_occlusion.slv index 81f196dd46..46da3f5fd5 100644 --- a/libraries/render-utils/src/ambient_occlusion.slv +++ b/libraries/render-utils/src/ambient_occlusion.slv @@ -12,13 +12,15 @@ // 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 vec2 varTexcoord; +out vec2 varTexcoord; void main(void) { - varTexcoord = gl_MultiTexCoord0.xy; - gl_Position = gl_Vertex; + varTexcoord = inTexCoord0.xy; + gl_Position = inPosition; } diff --git a/libraries/render-utils/src/deferred_light_limited.slv b/libraries/render-utils/src/deferred_light_limited.slv index 582840b1fb..e9f3e1bdb3 100644 --- a/libraries/render-utils/src/deferred_light_limited.slv +++ b/libraries/render-utils/src/deferred_light_limited.slv @@ -20,6 +20,8 @@ uniform mat4 texcoordMat; +out vec4 _texCoord0; + void main(void) { // standard transform TransformCamera cam = getTransformCamera(); @@ -27,6 +29,6 @@ void main(void) { <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>; vec4 projected = gl_Position / gl_Position.w; - gl_TexCoord[0] = vec4(dot(projected, texcoordMat[0]) * gl_Position.w, + _texCoord0 = vec4(dot(projected, texcoordMat[0]) * gl_Position.w, dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w); } diff --git a/libraries/render-utils/src/deferred_light_spot.slv b/libraries/render-utils/src/deferred_light_spot.slv index d3ef18fd53..8365899fde 100755 --- a/libraries/render-utils/src/deferred_light_spot.slv +++ b/libraries/render-utils/src/deferred_light_spot.slv @@ -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()$> @@ -19,8 +21,10 @@ uniform mat4 texcoordMat; uniform vec4 coneParam; +out vec4 _texCoord0; + void main(void) { - vec4 coneVertex = gl_Vertex; + vec4 coneVertex = inPosition; if (coneParam.w != 0.0) { if(coneVertex.z >= 0.0) { // Evaluate the true position of the spot volume @@ -42,6 +46,6 @@ void main(void) { <$transformModelToClipPos(cam, obj, coneVertex, gl_Position)$>; vec4 projected = gl_Position / gl_Position.w; - gl_TexCoord[0] = vec4(dot(projected, texcoordMat[0]) * gl_Position.w, + _texCoord0 = vec4(dot(projected, texcoordMat[0]) * gl_Position.w, dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w); } diff --git a/libraries/render-utils/src/gaussian_blur.slf b/libraries/render-utils/src/gaussian_blur.slf index 63ba14a07c..01c1bc8807 100644 --- a/libraries/render-utils/src/gaussian_blur.slf +++ b/libraries/render-utils/src/gaussian_blur.slf @@ -15,28 +15,29 @@ <@include DeferredBufferWrite.slh@> // the interpolated normal -//varying vec4 interpolatedNormal; +//in vec4 interpolatedNormal; -varying vec2 varTexcoord; -varying vec2 varBlurTexcoords[14]; +in vec2 varTexcoord; +in vec2 varBlurTexcoords[14]; uniform sampler2D occlusionTexture; +out vec4 outFragColor; void main(void) { - gl_FragColor = vec4(0.0); - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[0])*0.0044299121055113265; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[1])*0.00895781211794; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[2])*0.0215963866053; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[3])*0.0443683338718; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[4])*0.0776744219933; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[5])*0.115876621105; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[6])*0.147308056121; - gl_FragColor += texture2D(occlusionTexture, varTexcoord)*0.159576912161; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[7])*0.147308056121; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[8])*0.115876621105; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[9])*0.0776744219933; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[10])*0.0443683338718; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[11])*0.0215963866053; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[12])*0.00895781211794; - gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[13])*0.0044299121055113265; + outFragColor = vec4(0.0); + outFragColor += texture(occlusionTexture, varBlurTexcoords[0])*0.0044299121055113265; + outFragColor += texture(occlusionTexture, varBlurTexcoords[1])*0.00895781211794; + outFragColor += texture(occlusionTexture, varBlurTexcoords[2])*0.0215963866053; + outFragColor += texture(occlusionTexture, varBlurTexcoords[3])*0.0443683338718; + outFragColor += texture(occlusionTexture, varBlurTexcoords[4])*0.0776744219933; + outFragColor += texture(occlusionTexture, varBlurTexcoords[5])*0.115876621105; + outFragColor += texture(occlusionTexture, varBlurTexcoords[6])*0.147308056121; + outFragColor += texture(occlusionTexture, varTexcoord)*0.159576912161; + outFragColor += texture(occlusionTexture, varBlurTexcoords[7])*0.147308056121; + outFragColor += texture(occlusionTexture, varBlurTexcoords[8])*0.115876621105; + outFragColor += texture(occlusionTexture, varBlurTexcoords[9])*0.0776744219933; + outFragColor += texture(occlusionTexture, varBlurTexcoords[10])*0.0443683338718; + outFragColor += texture(occlusionTexture, varBlurTexcoords[11])*0.0215963866053; + outFragColor += texture(occlusionTexture, varBlurTexcoords[12])*0.00895781211794; + outFragColor += texture(occlusionTexture, varBlurTexcoords[13])*0.0044299121055113265; } diff --git a/libraries/render-utils/src/gaussian_blur_horizontal.slv b/libraries/render-utils/src/gaussian_blur_horizontal.slv index c3f326daac..7f8fb1c87f 100644 --- a/libraries/render-utils/src/gaussian_blur_horizontal.slv +++ b/libraries/render-utils/src/gaussian_blur_horizontal.slv @@ -12,16 +12,18 @@ // 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 vec2 varTexcoord; -varying vec2 varBlurTexcoords[14]; +out vec2 varTexcoord; +out vec2 varBlurTexcoords[14]; void main(void) { - varTexcoord = gl_MultiTexCoord0.xy; - gl_Position = gl_Vertex; + varTexcoord = inTexCoord0.xy; + gl_Position = inPosition; varBlurTexcoords[0] = varTexcoord + vec2(-0.028, 0.0); varBlurTexcoords[1] = varTexcoord + vec2(-0.024, 0.0); diff --git a/libraries/render-utils/src/gaussian_blur_vertical.slv b/libraries/render-utils/src/gaussian_blur_vertical.slv index fc35a96bf0..4a4d65dcf9 100644 --- a/libraries/render-utils/src/gaussian_blur_vertical.slv +++ b/libraries/render-utils/src/gaussian_blur_vertical.slv @@ -12,16 +12,18 @@ // 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 vec2 varTexcoord; -varying vec2 varBlurTexcoords[14]; +out vec2 varTexcoord; +out vec2 varBlurTexcoords[14]; void main(void) { - varTexcoord = gl_MultiTexCoord0.xy; - gl_Position = gl_Vertex; + varTexcoord = inTexCoord0.xy; + gl_Position = inPosition; varBlurTexcoords[0] = varTexcoord + vec2(0.0, -0.028); varBlurTexcoords[1] = varTexcoord + vec2(0.0, -0.024); diff --git a/libraries/render-utils/src/hit_effect.slf b/libraries/render-utils/src/hit_effect.slf index 6c0dcd7a70..ed11aea0b9 100644 --- a/libraries/render-utils/src/hit_effect.slf +++ b/libraries/render-utils/src/hit_effect.slf @@ -14,11 +14,12 @@ <@include DeferredBufferWrite.slh@> -varying vec2 varQuadPosition; +in vec2 varQuadPosition; +out vec4 outFragColor; void main(void) { vec2 center = vec2(0.0, 0.0); float distFromCenter = distance( vec2(0.0, 0.0), varQuadPosition); float alpha = mix(0.0, 0.5, pow(distFromCenter,5.)); - gl_FragColor = vec4(1.0, 0.0, 0.0, alpha); + outFragColor = vec4(1.0, 0.0, 0.0, alpha); } \ No newline at end of file diff --git a/libraries/render-utils/src/hit_effect.slv b/libraries/render-utils/src/hit_effect.slv index d1efdebc18..b9b0638f9e 100644 --- a/libraries/render-utils/src/hit_effect.slv +++ b/libraries/render-utils/src/hit_effect.slv @@ -12,13 +12,15 @@ // 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 vec2 varQuadPosition; +out vec2 varQuadPosition; void main(void) { - varQuadPosition = gl_Vertex.xy; - gl_Position = gl_Vertex; + varQuadPosition = inPosition.xy; + gl_Position = inPosition; } \ No newline at end of file diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 0c20e884e9..f455030f6f 100755 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -19,7 +19,7 @@ uniform sampler2D diffuseMap; in vec4 _position; -in vec4 _normal; +in vec3 _normal; in vec3 _color; in vec2 _texCoord0; diff --git a/libraries/render-utils/src/model_normal_map.slf b/libraries/render-utils/src/model_normal_map.slf index fdc2c41554..5479cec8eb 100755 --- a/libraries/render-utils/src/model_normal_map.slf +++ b/libraries/render-utils/src/model_normal_map.slf @@ -23,9 +23,9 @@ uniform sampler2D diffuseMap; uniform sampler2D normalMap; in vec4 _position; -in vec4 _texCoord0; -in vec4 _normal; -in vec4 _tangent; +in vec2 _texCoord0; +in vec3 _normal; +in vec3 _tangent; in vec3 _color; void main(void) { diff --git a/libraries/render-utils/src/model_normal_specular_map.slf b/libraries/render-utils/src/model_normal_specular_map.slf index a9fc6caea1..2ebcdaae44 100755 --- a/libraries/render-utils/src/model_normal_specular_map.slf +++ b/libraries/render-utils/src/model_normal_specular_map.slf @@ -36,13 +36,13 @@ void main(void) { vec3 normalizedNormal = normalize(_normal); vec3 normalizedTangent = normalize(_tangent); vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent)); - vec3 localNormal = normalize(vec3(texture2D(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5)); + vec3 localNormal = normalize(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, _texCoord0); - vec3 specular = texture2D(specularMap, _texCoord0).rgb; + vec4 diffuse = texture(diffuseMap, _texCoord0); + vec3 specular = texture(specularMap, _texCoord0).rgb; Material mat = getMaterial(); diff --git a/libraries/render-utils/src/occlusion_blend.slf b/libraries/render-utils/src/occlusion_blend.slf index cdab624b95..58873d9884 100644 --- a/libraries/render-utils/src/occlusion_blend.slf +++ b/libraries/render-utils/src/occlusion_blend.slf @@ -14,13 +14,14 @@ <@include DeferredBufferWrite.slh@> -varying vec2 varTexcoord; +in vec2 varTexcoord; +out vec4 outFragColor; uniform sampler2D blurredOcclusionTexture; void main(void) { - vec4 occlusionColor = texture2D(blurredOcclusionTexture, varTexcoord); + vec4 occlusionColor = texture(blurredOcclusionTexture, varTexcoord); - gl_FragColor = vec4(vec3(0.0), occlusionColor.r); + outFragColor = vec4(vec3(0.0), occlusionColor.r); } diff --git a/libraries/render-utils/src/overlay3D.slf b/libraries/render-utils/src/overlay3D.slf index 69ea8c0e76..7b8a8d85f4 100644 --- a/libraries/render-utils/src/overlay3D.slf +++ b/libraries/render-utils/src/overlay3D.slf @@ -13,17 +13,18 @@ uniform sampler2D diffuseMap; -varying vec2 varTexcoord; +in vec2 varTexcoord; -varying vec3 varEyeNormal; +in vec3 varEyeNormal; -varying vec4 varColor; +in vec4 varColor; +out vec4 outFragColor; void main(void) { - vec4 diffuse = texture2D(diffuseMap, varTexcoord.st); + vec4 diffuse = texture(diffuseMap, varTexcoord.st); if (diffuse.a < 0.5) { discard; } - gl_FragColor = vec4(varColor * diffuse); + outFragColor = vec4(varColor * diffuse); } diff --git a/libraries/render-utils/src/overlay3D.slv b/libraries/render-utils/src/overlay3D.slv index cdb11c1d08..a57f02d854 100644 --- a/libraries/render-utils/src/overlay3D.slv +++ b/libraries/render-utils/src/overlay3D.slv @@ -10,31 +10,31 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +<@include gpu/Inputs.slh@> + <@include gpu/Transform.slh@> <$declareStandardTransform()$> -//attribute vec2 texcoord; - -varying vec2 varTexcoord; +out vec2 varTexcoord; // interpolated eye position -varying vec4 varEyePosition; +out vec4 varEyePosition; // the interpolated normal -varying vec3 varEyeNormal; +out vec3 varEyeNormal; -varying vec4 varColor; +out vec4 varColor; void main(void) { - varTexcoord = gl_MultiTexCoord0.xy; + varTexcoord = inTexCoord0.xy; // pass along the color - varColor = gl_Color; + varColor = inColor; // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, gl_Vertex, varEyePosition, gl_Position)$> - <$transformModelToEyeDir(cam, obj, gl_Normal, varEyeNormal.xyz)$> + <$transformModelToEyeAndClipPos(cam, obj, inPosition, varEyePosition, gl_Position)$> + <$transformModelToEyeDir(cam, obj, inNormal.xyz, varEyeNormal.xyz)$> } diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index 425d6f9b08..5e353d3dcb 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -15,7 +15,8 @@ uniform bool Outline; uniform vec4 Color; // the interpolated normal -varying vec4 interpolatedNormal; +in vec3 _normal; +in vec2 _texCoord0; const float gamma = 2.2; const float smoothing = 256.0; @@ -24,7 +25,7 @@ const float outlineExpansion = 0.2; void main() { // retrieve signed distance - float sdf = texture2D(Font, gl_TexCoord[0].xy).g; + float sdf = texture(Font, gl_TexCoord[0].xy).g; if (Outline) { if (sdf > interiorCutoff) { sdf = 1.0 - sdf; @@ -47,6 +48,6 @@ void main() { // final color gl_FragData[0] = vec4(Color.rgb, Color.a * a); - gl_FragData[1] = vec4(normalize(interpolatedNormal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5); + gl_FragData[1] = vec4(normalize(_normal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5); gl_FragData[2] = vec4(Color.rgb, gl_FrontMaterial.shininess / 128.0); } \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D.slv b/libraries/render-utils/src/sdf_text3D.slv index 6838650e75..d8b7587789 100644 --- a/libraries/render-utils/src/sdf_text3D.slv +++ b/libraries/render-utils/src/sdf_text3D.slv @@ -9,21 +9,23 @@ // 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/Inputs.slh@> + <@include gpu/Transform.slh@> <$declareStandardTransform()$> // the interpolated normal -varying vec4 interpolatedNormal; +out vec3 _normal; +out vec2 _texCoord0; void main() { - gl_TexCoord[0] = gl_MultiTexCoord0; + _texCoord0 = inTexCoord0.xy; // 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.xyz)$> } \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_emisive.slf b/libraries/render-utils/src/simple_textured_emisive.slf index d2c7d403c3..dd0df6ba8b 100644 --- a/libraries/render-utils/src/simple_textured_emisive.slf +++ b/libraries/render-utils/src/simple_textured_emisive.slf @@ -18,15 +18,17 @@ uniform sampler2D originalTexture; // the interpolated normal -varying vec4 interpolatedNormal; +in vec3 _normal; +in vec4 _texCoord0; +in vec4 _color; void main(void) { - vec4 texel = texture2D(originalTexture, gl_TexCoord[0].st); + vec4 texel = texture(originalTexture, _texCoord0.st); packDeferredFragmentLightmap( - normalize(interpolatedNormal.xyz), + normalize(_normal), glowIntensity * texel.a, - gl_Color.rgb, + _color.rgb, DEFAULT_SPECULAR, DEFAULT_SHININESS, texel.rgb); } \ No newline at end of file diff --git a/libraries/render-utils/src/skin_model.slv b/libraries/render-utils/src/skin_model.slv index e3c87160c5..32fe92040d 100755 --- a/libraries/render-utils/src/skin_model.slv +++ b/libraries/render-utils/src/skin_model.slv @@ -35,7 +35,7 @@ void main(void) { vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; - float clusterWeight = inSkinClusterWeight[i].x; + float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; } diff --git a/libraries/render-utils/src/skin_model_normal_map.slv b/libraries/render-utils/src/skin_model_normal_map.slv index 907c2edb2c..0771117a3f 100755 --- a/libraries/render-utils/src/skin_model_normal_map.slv +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -37,7 +37,7 @@ void main(void) { vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; - float clusterWeight = inSkinClusterWeight[i].x; + float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; interpolatedTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight; diff --git a/libraries/render-utils/src/skin_model_shadow.slv b/libraries/render-utils/src/skin_model_shadow.slv index 03b912a981..727a23f861 100755 --- a/libraries/render-utils/src/skin_model_shadow.slv +++ b/libraries/render-utils/src/skin_model_shadow.slv @@ -1,5 +1,5 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> +<@include gpu/Config.slh@> +<$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // // skin_model_shadow.vert @@ -12,27 +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()$> +<$declareStandardTransform()$> const int MAX_CLUSTERS = 128; const int INDICES_PER_VERTEX = 4; uniform mat4 clusterMatrices[MAX_CLUSTERS]; -attribute vec4 clusterIndices; -attribute vec4 clusterWeights; - void main(void) { vec4 position = 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; + mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; + float clusterWeight = inSkinClusterWeight[i]; + position += clusterMatrix * inPosition * clusterWeight; } - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); + // standard transform + TransformCamera cam = getTransformCamera(); + TransformObject obj = getTransformObject(); <$transformModelToClipPos(cam, obj, position, gl_Position)$> } diff --git a/libraries/render-utils/src/standardDrawTexture.slf b/libraries/render-utils/src/standardDrawTexture.slf index b23bd47859..f3492c2959 100644 --- a/libraries/render-utils/src/standardDrawTexture.slf +++ b/libraries/render-utils/src/standardDrawTexture.slf @@ -23,5 +23,9 @@ out vec4 _fragColor; void main(void) { vec4 color = texture(colorMap, _texCoord0); - _fragColor = color * _color; + // FIXME CORE this isn't working + //_fragColor = color * _color; + //_fragColor = vec4(color.rgb, color.a * _color.a); + //_fragColor = vec4(color.rgb * _color.rgb, color.a); + _fragColor = color; } diff --git a/libraries/render-utils/src/stars.slf b/libraries/render-utils/src/stars.slf index 7e1c96bc5b..8d1ba0da51 100644 --- a/libraries/render-utils/src/stars.slf +++ b/libraries/render-utils/src/stars.slf @@ -10,8 +10,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -varying vec4 varColor; +in vec4 varColor; +out vec4 outFragColor; void main(void) { - gl_FragColor = varColor; //vec4(varColor, 1.0); + outFragColor = varColor; //vec4(varColor, 1.0); } diff --git a/libraries/render-utils/src/stars.slv b/libraries/render-utils/src/stars.slv index 98241321fa..f9be6d0139 100644 --- a/libraries/render-utils/src/stars.slv +++ b/libraries/render-utils/src/stars.slv @@ -12,21 +12,23 @@ // 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 vec4 varColor; +out vec3 varPosition; +out vec4 varColor; void main(void) { - varColor = gl_Color.rgba; + varColor = inColor.rgba; // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$> - varPosition = gl_Vertex.xyz; - gl_PointSize = gl_Color.a; + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + varPosition = inPosition.xyz; + gl_PointSize = inColor.a; } \ No newline at end of file diff --git a/libraries/render-utils/src/starsGrid.slf b/libraries/render-utils/src/starsGrid.slf index 12dfd0317c..c52ccb54d9 100644 --- a/libraries/render-utils/src/starsGrid.slf +++ b/libraries/render-utils/src/starsGrid.slf @@ -7,9 +7,9 @@ // // Created by Bradley Austin Davis on 2015/06/19 -varying vec2 varTexcoord; -varying vec3 varNomral; -varying vec3 varPosition; +in vec2 varTexcoord; +in vec3 varNomral; +in vec3 varPosition; uniform float iGlobalTime; @@ -20,6 +20,7 @@ const float latitudeDist = PI / 2.0 / float(latitudeCount); const int meridianCount = 4; const float merdianDist = PI / float(meridianCount); +out vec4 outFragColor; float clampLine(float val, float target) { return clamp((1.0 - abs((val - target)) - 0.998) * 500.0, 0.0, 1.0); @@ -58,6 +59,6 @@ void mainVR( out vec4 fragColor, in vec2 fragCoord, in vec3 fragRayOri, in vec3 } void main(void) { - mainVR(gl_FragColor, gl_FragCoord.xy, vec3(0.0), normalize(varPosition)); + mainVR(outFragColor, gl_FragCoord.xy, vec3(0.0), normalize(varPosition)); } diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index b341f444e6..1baffd872d 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -27,10 +27,10 @@ struct QuadBuilder { texMin + glm::vec2(0.0f, texSize.y)); vertices[1] = TextureVertex(min + glm::vec2(size.x, 0.0f), texMin + texSize); - vertices[2] = TextureVertex(min + size, - texMin + glm::vec2(texSize.x, 0.0f)); - vertices[3] = TextureVertex(min + glm::vec2(0.0f, size.y), + vertices[2] = TextureVertex(min + glm::vec2(0.0f, size.y), texMin); + vertices[3] = TextureVertex(min + size, + texMin + glm::vec2(texSize.x, 0.0f)); } QuadBuilder(const Glyph& glyph, const glm::vec2& offset) : QuadBuilder(offset + glm::vec2(glyph.offset.x, glyph.offset.y - glyph.size.y), glyph.size, @@ -318,5 +318,5 @@ void Font::drawString(gpu::Batch& batch, float x, float y, const QString& str, c batch.setInputFormat(_format); batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride); - batch.draw(gpu::QUADS, _numVertices, 0); + batch.draw(gpu::TRIANGLE_STRIP, _numVertices, 0); } diff --git a/libraries/render/src/render/drawItemBounds.slf b/libraries/render/src/render/drawItemBounds.slf index b5d1a297bf..a4ade87b1c 100644 --- a/libraries/render/src/render/drawItemBounds.slf +++ b/libraries/render/src/render/drawItemBounds.slf @@ -11,9 +11,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -varying vec4 varColor; +in vec4 varColor; +out vec4 outFragColor; void main(void) { - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); + outFragColor = vec4(1.0, 1.0, 1.0, 1.0); } diff --git a/libraries/render/src/render/drawItemStatus.slf b/libraries/render/src/render/drawItemStatus.slf index dcf5d3ee25..4cc45db2ec 100644 --- a/libraries/render/src/render/drawItemStatus.slf +++ b/libraries/render/src/render/drawItemStatus.slf @@ -11,9 +11,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -varying vec4 varColor; +in vec4 varColor; +out vec4 outFragColor; void main(void) { - gl_FragColor = varColor; + outFragColor = varColor; } diff --git a/libraries/render/src/render/drawItemStatus.slv b/libraries/render/src/render/drawItemStatus.slv index 106a5684bb..b90daef76a 100644 --- a/libraries/render/src/render/drawItemStatus.slv +++ b/libraries/render/src/render/drawItemStatus.slv @@ -16,7 +16,7 @@ <$declareStandardTransform()$> -varying vec4 varColor; +out vec4 varColor; uniform vec3 inBoundPos; uniform vec3 inBoundDim; diff --git a/tests/render-utils/CMakeLists.txt b/tests/render-utils/CMakeLists.txt index 2fef0c8884..97d3214744 100644 --- a/tests/render-utils/CMakeLists.txt +++ b/tests/render-utils/CMakeLists.txt @@ -5,12 +5,8 @@ set(TARGET_NAME render-utils-test) setup_hifi_project(Quick Gui OpenGL) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") -#include_oglplus() - # link in the shared libraries link_hifi_libraries(render-utils gpu shared) - -include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/") message(${PROJECT_BINARY_DIR}) copy_dlls_beside_windows_executable() diff --git a/tests/render-utils/src/main.cpp b/tests/render-utils/src/main.cpp index 940218e64e..a10c57b10f 100644 --- a/tests/render-utils/src/main.cpp +++ b/tests/render-utils/src/main.cpp @@ -38,58 +38,9 @@ #include - #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 times; QElapsedTimer timer; @@ -179,7 +130,6 @@ public: gpu::Context::init(); - { QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this); logger->initialize(); // initializes in the current context, i.e. ctx @@ -252,46 +202,6 @@ 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(); diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt new file mode 100644 index 0000000000..eefdf2aa3a --- /dev/null +++ b/tests/shaders/CMakeLists.txt @@ -0,0 +1,21 @@ + +set(TARGET_NAME shaders-test) + +# This is not a testcase -- just set it up as a regular hifi project +setup_hifi_project(Quick Gui OpenGL) +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") + +#include_oglplus() + +# link in the shared libraries +link_hifi_libraries(shared octree environment gpu model render fbx networking entities + script-engine physics + render-utils entities-renderer) + +include_directories("${PROJECT_BINARY_DIR}/../../libraries/gpu/") +include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/") +include_directories("${PROJECT_BINARY_DIR}/../../libraries/entities-renderer/") +include_directories("${PROJECT_BINARY_DIR}/../../libraries/model/") + +message(${PROJECT_BINARY_DIR}) +copy_dlls_beside_windows_executable() diff --git a/tests/shaders/src/main.cpp b/tests/shaders/src/main.cpp new file mode 100644 index 0000000000..70e93ba9d1 --- /dev/null +++ b/tests/shaders/src/main.cpp @@ -0,0 +1,370 @@ +// +// Copyright 2014 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 +// + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#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" + +#include "untextured_particle_frag.h" +#include "untextured_particle_vert.h" +#include "textured_particle_frag.h" +#include "textured_particle_vert.h" + +#include "ambient_occlusion_vert.h" +#include "ambient_occlusion_frag.h" +#include "gaussian_blur_vertical_vert.h" +#include "gaussian_blur_horizontal_vert.h" +#include "gaussian_blur_frag.h" +#include "occlusion_blend_frag.h" + +#include "hit_effect_vert.h" +#include "hit_effect_frag.h" + +#include "overlay3D_vert.h" +#include "overlay3D_frag.h" + +#include "SkyFromSpace_vert.h" +#include "SkyFromSpace_frag.h" +#include "SkyFromAtmosphere_vert.h" +#include "SkyFromAtmosphere_frag.h" + +#include "DrawTransformUnitQuad_vert.h" +#include "DrawTexcoordRectTransformUnitQuad_vert.h" +#include "DrawViewportQuadTransformTexcoord_vert.h" +#include "DrawTexture_frag.h" +#include "DrawTextureOpaque_frag.h" +#include "DrawColoredTexture_frag.h" + + +class RateCounter { + std::vector times; + QElapsedTimer timer; +public: + RateCounter() { + timer.start(); + } + + void reset() { + times.clear(); + } + + unsigned int count() const { + return times.size() - 1; + } + + float elapsed() const { + if (times.size() < 1) { + return 0.0f; + } + float elapsed = *times.rbegin() - *times.begin(); + return elapsed; + } + + void increment() { + times.push_back(timer.elapsed() / 1000.0f); + } + + float rate() const { + if (elapsed() == 0.0f) { + return NAN; + } + return (float) count() / elapsed(); + } +}; + + +const QString& getQmlDir() { + static QString dir; + if (dir.isEmpty()) { + QDir path(__FILE__); + path.cdUp(); + dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/qml/")) + "/"; + qDebug() << "Qml Path: " << dir; + } + return dir; +} + +// Create a simple OpenGL window that renders text in various ways +class QTestWindow : public QWindow { + Q_OBJECT + + QOpenGLContext* _context{ nullptr }; + QSize _size; + //TextRenderer* _textRenderer[4]; + RateCounter fps; + +protected: + void renderText(); + +private: + void resizeWindow(const QSize& size) { + _size = size; + } + +public: + QTestWindow() { + setSurfaceType(QSurface::OpenGLSurface); + + QSurfaceFormat format; + // Qt Quick may need a depth and stencil buffer. Always make sure these are available. + format.setDepthBufferSize(16); + format.setStencilBufferSize(8); + format.setVersion(4, 1); + format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + format.setOption(QSurfaceFormat::DebugContext); + + setFormat(format); + + _context = new QOpenGLContext; + _context->setFormat(format); + _context->create(); + + show(); + makeCurrent(); + + gpu::Context::init(); + + + { + QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this); + logger->initialize(); // initializes in the current context, i.e. ctx + logger->enableMessages(); + connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) { + qDebug() << debugMessage; + }); + // logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); + } + qDebug() << (const char*)glGetString(GL_VERSION); + + //_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false); + //_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false, + // TextRenderer::SHADOW_EFFECT); + //_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1, + // false, TextRenderer::OUTLINE_EFFECT); + //_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glClearColor(0.2f, 0.2f, 0.2f, 1); + glDisable(GL_DEPTH_TEST); + + makeCurrent(); + +// setFramePosition(QPoint(-1000, 0)); + resize(QSize(800, 600)); + } + + virtual ~QTestWindow() { + } + + void draw(); + void makeCurrent() { + _context->makeCurrent(this); + } + +protected: + void resizeEvent(QResizeEvent* ev) override { + resizeWindow(ev->size()); + } +}; + +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; + } + + makeCurrent(); + 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(DrawTransformUnitQuad_vert, DrawTexture_frag); + testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert, DrawTexture_frag); + testShaderBuild(DrawViewportQuadTransformTexcoord_vert, DrawTexture_frag); + testShaderBuild(DrawTransformUnitQuad_vert, DrawTextureOpaque_frag); + testShaderBuild(DrawTransformUnitQuad_vert, DrawColoredTexture_frag); + + 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); + testShaderBuild(untextured_particle_vert, untextured_particle_frag); + testShaderBuild(textured_particle_vert, textured_particle_frag); + + testShaderBuild(gaussian_blur_vertical_vert, gaussian_blur_frag); + testShaderBuild(gaussian_blur_horizontal_vert, gaussian_blur_frag); + testShaderBuild(ambient_occlusion_vert, ambient_occlusion_frag); + testShaderBuild(ambient_occlusion_vert, occlusion_blend_frag); + + testShaderBuild(hit_effect_vert, hit_effect_frag); + + testShaderBuild(overlay3D_vert, overlay3D_frag); + + testShaderBuild(SkyFromSpace_vert, SkyFromSpace_frag); + testShaderBuild(SkyFromAtmosphere_vert, SkyFromAtmosphere_frag); + + }); + + _context->swapBuffers(this); + glFinish(); + + fps.increment(); + if (fps.elapsed() >= 2.0f) { + qDebug() << "FPS: " << fps.rate(); + fps.reset(); + } +} + +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); + app.connect(&timer, &QTimer::timeout, &app, [&] { + window.draw(); + }); + timer.start(); + app.exec(); + return 0; +} + +#include "main.moc"