mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 11:53:28 +02:00
Merge pull request #6576 from samcake/hdr
Graphics: Fix the broken background rendering
This commit is contained in:
commit
4cf0f091af
15 changed files with 32 additions and 439 deletions
|
@ -52,8 +52,7 @@ void main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
|
||||
_fragColor = vec4(pixel, 0.0);
|
||||
_fragColor = vec4(color, 0.0);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular,
|
|||
discard;
|
||||
}
|
||||
|
||||
_fragColor0 = vec4(diffuse.rgb, alpha);
|
||||
_fragColor0 = vec4(diffuse.rgb, 1.0); // Opaque
|
||||
_fragColor1 = vec4(bestFitNormal(normal), 1.0);
|
||||
_fragColor2 = vec4(specular, shininess / 128.0);
|
||||
}
|
||||
|
@ -61,9 +61,8 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 s
|
|||
discard;
|
||||
}
|
||||
|
||||
_fragColor0 = vec4(diffuse.rgb, alpha);
|
||||
//_fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||
_fragColor1 = vec4(bestFitNormal(normal), 0.5);
|
||||
_fragColor0 = vec4(diffuse.rgb, 0.5);
|
||||
_fragColor1 = vec4(bestFitNormal(normal), 1.0);
|
||||
_fragColor2 = vec4(emissive, shininess / 128.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 sp
|
|||
vec3 schlick = specular * (1.0 - shlickPower5) + vec3(shlickPower5);
|
||||
vec3 reflect = specularPower * schlick;
|
||||
|
||||
return vec4(reflect, diffuse * (1 - length(schlick)));
|
||||
// FIXME:
|
||||
//return vec4(reflect, diffuse * (1 - length(schlick)));
|
||||
return vec4(reflect, diffuse);
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
|
|
|
@ -34,16 +34,8 @@
|
|||
#include "deferred_light_spot_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"
|
||||
|
@ -51,8 +43,6 @@
|
|||
static const std::string glowIntensityShaderHandle = "glowIntensity";
|
||||
|
||||
struct LightLocations {
|
||||
int shadowDistances;
|
||||
int shadowScale;
|
||||
int radius;
|
||||
int ambientSphere;
|
||||
int lightBufferUnit;
|
||||
|
@ -107,34 +97,16 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
|||
|
||||
_viewState = viewState;
|
||||
_directionalLightLocations = std::make_shared<LightLocations>();
|
||||
_directionalLightShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_directionalLightCascadedShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
|
||||
_directionalAmbientSphereLightShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_directionalAmbientSphereLightCascadedShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_directionalSkyboxLightLocations = std::make_shared<LightLocations>();
|
||||
_directionalSkyboxLightShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_directionalSkyboxLightCascadedShadowMapLocations = std::make_shared<LightLocations>();
|
||||
_pointLightLocations = std::make_shared<LightLocations>();
|
||||
_spotLightLocations = std::make_shared<LightLocations>();
|
||||
|
||||
loadLightProgram(deferred_light_vert, directional_light_frag, false, _directionalLight, _directionalLightLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_light_shadow_map_frag, false, _directionalLightShadowMap,
|
||||
_directionalLightShadowMapLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_light_cascaded_shadow_map_frag, false, _directionalLightCascadedShadowMap,
|
||||
_directionalLightCascadedShadowMapLocations);
|
||||
|
||||
loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_map_frag, false, _directionalAmbientSphereLightShadowMap,
|
||||
_directionalAmbientSphereLightShadowMapLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_ambient_light_cascaded_shadow_map_frag, false, _directionalAmbientSphereLightCascadedShadowMap,
|
||||
_directionalAmbientSphereLightCascadedShadowMapLocations);
|
||||
|
||||
loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_map_frag, false, _directionalSkyboxLightShadowMap,
|
||||
_directionalSkyboxLightShadowMapLocations);
|
||||
loadLightProgram(deferred_light_vert, directional_skybox_light_cascaded_shadow_map_frag, false, _directionalSkyboxLightCascadedShadowMap,
|
||||
_directionalSkyboxLightCascadedShadowMapLocations);
|
||||
|
||||
|
||||
loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations);
|
||||
|
@ -179,8 +151,8 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
|||
//auto blitProgram = gpu::StandardShaderLib::getProgram(gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS, gpu::StandardShaderLib::getDrawTexturePS);
|
||||
gpu::Shader::makeProgram(*blitProgram);
|
||||
auto blitState = std::make_shared<gpu::State>();
|
||||
blitState->setColorWriteMask(true, true, true, false);
|
||||
_blitLightBuffer = gpu::Pipeline::create(blitProgram, blitState);
|
||||
blitState->setColorWriteMask(true, true, true, true);
|
||||
_blitLightBuffer = gpu::PipelinePointer(gpu::Pipeline::create(blitProgram, blitState));
|
||||
}
|
||||
|
||||
// Allocate a global light representing the Global Directional light casting shadow (the sun) and the ambient light
|
||||
|
@ -372,11 +344,27 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
|
|||
void DeferredLightingEffect::prepare(RenderArgs* args) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
// Clear Lighting buffer
|
||||
auto lightingFbo = DependencyManager::get<FramebufferCache>()->getLightingFramebuffer();
|
||||
|
||||
batch.setFramebuffer(lightingFbo);
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(vec3(0), 0), true);
|
||||
|
||||
// Clear deferred
|
||||
auto deferredFbo = DependencyManager::get<FramebufferCache>()->getDeferredFramebuffer();
|
||||
|
||||
batch.setFramebuffer(deferredFbo);
|
||||
|
||||
// Clear Color, Depth and Stencil
|
||||
batch.clearFramebuffer(
|
||||
gpu::Framebuffer::BUFFER_COLOR0 |
|
||||
gpu::Framebuffer::BUFFER_DEPTH |
|
||||
gpu::Framebuffer::BUFFER_STENCIL,
|
||||
vec4(vec3(0), 1), 1.0, 0.0, true);
|
||||
|
||||
// clear the normal and specular buffers
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR1, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), true);
|
||||
const float MAX_SPECULAR_EXPONENT = 128.0f;
|
||||
|
@ -406,10 +394,8 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
|||
auto lightingFBO = framebufferCache->getLightingFramebuffer();
|
||||
batch.setFramebuffer(lightingFBO);
|
||||
|
||||
// Clearing it
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
batch.clearColorFramebuffer(lightingFBO->getBufferMask(), glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), true);
|
||||
|
||||
// BInd the G-Buffer surfaces
|
||||
batch.setResourceTexture(0, framebufferCache->getDeferredColorTexture());
|
||||
|
@ -755,7 +741,6 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
|||
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), 1));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), 2));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), 3));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("shadowMap"), 4));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), 5));
|
||||
const int LIGHT_GPU_SLOT = 3;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), LIGHT_GPU_SLOT));
|
||||
|
@ -766,8 +751,6 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
|||
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
locations->shadowDistances = program->getUniforms().findLocation("shadowDistances");
|
||||
locations->shadowScale = program->getUniforms().findLocation("shadowScale");
|
||||
|
||||
locations->radius = program->getUniforms().findLocation("radius");
|
||||
locations->ambientSphere = program->getUniforms().findLocation("ambientSphere.L00");
|
||||
|
@ -780,6 +763,10 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
|||
locations->deferredTransformBuffer = program->getBuffers().findLocation("deferredTransformBuffer");
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
// Stencil test all the light passes for objects pixels only, not the background
|
||||
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::NOT_EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
|
||||
|
||||
if (lightVolume) {
|
||||
state->setCullMode(gpu::State::CULL_BACK);
|
||||
|
||||
|
|
|
@ -106,24 +106,12 @@ private:
|
|||
|
||||
gpu::PipelinePointer _directionalSkyboxLight;
|
||||
LightLocationsPtr _directionalSkyboxLightLocations;
|
||||
gpu::PipelinePointer _directionalSkyboxLightShadowMap;
|
||||
LightLocationsPtr _directionalSkyboxLightShadowMapLocations;
|
||||
gpu::PipelinePointer _directionalSkyboxLightCascadedShadowMap;
|
||||
LightLocationsPtr _directionalSkyboxLightCascadedShadowMapLocations;
|
||||
|
||||
gpu::PipelinePointer _directionalAmbientSphereLight;
|
||||
LightLocationsPtr _directionalAmbientSphereLightLocations;
|
||||
gpu::PipelinePointer _directionalAmbientSphereLightShadowMap;
|
||||
LightLocationsPtr _directionalAmbientSphereLightShadowMapLocations;
|
||||
gpu::PipelinePointer _directionalAmbientSphereLightCascadedShadowMap;
|
||||
LightLocationsPtr _directionalAmbientSphereLightCascadedShadowMapLocations;
|
||||
|
||||
gpu::PipelinePointer _directionalLight;
|
||||
LightLocationsPtr _directionalLightLocations;
|
||||
gpu::PipelinePointer _directionalLightShadowMap;
|
||||
LightLocationsPtr _directionalLightShadowMapLocations;
|
||||
gpu::PipelinePointer _directionalLightCascadedShadowMap;
|
||||
LightLocationsPtr _directionalLightCascadedShadowMapLocations;
|
||||
|
||||
gpu::PipelinePointer _pointLight;
|
||||
LightLocationsPtr _pointLightLocations;
|
||||
|
|
|
@ -92,6 +92,7 @@ void FramebufferCache::createPrimaryFramebuffer() {
|
|||
// _lightingTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::HALF, gpu::RGBA), width, height, defaultSampler));
|
||||
_lightingFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
_lightingFramebuffer->setRenderBuffer(0, _lightingTexture);
|
||||
_lightingFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
|
||||
}
|
||||
|
||||
gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() {
|
||||
|
|
|
@ -35,24 +35,6 @@
|
|||
|
||||
using namespace render;
|
||||
|
||||
void SetupDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||
RenderArgs* args = renderContext->args;
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
auto deferredFbo = DependencyManager::get<FramebufferCache>()->getDeferredFramebufferDepthColor();
|
||||
|
||||
batch.enableStereo(false);
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
batch.setFramebuffer(deferredFbo);
|
||||
batch.clearFramebuffer(
|
||||
gpu::Framebuffer::BUFFER_COLOR0 |
|
||||
gpu::Framebuffer::BUFFER_DEPTH |
|
||||
gpu::Framebuffer::BUFFER_STENCIL,
|
||||
vec4(vec3(0), 1), 1.0, 0.0, true);
|
||||
});
|
||||
}
|
||||
|
||||
void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||
DependencyManager::get<DeferredLightingEffect>()->prepare(renderContext->args);
|
||||
|
@ -68,8 +50,6 @@ void ResolveDeferred::run(const SceneContextPointer& sceneContext, const RenderC
|
|||
}
|
||||
|
||||
RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||
_jobs.push_back(Job(new SetupDeferred::JobModel("SetupFramebuffer")));
|
||||
|
||||
_jobs.push_back(Job(new PrepareDeferred::JobModel("PrepareDeferred")));
|
||||
_jobs.push_back(Job(new FetchItems::JobModel("FetchOpaque",
|
||||
FetchItems(
|
||||
|
@ -375,12 +355,11 @@ void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const
|
|||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
|
||||
auto deferredFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getDeferredFramebufferDepthColor();
|
||||
auto deferredFboFull = DependencyManager::get<FramebufferCache>()->getDeferredFramebuffer();
|
||||
auto lightingFBO = DependencyManager::get<FramebufferCache>()->getLightingFramebuffer();
|
||||
|
||||
batch.enableSkybox(true);
|
||||
|
||||
batch.setFramebuffer(deferredFboColorDepthStencil);
|
||||
batch.setFramebuffer(lightingFBO);
|
||||
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
@ -395,8 +374,6 @@ void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const
|
|||
|
||||
renderItems(sceneContext, renderContext, inItems);
|
||||
|
||||
batch.setFramebuffer(deferredFboFull);
|
||||
|
||||
});
|
||||
args->_batch = nullptr;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ void main(void) {
|
|||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/3/14.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalAmbientSphereGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalAmbienSphereGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/3/14.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalAmbientSphereGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalAmbienSphereGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/3/14.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalAmbientGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalAmbienGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/3/14.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalAmbientGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalAmbienGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Sam Gateau on 5/8/2015.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalSkyboxGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalCascadedShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalSkyboxGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// directional_light.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Sam Gateau on 5/8/2015.
|
||||
// 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
|
||||
//
|
||||
|
||||
// Everything about deferred buffer
|
||||
<@include DeferredBuffer.slh@>
|
||||
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<$declareEvalSkyboxGlobalColor()$>
|
||||
|
||||
// Everything about shadow
|
||||
<@include Shadow.slh@>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
||||
|
||||
// Eval shadow Texcoord and then Attenuation
|
||||
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
|
||||
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
|
||||
|
||||
// Light mapped or not ?
|
||||
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
|
||||
vec3 color = evalLightmappedColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
} else {
|
||||
vec3 color = evalSkyboxGlobalColor(
|
||||
deferredTransform.viewInverse,
|
||||
shadowAttenuation,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specular,
|
||||
frag.gloss);
|
||||
|
||||
_fragColor = vec4(color, frag.normalVal.a);
|
||||
}
|
||||
}
|
|
@ -35,16 +35,10 @@
|
|||
#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"
|
||||
|
@ -185,14 +179,8 @@ void QTestWindow::draw() {
|
|||
testShaderBuild(simple_vert, simple_textured_frag);
|
||||
testShaderBuild(simple_vert, simple_textured_emisive_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);
|
||||
|
|
Loading…
Reference in a new issue