Added flag to enable / disable ambient fresnel LUT

This commit is contained in:
Olivier Prat 2019-04-05 08:58:06 +02:00
parent b71a8f7902
commit 361371b2a9
3 changed files with 12 additions and 4 deletions

View file

@ -30,13 +30,13 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
LAYOUT(binding=RENDER_UTILS_TEXTURE_AMBIENT_FRESNEL) uniform sampler2D ambientFresnelLUT;
vec3 fresnelSchlickAmbient(vec3 fresnelColor, float ndotd, float roughness) {
#if 0
#if RENDER_UTILS_ENABLE_AMBIENT_FRESNEL_LUT
vec2 ambientFresnel = texture(ambientFresnelLUT, vec2(roughness, ndotd)).xy;
return fresnelColor * ambientFresnel.x + vec3(ambientFresnel.y);
#else
float gloss = 1.0-roughness;
float f = pow(1.0 - ndotd, 5.0);
return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * f;
#else
vec2 ambientFresnel = texture(ambientFresnelLUT, vec2(roughness, ndotd)).xy;
return fresnelColor * ambientFresnel.x + vec3(ambientFresnel.y);
#endif
}

View file

@ -12,6 +12,8 @@
#include "RandomAndNoise.h"
#include "BRDF.h"
#include "render-utils/ShaderConstants.h"
#include <tbb/parallel_for.h>
#include <tbb/blocked_range2d.h>
@ -21,6 +23,7 @@ LightingModel::LightingModel() {
Parameters parameters;
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters, sizeof(Parameters)));
#if RENDER_UTILS_ENABLE_AMBIENT_FRESNEL_LUT
if (!_ambientFresnelLUT) {
// Code taken from the IntegrateBRDF method as described in this talk :
// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
@ -88,6 +91,7 @@ LightingModel::LightingModel() {
_ambientFresnelLUT->assignStoredMip(0, N_roughness * N_NdotV * sizeof(LUTVector::value_type), (const gpu::Byte*)lut.data());
}
#endif
}
void LightingModel::setUnlit(bool enable) {

View file

@ -14,6 +14,10 @@
#ifndef RENDER_UTILS_SHADER_CONSTANTS_H
#define RENDER_UTILS_SHADER_CONSTANTS_H
// Feature enabling flags (possibly need to rebuild shaders if this changes)
#define RENDER_UTILS_ENABLE_AMBIENT_FRESNEL_LUT 1
// Binding slots
#define RENDER_UTILS_ATTR_TEXCOORD01 0
#define RENDER_UTILS_ATTR_COLOR 1