New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add depth-of-field (Blurring rendering options) #1662
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Perminder <permindersingh089@gmail.com>
Hi @ghutchis code is functioning correctly, but there are a couple of concerns I'd like your help with. Also I am thinking to add visual tests when the all the requirements will be done. Here's the other PR OpenChemistry/avogadroapp#492
|
This pull request has been mentioned on Avogadro Discussion. There might be relevant details there: https://discuss.avogadro.cc/t/add-depth-of-field-fog-or-blurring-rendering-options/5332/9 |
Signed-off-by: Perminder <permindersingh089@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review of Shader Code Enhancements
The proposed changes to the shader code, including enhanced randomness in the rand
function, dynamic sample adjustment, and smoother weight transitions using smoothstep
, significantly improve performance and visual quality. These updates are well-aligned with best practices for rendering optimizations.
@ghutchis , could you please review these enhancements and provide your feedback?
|
||
float total = 1.0; | ||
vec4 color = texture2D(inRGBTex, texCoord); | ||
// number of samples can be optimized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int numSamples = int(clamp(blurAmt * 64.0, 16.0, 64.0));
// dynamically reduce number of samples based on blur amount
for (int i = 0; i < numSamples; i++) {
// Remaining loop code of blur application...
}
@ghutchis your reviews for the changes proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. I'll definitely make time to address the suggestions. However, regarding this issue, the loop index can't be compared with a non-constant expression. Therefore, adding numSamples
to the for loop won't function since its value isn't constant. Could also leads to error. Are you sure about this one??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, and I appreciate your careful consideration. While GLSL 1.2 does support dynamic looping, the behavior can indeed vary based on the GPU and driver support. Sticking with your current approach to ensure compatibility and stability is wise. Thank you for pointing this out, @guthichs, and your reviews and help are greatly appreciated!
@@ -66,6 +68,47 @@ float lerp(float a, float b, float f) | |||
return a + f * (b - a); | |||
} | |||
|
|||
float rand(vec2 co){ | |||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float rand(vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,78.233)) + cos(dot(co.xy, vec2(93.9898,50.233)))) * 43758.5453);
}
//more complex pattern produced which helps in reducing the noise. @ghutchis your insights ?
vec2 offset = (vec2(cos(angle), sin(angle)) * radius * 0.05 * blurAmt) / pixelScale; | ||
float z = depthToZ(texture2D(inDepthTex, texCoord + offset).x); | ||
float sampleBlur = calcBlur(z, pixelScale); | ||
float weight = float((z >= origZ) || (sampleBlur >= blurAmt * radius + 0.)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float weight = 1.0 - smoothstep(0.0, 1.0, abs(z - origZ) / blurAmt);
// using smoothstep to soften weight transitions
This modification uses smoothstep to create a more gradual transition in weights applied to sampled colors, potentially reducing artifacts like banding. Reviews @ghutchis
issue : #347
Signed-off by : permindersingh089@gmail.com
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.