Skip to content
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

Bug in GLSL code for examples/Topics/Shaders/Nebula #20

Open
pjfordham opened this issue May 2, 2023 · 0 comments
Open

Bug in GLSL code for examples/Topics/Shaders/Nebula #20

pjfordham opened this issue May 2, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@pjfordham
Copy link

pjfordham commented May 2, 2023

Issue description

When you run this example, opaque black regions occasionally appear in the visualization. This appears to be caused by the surface3 function returning values larger than 1.0 due to the way it sums various different frequencies of noise. When the value is larger than 1.0 the calculated color can end up negative which results in the opaque black sections.

URL(s) of affected page(s)

Proposed fix

float surface3 ( vec3 coord, float frequency ) {

float n = 0.0;	
	
n += (0.5     + 0.00625) * abs( cnoise4( coord * frequency ) );
n += (0.25    + 0.00625) * abs( cnoise4( coord * frequency * 2.0 ) );
n += (0.125   + 0.00625) * abs( cnoise4( coord * frequency * 4.0 ) );
n += (0.0625  + 0.00625) * abs( cnoise4( coord * frequency * 8.0 ) );
n += (0.03125 + 0.00625) * abs( cnoise4( coord * frequency * 16.0 ) );

return n;
}

This suggested new version of surface3 ensures that the return value is never greater than 1 by weighting the noise frequencies more appropriately. I have reduced the main weighting of each frequency by half and added back a small extra bit to ensure the total of all the weights is 1, while maintaining approximately the same intended distribution.

The result is a little more nebula heavy than the original so more tweaking might be needed by those with a better eye for graphic design than me.

@SableRaf SableRaf added the enhancement New feature or request label May 2, 2023
@SableRaf SableRaf transferred this issue from processing/processing-docs May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants