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

3D GEQ #143

Merged
merged 29 commits into from
Jul 16, 2024
Merged

3D GEQ #143

merged 29 commits into from
Jul 16, 2024

Conversation

netmindz
Copy link
Collaborator

@netmindz netmindz commented Jul 10, 2024

PR to pull in @troyhacks new 3D GEQ effect

wled00/FX.cpp Outdated Show resolved Hide resolved
wled00/FX.cpp Outdated Show resolved Hide resolved
wled00/FX.cpp Outdated Show resolved Hide resolved
wled00/FX.cpp Outdated Show resolved Hide resolved
@netmindz
Copy link
Collaborator Author

Should it perhaps be GEQ 3D rather than 3D GEQ so it sits next to the other in the list?

@netmindz netmindz marked this pull request as ready for review July 10, 2024 08:44
wled00/FX.cpp Outdated Show resolved Hide resolved
@troyhacks
Copy link
Collaborator

Should it perhaps be GEQ 3D rather than 3D GEQ so it sits next to the other in the list?

I was thinking the same thing.

wled00/FX.cpp Outdated Show resolved Hide resolved
@netmindz netmindz requested a review from MoonModules July 10, 2024 22:59
@netmindz netmindz added the enhancement New feature or request label Jul 12, 2024
Bug fixes after lots of testing, better settings, etc.

Big thanks to @netmindz  for restructuring the code.

Add rough distance stop to Segment::drawLine()
Copy link
Collaborator

@troyhacks troyhacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

I added a lot of rendering bugfixes to work with all the new various sliders so it always behaves as expected.

"Speed" is implemented with the fastest setting as 1 pixel shift per frame, and that goes down to 1 pixel shift every 10 frames at the lowest end of the slider.

Thanks to @netmindz for restructuring so it uses proper WLED functionality.

I've tested this down to 16x16 and you can get something that looks pretty good at that resolution if you adjust the sliders, reduce the bars, etc.

I'm not overly happy with the perspective when the horizon is moved and the distance is lowered - I feel like that needs some sort of "depth" change so it's not coming to a point when the projector point is right over the bar.

...but that's for a later fix. 😄

@netmindz
Copy link
Collaborator Author

I'm in favour of more controls, however the dmx effect mode personality only supports the speed and intensity options, so are we happy we are mapping the two most useful controls to the right thing? Personally fade speed is the least useful to me, for it to look most like a laser and appear most responsive that is with zero fade. Whereas I'm highly likely to want to change the number of bands and would not be able to in Effect Mode.

@ewoudwijma
Copy link
Collaborator

Why is dmx only supporting 2 controls? Dmx fixtures have often easily 10+ channels. Shouldn't WLED support that as well?

@softhack007
Copy link
Collaborator

I see a few minor optimizations for accuracy, but spotted nothing yet that could drastically improve speed.
I'll take a close look tomorrow or monday.

* adding a _fast_ variant of SetPixelColorXY, that does not perform any error checking.
* drawLine uses the fast setPixelColor variant (bresenham algo only)
* for TESTING: segment option "reverse" switches back to the "original slow" code.
surely needs some more optimization and improvements.

First test on GEQ 3D shows 10%-30% speedup
@softhack007
Copy link
Collaborator

softhack007 commented Jul 14, 2024

@netmindz @troyhacks I've pushed a first shot for faster DrawLine, using an optimized setPixelColorXY_fast that does not repeat error checking and cuts a few more corners.
Currently only supports GEQ 3D, but could be later extended to other "draw loops".

Can you check if this produces better framerates in your setups? I'd expect around 10%-30% speedup.

Important: I've temporarily misused the "X reverse" checkbox, it turns off my optimization - for back-to-back comparing without recompile.

@troyhacks
Copy link
Collaborator

@netmindz @troyhacks I've pushed a first shot for faster DrawLine, using an optimized setPixelColorXY_fast that does not repeat error checking and cuts a few more corners. Currently only supports GEQ 3D, but could be later extended to other "draw loops".

