Skip to content
Snippets Groups Projects
Commit 5621b194 authored by Adam Nyberg's avatar Adam Nyberg
Browse files

Discared smoothing thicknes fro backrgound piels, fluid now looks better

parent 9f803c87
No related branches found
No related tags found
No related merge requests found
......@@ -100,8 +100,17 @@ void main()
vec3 finalColor = fluidColor * lighting;
finalColor += fluidColor * fresnel;
//---------------------------------------
// Attenuation
//---------------------------------------
float attenuation = texture(uLightAttenTex, TexCoords).r;
finalColor *= attenuation;
float alpha = texture(uLightAttenTex, TexCoords).a;
// float alpha = clamp(1.0 - attenuation, 0.0, 1.0);
//---------------------------------------
// 5) Output
//---------------------------------------
FragColor = vec4(finalColor, 1.0);
FragColor = vec4(finalColor, alpha);
}
......@@ -19,7 +19,7 @@ void main()
discard;
// For thickness: each particle in this pixel adds some amount.
float thicknessIncrement = 0.04;
float thicknessIncrement = 0.08;
// Output that in the red channel. Using GL32F only reed chanele sotred
FragColor = vec4(thicknessIncrement, 0.0, 0.0, 1.0);
......
......@@ -24,5 +24,15 @@ void main()
// to be fully absorbing, you do: finalColor = fluidColor * (1 - attenuation), etc.)
//vec3 color = fluidColor * (1 - attenuation);
//FragColor = vec4(color, 1.0);
FragColor = vec4(attenuation, 0.0, 0.0, 1.0);
float alpha = 0;
if(thicknessVal < 0.001) {
// Background
alpha = 0;
} else
{
alpha = clamp((1.0 - attenuation)*4, 0.0, 1.0);
}
FragColor = vec4(attenuation, 0.0, 0.0, alpha);
}
......@@ -16,6 +16,8 @@ void main()
// Sample center
float centerVal = texture(uThicknessTex, TexCoords).r;
if (centerVal < 0.01) discard;
// Accumulate for a 1D Gaussian blur
float sum = 0.0;
float wSum = 0.0;
......@@ -28,6 +30,8 @@ void main()
float sampleVal = texture(uThicknessTex, sampleUV).r;
//if (sampleVal < 0.01) continue;
// Spatial weight from precomputed array
float w = gaussWeights[abs(i)];
......
......@@ -989,7 +989,7 @@ void FluidRenderer::renderThicknessAttenFrame()
glUniform1i(glGetUniformLocation(m_thicknessAttenProgram.programID, "uThicknessTex"), 0);
// 3) Set uniform: absorption, fluidColor, etc.
float absorption = 0.8f; // tweak to taste
float absorption = 0.2f; // tweak to taste
GLuint absorpLoc = glGetUniformLocation(m_thicknessAttenProgram.programID, "absorption");
glUniform1f(absorpLoc, absorption);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment