Merge pull request #7286 from zzmp/fix/skybox-tex

Clean up skybox rendering
This commit is contained in:
Brad Hefta-Gaub 2016-03-11 08:50:23 -08:00
commit d1c024fb39
19 changed files with 287 additions and 204 deletions

View file

@ -0,0 +1,18 @@
//
// px.fs
// examples/tests/skybox
//
// Created by Zach Pomerantz on 3/10/2016
// Copyright 2016 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
vec3 getSkyboxColor() {
float red = (cos(iGlobalTime) + 1) / 2;
vec3 color = vec3(red, 1.0, 1.0);
return color;
}

View file

@ -0,0 +1,20 @@
//
// px_rgba.fs
// examples/tests/skybox
//
// Created by Zach Pomerantz on 3/10/2016
// Copyright 2016 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
vec3 getSkyboxColor() {
float red = (cos(iGlobalTime) + 1) / 2;
vec3 color = vec3(red, 1.0, 1.0);
color *= skybox.color.rgb;
return color;
}

View file

@ -0,0 +1,22 @@
//
// px_rgba.fs
// examples/tests/skybox
//
// Created by Zach Pomerantz on 3/10/2016
// Copyright 2016 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
vec3 getSkyboxColor() {
float red = (cos(iGlobalTime) + 1) / 2;
vec3 color = vec3(red, 1.0, 1.0);
vec3 coord = normalize(_normal);
vec3 texel = texture(cubeMap, coord).rgb;
color *= texel;
return color;
}

View file

@ -0,0 +1,24 @@
//
// px_rgba.fs
// examples/tests/skybox
//
// Created by Zach Pomerantz on 3/10/2016
// Copyright 2016 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
vec3 getSkyboxColor() {
float red = (cos(iGlobalTime) + 1) / 2;
vec3 color = vec3(red, 1.0, 1.0);
vec3 coord = normalize(_normal);
vec3 texel = texture(cubeMap, coord).rgb;
color *= texel;
color *= skybox.color.rgb;
return color;
}

View file

@ -0,0 +1,83 @@
// skyboxTest.js
// examples/tests/skybox
//
// Created by Zach Pomerantz on 3/10/2016.
// Copyright 2016 High Fidelity, Inc.
//
// This test cycles through different variations on the skybox with a mouseclick.
// For the test to pass, you should observe the following cycle:
// - Procedural skybox (no texture, no color)
// - Procedural skybox (no texture, with color)
// - Procedural skybox (with texture, no color)
// - Procedural skybox (with texture, with color)
// - Color skybox (no texture)
// - Color skybox (with texture)
// - Texture skybox (no color)
//
// As you run the test, descriptions of the expected rendered skybox will appear as overlays.
//
// NOTE: This does not test uniforms/textures applied to a procedural shader through userData.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var PX_URL = Script.resolvePath('px.fs');
var PX_RGBA_URL = Script.resolvePath('px_rgba.fs');
var PX_TEX_URL = Script.resolvePath('px_tex.fs');
var PX_TEX_RGBA_URL = Script.resolvePath('px_tex_rgba.fs');
var TEX_URL = 'https://hifi-public.s3.amazonaws.com/alan/Playa/Skies/Test-Sky_out.png';
var NO_TEX = '';
var COLOR = { red: 255, green: 0, blue: 255 };
var NO_COLOR = { red: 0, green: 0, blue: 0 };
var data = { ProceduralEntity: { shaderUrl: PX_URL } };
var zone = Entities.addEntity({
type: 'Zone',
dimensions: { x: 50, y: 50, z: 50 },
position: MyAvatar.position,
backgroundMode: 'skybox'
});
var text = Overlays.addOverlay('text', {
text: 'Click this box to advance tests; note that red value cycling means white->light blue',
x: Window.innerWidth / 2 - 250, y: Window.innerHeight / 2 - 25,
width: 500, height: 50
});
print('Zone:', zone);
print('Text:', text);
var edits = [
['Red value should cycle', getEdit(PX_URL, NO_TEX, NO_COLOR)],
['Red value should cycle, no green', getEdit(PX_RGBA_URL, NO_TEX, COLOR)],
['Red value should cycle, each face tinted differently', getEdit(PX_TEX_URL, TEX_URL, NO_COLOR)],
['Red value should cycle, each face tinted differently, no green', getEdit(PX_TEX_RGBA_URL, TEX_URL, COLOR)],
['No green', getEdit(null, NO_TEX, COLOR)],
['Each face colored differently, no green', getEdit(null, TEX_URL, COLOR)],
['Each face colored differently', getEdit(null, TEX_URL, NO_COLOR)],
];
Controller.mousePressEvent.connect(function(e) { if (Overlays.getOverlayAtPoint(e) === text) next(); });
Script.scriptEnding.connect(function() {
Overlays.deleteOverlay(text);
Entities.deleteEntity(zone);
});
var i = 0;
function next() {
var edit = edits[i];
Overlays.editOverlay(text, { text: edit[0] });
Entities.editEntity(zone, edit[1]);
i++;
i %= edits.length;
}
function getEdit(px, url, color) {
return { userData: px ? getUserData(px) : '', backgroundMode: 'skybox', skybox: { url: url, color: color } }
}
function getUserData(px) { return JSON.stringify({ ProceduralEntity: { shaderUrl: px } }); }