Can you check if this produces better framerates in your setups? I'd expect around 10%-30% speedup.

This is good for 2-3 FPS faster at around 20 FPS before.

softhack007 and others added 2 commits July 14, 2024 23:49
* made setPixelColorXY_fast private
* optimized Segment::fill() to use setPixelColorXY_fast
* "bar" 1D expand optimization
Only draw what will be visible.

This is a pretty solid speed increase when the adjacent bar is close in height, or if it's taller and would occlude it anyway, it'll be skipped.
@troyhacks
Copy link
Collaborator

Added optimized side-wall drawing that will only draw what will be visible, rather than the entire height.

This is a pretty solid speed increase when the adjacent bar is close in height - or if it's taller and would be occluded anyway, it'll be skipped.

@netmindz
Copy link
Collaborator Author

Added optimized side-wall drawing that will only draw what will be visible, rather than the entire height.

This is a pretty solid speed increase when the adjacent bar is close in height - or if it's taller and would be occluded anyway, it'll be skipped.

What impact did this have on speed?

+ don't use dynamic array for heights[] - dynamic arrays are using malloc() -> heap frag.
@softhack007
Copy link
Collaborator

What impact did this have on speed?

on my test setup: 20fps --> 30-35fps.

* made cols/rows integer, to avoid that "cols-x" wraps around
* pre-compute some expressions that don't depend on loop counters

--> wins us 1-4 fps on my 72x72 test setup
@troyhacks
Copy link
Collaborator

troyhacks commented Jul 15, 2024

What impact did this have on speed?

on my test setup: 20fps --> 30-35fps.

image

Depends on the frame, but a big increase.

Before it would have drawn a sidewall for every bar except the one under the projector, from the bottom to the height (like in the red circle) - and then relying on other painting over top to hide the the non-visible parts.

...but now it only draws the green areas because those sidewalls are actually visible.

Netmindz likes the borders. Now a check-box to enable.
@troyhacks
Copy link
Collaborator

troyhacks commented Jul 15, 2024

Added borders back as a checkbox for @netmindz 😊

image

@softhack007
Copy link
Collaborator

@troyhacks on my setup (72pixels wide) the "borders" checkbox does not seems to make a difference

image

@softhack007
Copy link
Collaborator

@troyhacks my fault, its there. I just had to move the "front fill" slider to left side to see the boxes.

image

fast sPC() in pinwheel mapping -> ~10% speedup
@troyhacks
Copy link
Collaborator

troyhacks commented Jul 15, 2024

@troyhacks my fault, its there. I just had to move the "front fill" slider to left side to see the boxes.

It should work for values below "full" down to black-out. Full front fill is the same color.

I guess I could make them not draw when the front face fill is 100%, but that's only a very minor speedup and there's a checkbox for that.

use drawLine() to draw a complete bar at once. Only possible if _not_ doing colored bars.
drawLine parameter "depth" shortens a line by a fraction - useful for VP perspective (vanishing point)
@softhack007
Copy link
Collaborator

added better handling of depth (distance) in DrawLine - could be a bit improved with proper rounding...

30% depth

100% depth

* bugfix for Borders (did not work with <16 bands)

* new option for soft light: when checked, the left & right edges of top lights are drawn with anti-aliasing on. Costs us 1-2 fps, so I made it optional.
hmpf ... looks like somewhere deep in WLED, the FX name string gets limited to 127 chars....
@softhack007
Copy link
Collaborator

new feature: "Soft Light" - draws the light rays with Anti-Aliasing enabled. Costs 1-2 fps, so I made it optional.

image

@softhack007 softhack007 merged commit 98bd7ac into mdev Jul 16, 2024
70 checks passed
@softhack007 softhack007 deleted the 3DGEQ branch October 11, 2024 21:57
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

Successfully merging this pull request may close these issues.

5 participants