Skip to content

Commit

Permalink
update bilateral cleanup pass
Browse files Browse the repository at this point in the history
  • Loading branch information
WANG-Ruipeng committed Dec 6, 2024
1 parent cb0ed4f commit 318fb14
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions shaders/bilateral_cleanup_pass.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ void main()
vec3 result = vec3(0.0,0.0,0.0);
float weightSum = 0.0;

if(length(centerColor) < 0.0001 || sqrt(variance) < 2.0){
if(length(centerColor) < 0.0001 || variance < 2.0){
imageStore(bilateralCleanupColor, imageCoords, vec4(0.0));
return;
}

// Define sigma values
float sigmaS = clamp (sqrt(variance) , 2.0, 4.0);
float sigmaS = clamp (variance , 2.0, 4.0);
float sigmaR = 0.5;
// Define a kernel radius for the spatial domain
int kernelRadius = int(0.5 * sigmaS);
Expand All @@ -67,7 +67,7 @@ void main()
neighborCoords.x >= imageRes.x || neighborCoords.y >= imageRes.y)
continue;
vec4 neighborColor = imageLoad(filteredReflectionColor, neighborCoords);
if(length (neighborColor.rgb) < 0.001) continue;
if(length (neighborColor.rgb) < 0.1) continue;
// Spatial weight
float dist2 = float(x * x + y * y);
float spatialWeight = exp(-dist2 / (2.0 * sigmaS * sigmaS));
Expand Down
2 changes: 1 addition & 1 deletion shaders/lightPass.frag
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void main()
vec3 diffuseAlbedo = state.mat.albedo * (1.0 - F_SchlickRoughness(state.mat.f0, max(0.0, dot(-camRay.direction, state.normal)), state.mat.roughness)
* (1.0 - state.mat.metallic)) * 0.5;
vec3 directLighting = hit ? vec3(0) : directLight.radiance;
vec3 reflectionColor = texelFetch(filteredReflectionColor, ivec2(gl_FragCoord.xy), 0).rgb;
vec3 reflectionColor = texelFetch(bilateralCleanupColor, ivec2(gl_FragCoord.xy), 0).rgb;

Light randLight = selectRandomLight(114514);
float dist = distance(randLight.position, worldPos);
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int main(int argc, char** argv)
InputParser parser(argc, argv);
//std::string sceneFile = parser.getString("-f", "Sponza/Sponza.gltf");
//std::string sceneFile = parser.getString("-f", "Street/scene.gltf");
std::string sceneFile = parser.getString("-f", "apocal/apocal.gltf");
//std::string sceneFile = parser.getString("-f", "station/station.gltf");
//std::string sceneFile = parser.getString("-f", "apocal/apocal.gltf");
std::string sceneFile = parser.getString("-f", "station/station.gltf");
std::string hdrFilename = parser.getString("-e", "std_env.hdr");

// Setup GLFW window
Expand Down
2 changes: 0 additions & 2 deletions src/sample_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,7 @@ void SampleExample::computeReflection(const VkCommandBuffer& cmdBuf, nvvk::Profi
m_temporalSpatialPass.run(cmdBuf, render_size, profiler, {
m_reflectionComputePass.getSamplerDescSet()
});



vkCmdPipelineBarrier(cmdBuf,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Expand Down

0 comments on commit 318fb14

Please sign in to comment.