View file

@ -3757,19 +3757,19 @@ namespace render {
switch (backgroundMode) {
case model::SunSkyStage::SKY_BOX: {
auto skybox = skyStage->getSkybox();
if (skybox && skybox->getCubemap() && skybox->getCubemap()->isDefined()) {
if (skybox) {
PerformanceTimer perfTimer("skybox");
skybox->render(batch, *(args->_viewFrustum));
break;
}
// If no skybox texture is available, render the SKY_DOME while it loads
}
// fall through to next case
// Fall through: if no skybox is available, render the SKY_DOME
case model::SunSkyStage::SKY_DOME: {
if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
PerformanceTimer perfTimer("stars");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::payloadRender<BackgroundRenderData>() ... stars...");
"Application::payloadRender<BackgroundRenderData>() ... My god, it's full of stars...");
// should be the first rendering pass - w/o depth buffer / lighting
static const float alpha = 1.0f;
@ -3777,6 +3777,7 @@ namespace render {
}
}
break;
case model::SunSkyStage::NO_BACKGROUND:
default:
// this line intentionally left blank

View file

@ -140,8 +140,8 @@ void EntityTreeRenderer::update() {
// If we haven't already updated and previously attempted to load a texture,
// check if the texture loaded and apply it
if (!updated && (
(_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) ||
(_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded()))) {
(_pendingSkyboxTexture && (!_skyboxTexture || _skyboxTexture->isLoaded())) ||
(_pendingAmbientTexture && (!_ambientTexture && _ambientTexture->isLoaded())))) {
applyZonePropertiesToScene(_bestZone);
}
@ -158,6 +158,8 @@ void EntityTreeRenderer::update() {
}
bool EntityTreeRenderer::checkEnterLeaveEntities() {
bool didUpdate = false;
if (_tree && !_shuttingDown) {
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
@ -172,6 +174,7 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
auto oldBestZone = _bestZone;
_bestZone = nullptr; // NOTE: Is this what we want?
_bestZoneVolume = std::numeric_limits<float>::max();
@ -204,7 +207,10 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
}
}
applyZonePropertiesToScene(_bestZone);
if (_bestZone != oldBestZone) {
applyZonePropertiesToScene(_bestZone);
didUpdate = true;
}
});
// Note: at this point we don't need to worry about the tree being locked, because we only deal with
@ -228,11 +234,9 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
}
_currentEntitiesInside = entitiesContainingAvatar;
_lastAvatarPosition = avatarPosition;
return true;
}
}
return false;
return didUpdate;
}
void EntityTreeRenderer::leaveAllEntities() {
@ -322,15 +326,19 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
_ambientTexture.clear();
} else {
_ambientTexture = textureCache->getTexture(zone->getKeyLightProperties().getAmbientURL(), CUBE_TEXTURE);
if (_ambientTexture && _ambientTexture->isLoaded() && _ambientTexture->getGPUTexture()) {
_pendingAmbientTexture = true;
if (_ambientTexture && _ambientTexture->isLoaded()) {
_pendingAmbientTexture = false;
if (_ambientTexture->getGPUTexture()->getIrradiance()) {
sceneKeyLight->setAmbientSphere(_ambientTexture->getGPUTexture()->getIrradiance());
sceneKeyLight->setAmbientMap(_ambientTexture->getGPUTexture());
auto texture = _ambientTexture->getGPUTexture();
if (texture) {
sceneKeyLight->setAmbientSphere(texture->getIrradiance());
sceneKeyLight->setAmbientMap(texture);
isAmbientTextureSet = true;
} else {
qCDebug(entitiesrenderer) << "Failed to load ambient texture:" << zone->getKeyLightProperties().getAmbientURL();
}
} else {
_pendingAmbientTexture = true;
}
}
@ -344,24 +352,27 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
skybox->parse(userData);
}
if (zone->getSkyboxProperties().getURL().isEmpty()) {
skybox->setCubemap(gpu::TexturePointer());
skybox->setCubemap(nullptr);
_pendingSkyboxTexture = false;
_skyboxTexture.clear();
} else {
// Update the Texture of the Skybox with the one pointed by this zone
_skyboxTexture = textureCache->getTexture(zone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
_pendingSkyboxTexture = true;
if (_skyboxTexture && _skyboxTexture->isLoaded()) {
_pendingSkyboxTexture = false;
if (_skyboxTexture && _skyboxTexture->isLoaded() && _skyboxTexture->getGPUTexture()) {
auto texture = _skyboxTexture->getGPUTexture();
skybox->setCubemap(texture);
_pendingSkyboxTexture = false;
if (!isAmbientTextureSet && texture->getIrradiance()) {
if (!isAmbientTextureSet) {
sceneKeyLight->setAmbientSphere(texture->getIrradiance());
sceneKeyLight->setAmbientMap(texture);
isAmbientTextureSet = true;
}
} else {
_pendingSkyboxTexture = true;
skybox->setCubemap(nullptr);
qCDebug(entitiesrenderer) << "Failed to load skybox:" << zone->getSkyboxProperties().getURL();
}
}

View file

@ -146,7 +146,7 @@ public:
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, TextureType type, const QByteArray& content) {
TextureExtra extra = { type, content };
return ResourceCache::getResource(url, QUrl(), false, &extra).staticCast<NetworkTexture>();
return ResourceCache::getResource(url, QUrl(), content.isEmpty(), &extra).staticCast<NetworkTexture>();
}
/// Returns a texture version of an image file

View file

@ -101,8 +101,6 @@ private:
/// A simple object wrapper for an OpenGL texture.
class Texture {
public:
friend class TextureCache;
gpu::TexturePointer getGPUTexture() const { return _textureSource->getGPUTexture(); }
gpu::TextureSourcePointer _textureSource;
};

View file

@ -15,71 +15,68 @@
#include <gpu/Context.h>
#include <ViewFrustum.h>
#include "Skybox_vert.h"
#include "Skybox_frag.h"
#include "skybox_vert.h"
#include "skybox_frag.h"
using namespace model;
Skybox::Skybox() {
Data data;
_dataBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Data), (const gpu::Byte*) &data));
/* // PLease create a default engineer skybox
_cubemap.reset( gpu::Texture::createCube(gpu::Element::COLOR_RGBA_32, 1));
unsigned char texels[] = {
255, 0, 0, 255,
0, 255, 255, 255,
0, 0, 255, 255,
255, 255, 0, 255,
0, 255, 0, 255,
255, 0, 255, 255,
};
_cubemap->assignStoredMip(0, gpu::Element::COLOR_RGBA_32, sizeof(texels), texels);*/
Schema schema;
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema));
}
void Skybox::setColor(const Color& color) {
_dataBuffer.edit<Data>()._color = color;
_schemaBuffer.edit<Schema>().color = color;
}
void Skybox::setCubemap(const gpu::TexturePointer& cubemap) {
_cubemap = cubemap;
}
void Skybox::updateDataBuffer() const {
void Skybox::updateSchemaBuffer() const {
auto blend = 0.0f;
if (getCubemap() && getCubemap()->isDefined()) {
blend = 1.0f;
blend = 0.5f;
// If pitch black neutralize the color
if (glm::all(glm::equal(getColor(), glm::vec3(0.0f)))) {
blend = 2.0f;
blend = 1.0f;
}
}
if (blend != _dataBuffer.get<Data>()._blend) {
_dataBuffer.edit<Data>()._blend = blend;
if (blend != _schemaBuffer.get<Schema>().blend) {
_schemaBuffer.edit<Schema>().blend = blend;
}
}
void Skybox::prepare(gpu::Batch& batch, int textureSlot, int bufferSlot) const {
if (bufferSlot > -1) {
batch.setUniformBuffer(bufferSlot, _schemaBuffer);
}
void Skybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
updateDataBuffer();
Skybox::render(batch, frustum, (*this));
if (textureSlot > -1) {
gpu::TexturePointer skymap = getCubemap();
// FIXME: skymap->isDefined may not be threadsafe
if (skymap && skymap->isDefined()) {
batch.setResourceTexture(textureSlot, skymap);
}
}
}
void Skybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
updateSchemaBuffer();
Skybox::render(batch, frustum, (*this));
}
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
// Create the static shared elements used to render the skybox
static gpu::BufferPointer theConstants;
static gpu::PipelinePointer thePipeline;
const int SKYBOX_SKYMAP_SLOT = 0;
const int SKYBOX_CONSTANTS_SLOT = 0;
static std::once_flag once;
std::call_once(once, [&] {
{
auto skyVS = gpu::Shader::createVertex(std::string(Skybox_vert));
auto skyFS = gpu::Shader::createPixel(std::string(Skybox_frag));
auto skyVS = gpu::Shader::createVertex(std::string(skybox_vert));
auto skyFS = gpu::Shader::createPixel(std::string(skybox_frag));
auto skyShader = gpu::Shader::createProgram(skyVS, skyFS);
gpu::Shader::BindingSet bindings;
@ -98,10 +95,6 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
// Render
gpu::TexturePointer skymap = skybox.getCubemap();
// FIXME: skymap->isDefined may not be threadsafe
assert(skymap && skymap->isDefined());
glm::mat4 projMat;
viewFrustum.evalProjectionMatrix(projMat);
@ -112,11 +105,8 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
batch.setModelTransform(Transform()); // only for Mac
batch.setPipeline(thePipeline);
batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, skybox._dataBuffer);
batch.setResourceTexture(SKYBOX_SKYMAP_SLOT, skymap);
skybox.prepare(batch);
batch.draw(gpu::TRIANGLE_STRIP, 4);
batch.setResourceTexture(SKYBOX_SKYMAP_SLOT, nullptr);
}

View file

@ -30,30 +30,33 @@ public:
virtual ~Skybox() {};
void setColor(const Color& color);
const Color getColor() const { return _dataBuffer.get<Data>()._color; }
const Color getColor() const { return _schemaBuffer.get<Schema>().color; }
void setCubemap(const gpu::TexturePointer& cubemap);
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
void prepare(gpu::Batch& batch, int textureSlot = SKYBOX_SKYMAP_SLOT, int bufferSlot = SKYBOX_CONSTANTS_SLOT) const;
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
protected:
static const int SKYBOX_SKYMAP_SLOT { 0 };
static const int SKYBOX_CONSTANTS_SLOT { 0 };
gpu::TexturePointer _cubemap;
class Data {
class Schema {
public:
glm::vec3 _color{ 1.0f, 1.0f, 1.0f };
float _blend = 1.0f;
glm::vec3 color { 1.0f, 1.0f, 1.0f };
float blend { 0.0f };
};
mutable gpu::BufferView _dataBuffer;
mutable gpu::BufferView _schemaBuffer;
void updateDataBuffer() const;
void updateSchemaBuffer() const;
};
typedef std::shared_ptr< Skybox > SkyboxPointer;
typedef std::shared_ptr<Skybox> SkyboxPointer;
};

View file

@ -1,59 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// skybox.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2015.
// 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
//
uniform samplerCube cubeMap;
struct Skybox {
vec4 _color;
};
uniform skyboxBuffer {
Skybox _skybox;
};
in vec3 _normal;
out vec4 _fragColor;
//PROCEDURAL_COMMON_BLOCK
#line 1001
//PROCEDURAL_BLOCK
#line 2033
void main(void) {
#ifdef PROCEDURAL
vec3 color = getSkyboxColor();
_fragColor = vec4(color, 0.0);
#else
vec3 coord = normalize(_normal);
// Skybox color or blend with skymap
vec3 color = _skybox._color.rgb;
if (_skybox._color.a > 0.0) {
vec3 texel = texture(cubeMap, coord).rgb;
if (_skybox._color.a < 2.0) {
color *= texel;
} else {
color = texel;
}
}
_fragColor = vec4(color, 0.0);
#endif
}

View file

@ -14,11 +14,11 @@
uniform samplerCube cubeMap;
struct Skybox {
vec4 _color;
vec4 color;
};
uniform skyboxBuffer {
Skybox _skybox;
Skybox skybox;
};
in vec3 _normal;
@ -39,11 +39,20 @@ void main(void) {
color = pow(color, vec3(2.2));
_fragColor = vec4(color, 0.0);
#else
// FIXME: scribe does not yet scrub out else statements
return;
#else
vec3 coord = normalize(_normal);
vec3 texel = texture(cubeMap, coord).rgb;
vec3 color = texel * _skybox._color.rgb;
vec3 color = skybox.color.rgb;
// blend is only set if there is a cubemap
if (skybox.color.a > 0.0) {
color = texture(cubeMap, coord).rgb;
if (skybox.color.a < 1.0) {
color *= skybox.color.rgb;
}
}
_fragColor = vec4(color, 0.0);
#endif

View file

@ -101,6 +101,7 @@ bool Procedural::parseUrl(const QUrl& shaderUrl) {
}
_shaderUrl = shaderUrl;
_shaderDirty = true;
if (_shaderUrl.isLocalFile()) {
_shaderPath = _shaderUrl.toLocalFile();
@ -230,7 +231,10 @@ void Procedural::prepare(gpu::Batch& batch, const glm::vec3& position, const glm
if (replaceIndex != std::string::npos) {
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_BLOCK.size(), _shaderSource.toLocal8Bit().data());
}
//qDebug() << "FragmentShader:\n" << fragmentShaderSource.c_str();
// Leave this here for debugging
// qDebug() << "FragmentShader:\n" << fragmentShaderSource.c_str();
_fragmentShader = gpu::Shader::createPixel(fragmentShaderSource);
_shader = gpu::Shader::createProgram(_vertexShader, _fragmentShader);

View file

@ -37,6 +37,7 @@ public:
bool ready();
void prepare(gpu::Batch& batch, const glm::vec3& position, const glm::vec3& size);
const gpu::ShaderPointer& getShader() const { return _shader; }
glm::vec4 getColor(const glm::vec4& entityColor);

View file

@ -15,40 +15,39 @@
#include <gpu/Context.h>
#include <ViewFrustum.h>
#include "ProceduralSkybox_vert.h"
#include "ProceduralSkybox_frag.h"
#include <model/skybox_vert.h>
#include <model/skybox_frag.h>
ProceduralSkybox::ProceduralSkybox() : model::Skybox() {
_procedural._vertexSource = ProceduralSkybox_vert;
_procedural._fragmentSource = ProceduralSkybox_frag;
_procedural._vertexSource = skybox_vert;
_procedural._fragmentSource = skybox_frag;
// Adjust the pipeline state for background using the stencil test
_procedural._state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
}
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
ProceduralSkybox::render(batch, frustum, (*this));
if (_procedural.ready()) {
ProceduralSkybox::render(batch, frustum, (*this));
} else {
Skybox::render(batch, frustum);
}
}
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) {
if (!(skybox._procedural.ready())) {
skybox.updateDataBuffer();
Skybox::render(batch, viewFrustum, skybox);
} else {
gpu::TexturePointer skymap = skybox.getCubemap();
// FIXME: skymap->isDefined may not be threadsafe
assert(skymap && skymap->isDefined());
glm::mat4 projMat;
viewFrustum.evalProjectionMatrix(projMat);
glm::mat4 projMat;
viewFrustum.evalProjectionMatrix(projMat);
Transform viewTransform;
viewFrustum.evalViewTransform(viewTransform);
batch.setProjectionTransform(projMat);
batch.setViewTransform(viewTransform);
batch.setModelTransform(Transform()); // only for Mac
Transform viewTransform;
viewFrustum.evalViewTransform(viewTransform);
batch.setProjectionTransform(projMat);
batch.setViewTransform(viewTransform);
batch.setModelTransform(Transform()); // only for Mac
batch.setResourceTexture(0, skybox.getCubemap());
skybox._procedural.prepare(batch, glm::vec3(0), glm::vec3(1));
batch.draw(gpu::TRIANGLE_STRIP, 4);
}
auto& procedural = skybox._procedural;
procedural.prepare(batch, glm::vec3(0), glm::vec3(1));
auto textureSlot = procedural.getShader()->getTextures().findLocation("cubeMap");
auto bufferSlot = procedural.getShader()->getBuffers().findLocation("skyboxBuffer");
skybox.prepare(batch, textureSlot, bufferSlot);
batch.draw(gpu::TRIANGLE_STRIP, 4);
}

View file

@ -1,39 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// skybox.vert
// vertex shader
//
// Created by Sam Gateau on 5/5/2015.
// 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
//
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
out vec3 _normal;
void main(void) {
const float depth = 0.0;
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, depth, 1.0),
vec4(1.0, -1.0, depth, 1.0),
vec4(-1.0, 1.0, depth, 1.0),
vec4(1.0, 1.0, depth, 1.0)
);
vec4 inPosition = UNIT_QUAD[gl_VertexID];
// standard transform
TransformCamera cam = getTransformCamera();
vec3 clipDir = vec3(inPosition.xy, 0.0);
vec3 eyeDir;
<$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

@ -72,8 +72,8 @@
#include <render-utils/overlay3D_vert.h>
#include <render-utils/overlay3D_frag.h>
#include <model/Skybox_vert.h>
#include <model/Skybox_frag.h>
#include <model/skybox_vert.h>
#include <model/skybox_frag.h>
#include <render-utils/stars_vert.h>
#include <render-utils/stars_frag.h>
@ -157,7 +157,7 @@ void QTestWindow::draw() {
testShaderBuild(DrawTransformUnitQuad_vert, DrawTextureOpaque_frag);
testShaderBuild(DrawTransformUnitQuad_vert, DrawColoredTexture_frag);
testShaderBuild(Skybox_vert, Skybox_frag);
testShaderBuild(skybox_vert, skybox_frag);
testShaderBuild(simple_vert, simple_frag);
testShaderBuild(simple_vert, simple_textured_frag);
testShaderBuild(simple_vert, simple_textured_emisive_frag);
@ -203,8 +203,6 @@ void QTestWindow::draw() {
testShaderBuild(overlay3D_vert, overlay3D_frag);
testShaderBuild(Skybox_vert, Skybox_frag);
testShaderBuild(paintStroke_vert,paintStroke_frag);
testShaderBuild(polyvox_vert, polyvox_frag);