Merge branch 'hdr' of https://github.com/samcake/hifi into hdr

This commit is contained in:
samcake 2015-12-06 10:53:57 -08:00
commit d2081dc6bb
5 changed files with 23 additions and 28 deletions

View file

@ -52,7 +52,8 @@ void main(void) {
}
}
vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
// vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
vec3 pixel = color;
_fragColor = vec4(pixel, 0.0);
#endif

View file

@ -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);
}

View file

@ -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@>

View file

@ -179,8 +179,11 @@ 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->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);*/
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 +375,21 @@ 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.setStateScissorRect(args->_viewport);
batch.setViewportTransform(args->_viewport);
batch.setStateScissorRect(args->_viewport);
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;

View file

@ -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(