mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 20:15:15 +02:00
CLeaning up and debugging the splotch
This commit is contained in:
parent
884b9211c6
commit
e95a31f760
6 changed files with 26 additions and 23 deletions
|
@ -178,21 +178,17 @@ vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, f
|
|||
vec3 bentNormalLow = normalize( (diffusedCurvature.xyz - 0.5f) * 2.0f );
|
||||
float curvature = unpackCurvature(diffusedCurvature.w);
|
||||
|
||||
|
||||
vec3 rS = bentNormalHigh;
|
||||
|
||||
vec3 bendFactorSpectrum = getBendFactor();
|
||||
vec3 rN = normalize(mix(normal, bentNormalLow, bendFactorSpectrum.x));
|
||||
// vec3 rN = normalize(mix(normal, bentNormalLow, bendFactorSpectrum.x));
|
||||
vec3 rN = normalize(mix(bentNormalHigh, bentNormalLow, bendFactorSpectrum.x));
|
||||
vec3 gN = normalize(mix(bentNormalHigh, bentNormalLow, bendFactorSpectrum.y));
|
||||
vec3 bN = normalize(mix(bentNormalHigh, bentNormalLow, bendFactorSpectrum.z));
|
||||
|
||||
|
||||
/* vec3 rN = normalize(mix(normal, bentNormalHigh, bendFactorSpectrum.x));
|
||||
vec3 gN = normalize(mix(normal, bentNormalHigh, bendFactorSpectrum.y));
|
||||
vec3 bN = normalize(mix(normal, bentNormalHigh, bendFactorSpectrum.z));
|
||||
*/
|
||||
vec3 NdotLSpectrum = vec3(dot(rN, fragLightDir), dot(gN, fragLightDir), dot(bN, fragLightDir));
|
||||
|
||||
//return 0.5 * (NdotLSpectrum + vec3(1.0));
|
||||
// --> Look up the pre-integrated curvature-dependent BDRF textures
|
||||
vec3 brdf = fetchBRDFSpectrum(NdotLSpectrum, curvature);
|
||||
|
||||
|
@ -218,7 +214,8 @@ vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, f
|
|||
if (scatteringLevel < 0.1) {
|
||||
brdf = vec3(standardDiffuse);
|
||||
}
|
||||
vec3 color = vec3(albedo * vec3(brdf.xyz) * shading.w + shading.rgb) * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
vec3 color = vec3(albedo * vec3(brdf.xyz) * shading.w + shading.rgb) * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
|
||||
// Diffuse from ambient
|
||||
|
@ -230,7 +227,11 @@ vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, f
|
|||
|
||||
if ( showBRDF())
|
||||
return brdf;
|
||||
return vec3(color);
|
||||
|
||||
vec3 debugNdotL = 0.5 * (NdotLSpectrum + vec3(1.0));
|
||||
return vec3(debugNdotL.z, curvature, 0.0 );
|
||||
|
||||
return vec3(color);
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
|
|
|
@ -636,8 +636,8 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
|||
_subsurfaceScatteringResource->generateScatteringTable(renderContext->args);
|
||||
}
|
||||
|
||||
auto& deferredTransform = inputs.get0();
|
||||
auto& diffusedCurvature2 = inputs.get2()->getRenderBuffer(0);
|
||||
auto deferredTransform = inputs.get0();
|
||||
auto diffusedCurvature2 = inputs.get2()->getRenderBuffer(0);
|
||||
setupJob.run(sceneContext, renderContext, deferredTransform, diffusedCurvature2, _subsurfaceScatteringResource);
|
||||
|
||||
lightsJob.run(sceneContext, renderContext, deferredTransform, _enablePointLights, _enableSpotLights);
|
||||
|
|
|
@ -124,8 +124,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
|||
addJob<DrawLight>("DrawLight", lights);
|
||||
|
||||
const auto deferredLightingInputs = render::Varying(RenderDeferred::Inputs(deferredFrameTransform, curvatureFramebuffer, diffusedCurvatureFramebuffer));
|
||||
// const auto scatteringFramebuffer = addJob<SubsurfaceScattering>("Scattering", scatteringInputs);
|
||||
|
||||
|
||||
// DeferredBuffer is complete, now let's shade it into the LightingBuffer
|
||||
addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
|
||||
|
||||
|
@ -136,6 +135,8 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
|||
// Render transparent objects forward in LightingBuffer
|
||||
addJob<DrawDeferred>("DrawTransparentDeferred", transparents, shapePlumber);
|
||||
|
||||
const auto scatteringFramebuffer = addJob<SubsurfaceScattering>("Scattering", deferredLightingInputs);
|
||||
|
||||
// Lighting Buffer ready for tone mapping
|
||||
addJob<ToneMappingDeferred>("ToneMapping");
|
||||
|
||||
|
|
|
@ -220,10 +220,10 @@ void SubsurfaceScattering::run(const render::SceneContextPointer& sceneContext,
|
|||
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
|
||||
if (!updateScatteringFramebuffer(curvatureFramebuffer, scatteringFramebuffer)) {
|
||||
/* if (!updateScatteringFramebuffer(curvatureFramebuffer, scatteringFramebuffer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
const auto theLight = DependencyManager::get<DeferredLightingEffect>()->getLightStage().lights[0];
|
||||
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
@ -231,7 +231,7 @@ void SubsurfaceScattering::run(const render::SceneContextPointer& sceneContext,
|
|||
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
|
||||
batch.setFramebuffer(_scatteringFramebuffer);
|
||||
/* batch.setFramebuffer(_scatteringFramebuffer);
|
||||
|
||||
batch.setPipeline(pipeline);
|
||||
|
||||
|
@ -251,7 +251,7 @@ void SubsurfaceScattering::run(const render::SceneContextPointer& sceneContext,
|
|||
batch.setResourceTexture(ScatteringTask_LinearMapSlot, framebufferCache->getDepthPyramidTexture());
|
||||
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
|
||||
*/
|
||||
if (_showLUT) {
|
||||
auto viewportSize = std::min(args->_viewport.z, args->_viewport.w) >> 1;
|
||||
batch.setViewportTransform(glm::ivec4(0, 0, viewportSize, viewportSize));
|
||||
|
@ -359,9 +359,9 @@ void diffuseScatter(gpu::TexturePointer& lut) {
|
|||
vec3 val = integrate(x, y);
|
||||
|
||||
// Convert to linear
|
||||
val.x = sqrt(val.x);
|
||||
val.y = sqrt(val.y);
|
||||
val.z = sqrt(val.z);
|
||||
// val.x = sqrt(val.x);
|
||||
// val.y = sqrt(val.y);
|
||||
// val.z = sqrt(val.z);
|
||||
|
||||
// Convert to 24-bit image.
|
||||
unsigned char valI[3];
|
||||
|
@ -464,7 +464,7 @@ void diffuseProfile(gpu::TexturePointer& profile) {
|
|||
|
||||
gpu::TexturePointer SubsurfaceScatteringResource::generatePreIntegratedScattering(RenderArgs* args) {
|
||||
|
||||
auto profileMap = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, 128, 1, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
auto profileMap = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, 256, 1, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
diffuseProfile(profileMap);
|
||||
|
||||
const int WIDTH = 128;
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
float curvatureOffset{ 0.08f };
|
||||
float curvatureScale{ 0.8f };
|
||||
|
||||
bool showLUT{ false };
|
||||
bool showLUT{ true };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
uniform sampler2D scatteringLUT;
|
||||
|
||||
vec3 fetchBRDF(float LdotN, float curvature) {
|
||||
return texture(scatteringLUT, vec2( clamp(LdotN * 0.5 + 0.5, 0.0, 1.0), curvature)).xyz;
|
||||
return texture(scatteringLUT, vec2( clamp(LdotN * 0.5 + 0.5, 0.0, 1.0), clamp(2 * curvature, 0.0, 1.0))).xyz;
|
||||
}
|
||||
|
||||
vec3 fetchBRDFSpectrum(vec3 LdotNSpectrum, float curvature) {
|
||||
|
@ -50,4 +50,5 @@ float unpackCurvature(float packedCurvature) {
|
|||
return abs(packedCurvature * 2 - 1) * parameters.curvatureInfo.y + parameters.curvatureInfo.x;
|
||||
}
|
||||
|
||||
|
||||
<@endfunc@>
|
||||
|
|
Loading…
Reference in a new issue