diff --git a/libraries/gpu/src/gpu/Inputs.slh b/libraries/gpu/src/gpu/Inputs.slh index 1ff4350afb..546427e3d1 100644 --- a/libraries/gpu/src/gpu/Inputs.slh +++ b/libraries/gpu/src/gpu/Inputs.slh @@ -1,5 +1,5 @@ // 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); } diff --git a/libraries/model/src/model/Skybox.slv b/libraries/model/src/model/Skybox.slv index d622dc0bdb..d1b9a20a66 100755 --- a/libraries/model/src/model/Skybox.slv +++ b/libraries/model/src/model/Skybox.slv @@ -11,39 +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; -}; - -uniform skyboxBuffer { - Skybox _skybox; -}; -Skybox getSkybox() { - return _skybox; -} - -varying vec3 normal; -varying vec2 texcoord; -varying vec3 color; - -void main(void) { - texcoord = inPosition.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); +} \ No newline at end of file diff --git a/libraries/render-utils/src/deferred_light_limited.slv b/libraries/render-utils/src/deferred_light_limited.slv index 262d798e12..e6fbbcdac3 100644 --- a/libraries/render-utils/src/deferred_light_limited.slv +++ b/libraries/render-utils/src/deferred_light_limited.slv @@ -12,12 +12,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include gpu/Input.slh@> +<@include gpu/Inputs.slh@> +out vec4 texCoord0; void main(void) { gl_Position = ftransform(); vec4 projected = gl_Position / gl_Position.w; - gl_TexCoord[0] = vec4(dot(projected, gl_ObjectPlaneS[3]) * gl_Position.w, + texCoord0 = vec4(dot(projected, gl_ObjectPlaneS[3]) * gl_Position.w, dot(projected, gl_ObjectPlaneT[3]) * gl_Position.w, 0.0, gl_Position.w); } diff --git a/tests/render-utils/CMakeLists.txt b/tests/render-utils/CMakeLists.txt index 0452fd629c..e91d9baff7 100644 --- a/tests/render-utils/CMakeLists.txt +++ b/tests/render-utils/CMakeLists.txt @@ -7,4 +7,6 @@ setup_hifi_project(Quick Gui OpenGL) # link in the shared libraries link_hifi_libraries(render-utils gpu shared) -copy_dlls_beside_windows_executable() \ No newline at end of file +include_directories("${PROJECT_BINARY_DIR}") +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 d38f1bd57d..a4683ddc8b 100644 --- a/tests/render-utils/src/main.cpp +++ b/tests/render-utils/src/main.cpp @@ -15,6 +15,8 @@ #pragma GCC diagnostic ignored "-Wdouble-promotion" #endif +#include + #include #include #include @@ -41,6 +43,14 @@ #include #include + +#include "gpu/Batch.h" +#include "gpu/Context.h" + +#include "../../libraries/model/Skybox_vert.h" +#include "../../libraries/model/Skybox_frag.h" + + class RateCounter { std::vector times; QElapsedTimer timer; @@ -114,8 +124,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); @@ -134,7 +144,7 @@ public: connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) { qDebug() << debugMessage; }); - // logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); + logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); } qDebug() << (const char*)glGetString(GL_VERSION); @@ -155,12 +165,12 @@ public: glGetError(); #endif - _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); +// _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); @@ -169,7 +179,7 @@ public: makeCurrent(); - setFramePosition(QPoint(-1000, 0)); +// setFramePosition(QPoint(-1000, 0)); resize(QSize(800, 600)); } @@ -251,7 +261,14 @@ void QTestWindow::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio()); - renderText(); + static std::once_flag once; + std::call_once(once, [&]{ + auto skyVS = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(Skybox_vert))); + auto skyFS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(Skybox_frag))); + auto skyShader = gpu::ShaderPointer(gpu::Shader::createProgram(skyVS, skyFS)); + gpu::Shader::makeProgram(*skyShader); + }); + // renderText(); _context->swapBuffers(this); glFinish();