-
Notifications
You must be signed in to change notification settings - Fork 18
Chaos overhaul (new branch) #561
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
Conversation
|
See #540 for previous comments on the development of this. |
|
Three comments so far:
|
This comment was marked as resolved.
This comment was marked as resolved.
And when you resize to a very small screen height, numbers to the top are clipped, and the numbers seem much larger than they need to be: |
|
The "Divisor Square" specimen does not seem to be updated for the revised visualizer. Perhaps that's implicit in the unchecked "featured specimen" box at the top. |
|
Does the name refer to the embedded orange-red Sierpinski triangle? It is pretty, but not more so than Divisor Square and it's not clear to me it's worth having two featured specimens based on the same A000005 sequence... and I would say DivisorSquare has a somewhat better "Change Sequence" tableau. Isn't there some Chaos instance showing a bias in the distribution of primes among residue classes to some modulus? Would that make a good specimen? |
gwhitney
left a comment
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.
OK, here's a pass through the docs and code. Given there's a bunch of items, I'll presumably make another pass when these are resolved. (Some may not need any changes.)
|
I've pushed most of the suggested code tweaks, so you can resolve many of them (if I didn't respond, I'm assuming it's ok and you'll probably resolve unless I misunderstood the guidance). |
|
Also lint passes on my machine, I wonder if my lint is a different version? |
|
But finally, I'm a bit frustrated with fade. After your comment that my suggestion of putting a translucent rectangle over the picture to fade was not "artificial", I added such a feature. Whether or not it is performant enough to keep it, it has highlighted some real issues going on. I'm too tired to keep at it now, so if in the meantime you want to look at this URL: |
This comment was marked as outdated.
This comment was marked as outdated.
|
I reverted the change that broke compiling. |
Systematizes the variables that can be used in each formula, so that lower-case versions always refer to the prior step or value, and upper-case to the new/current step or value. Also conforms symbols to other visualizers. And updates docs.
Yes, I see what you mean. I am tired at the moment too, so I will take another stab when I next get to this. I suspect the issue is that you are drawing the fade overlay every dot, as far as I can see. So it's adding a lot of polygons to the "chunks". Any chance you'd be content with just drawing one overlay per frame? That would "cluster" the fade levels, but I hypothesize it will reduce the processing burden significantly. I will give it a try sometime soon and if it looks OK to me, push it for you to try out and see what you think. |
|
OK, there were some indexing difficulties that caused the fast initial phase followed by the slow period -- basically once there was at least one chunk, it was redrawing all the dots on every frame. Now the difficulty is that when it makes the chunks, all of the dots in the chunk are at the same unfaded intensity, and then the chunks are re-drawn and don't get faded. So I will need to (a) when making a chunk, for each dot, figure out how many times it would be faded, then draw it in its dot color faded that many times, and (b) just before displaying each chunk, fade the number of times that would occur during the normal drawing of those dots. Of course, all of these multiple fadings can be done by precomputing the proper derived color/opacity and fading once -- I just need to figure out the formulas. |
|
All right, I have put in code for (a) and (b). It turns out there was a complication -- I had implemented the Chroma overlay function incorrectly, and I had used a poor definition of scalar multiplication: if we are going to define However, I have not quite gotten the fading completely smooth. For example, try this example of just watching three simultaneous more-or-less ordinary random walks on the integer lattice: http://localhost:5173/?name=ThreeStaggered&viz=Chaos&walkers=3&stepFormula=0.02&colorFormula=rainbow%28W*360%2Fh%29&pixelsPerFrame=3&fadeEffect=0.02&seq=Random&max=3 (I recommend you zoom in somewhat) You will see that it fades out nicely, except that every now and then a bunch of the older stuff gets much lighter all at once. So on average, it seems to fade out about as rapidly as I'd expect, but it's jerky. I think it has to do with the chunking -- maybe I haven't quite gotten my counts of the number of fades in different circumstances consistent, or maybe there's still some issue in the fade formula -- possibly a numerical one, because the scalar multiplication formula does now involve raising the transparency ( = 1 - alpha) to the scalar power. So for a large scalar (lots of fades), we're visually comparing the result of that exponentiation done in floats, to the results of overdrawing that number of times on an eight-bit-per-channel graphics buffer. So maybe rounding issues in overdrawing the fade 30 times to 8-bit accuracy produces a significantly lesser fade than precomputing the effect of 30 fades in full 64-bit IEEE floating-point arithmetic. That would explain why I can't see the effect at larger fade rates, nor when there are more pixels per frame (= less frequent fades, since there is one fade per frame). The more I think about it and experiment, the more likely it seems that is what is going on. For example, if you take your sample URL above (not mine), and let it run to completion, and then drag it a bit but then stop moving the mouse with the button still down, you will see it fades out (because it keeps drawing more frames, and fades once each time, with nothing new being drawn because it has finished the sequence). But this fade out stops with a faint "ghost" of the pattern, and doesn't get any dimmer than that. I suspect because of 8-bit numerical issues in drawing the faint, just slightly opaque overlay over the very dim dots, it ends reaching a fixed point just shy of all channels equal to 0. So that would suggest that the occasional discrete "dimmenings" in my example URL are actually good -- the fadeout of really old points is being profitably recalculated with greater accuracy. So should we call the current situation victory, or pursue even greater smoothness of fading? The only way I can see to achieve that smoothness is to choose a "visibility window" of step serial numbers (based on the fading rate and number of pixelsPerFrame). The idea is that steps earlier than the window have gotten so faint that they don't matter anymore. Then on every frame, you re-draw every dot in the visibility window, with its color pre-scaled using the full floating-point accuracy, so that they fade with greater fidelity. I don't see any way to use chunks in this scheme, so even once we've implemented it (which seems like a fair amount of work), the drawing might just not be performant enough to use practically. So I'd be inclined to leave well enough alone as far as fade goes, unless the lack of smoothness in some cases like the random walks link I gave really undermines your goals for this feature. Looking forward to your feedback and when it's next convenient we can regroup and decide what all else needs to happen with this PR to get it merged. Thanks! |
|
Hi @gwhitney do you know how to move the fern up to the center of the canvas? I'd like to feature it. |
|
Something strange is happening with Fade. Try this one: http://localhost:5173/?name=OEIS+A007931&viz=Chaos&corners=9&walkers=2&bgColor=4E8DA4FF&staticMode=true&eagernessFormula=0.16&sizeFormula=1.5&colorFormula=rainbow%28W*360%2Fh%2B140%29&pixelsPerFrame=10&fadeEffect=0.003&seq=OEIS+A007931 |
|
Have reproduced weird background color/fade thing. It really is weird. If I change the color it doesn't happen, but it is reproducible via that URL. Trying to investigate, but am very confused. |
|
It was rounding on fading again. It only happened when the values of the color channels were different enough and the fade was small enough that fading-with-rounding-to-8-bits changed some of the channel values but not all of them, distorting the hue. (When the fade got so small that it couldn't change any of the channel values, the effect went away). So I had to switch back to using the framebuffer even in static mode. The big cost saving from static mode is never redrawing all of the points and not creating chunks (we only ever create one framebuffer at a time, and are careful to discard any old ones), so it still seems to work reasonably OK, I mean not noticeably slower than without a FrameBuffer, and the hue anomalies are gone. |
|
Ok I don't have anything unpushed, so you could push the fix for fade? |
|
Oh I thought I had, sorry. Will check what happened when I get back to my computer in an hour or two. |
|
Oops yeah forgot the push. Should be OK now. |
|
All checkboxes remaining on Chaos have been checked! |
gwhitney
left a comment
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.
I think we are finally there :)
This PR revamps Chaos for the new ui. New features include: * WebGL rendering for zoom/pan (which can be disabled to allow for megapoint+ visualizations) * Progressive fading of the past * mathjs formulas controlling nearly every aspect of the visualization, including how to get from the current location to the next destination, allowing nearly arbitrary iterated function systems * many new variables that can be used in the formulas * Improved color arithmetic * Improved documentation * New Featured Specimens * bugfixes Resolves #317. Resolves #384. Resolves #447. Resolves #518. --------- Co-authored-by: Glen Whitney <glen@studioinfinity.org>


By submitting this PR, I am indicating to the Numberscope maintainers that I have read and understood the contributing guidelines and that this PR follows those guidelines to the best of my knowledge. I have also read the pull request checklist and followed the instructions therein.
This PR overhauls Chaos, changing it to P5GL and changing the par ameters to mostly formulas.
This should eventually resolve #518 #447 #384 #317 #539
Still to do: