• March 01, 2021, 10:38:34 AM

Login with username, password and session length

Author Topic:  Algorithm for Rendering Slope in a Fractal  (Read 3626 times)

0 Members and 1 Guest are viewing this topic.

Offline gerrit

  • 3f
  • ******
  • Posts: 2333
Re: Algorithm for Rendering Slope in a Fractal
« Reply #15 on: March 10, 2020, 04:56:16 AM »

I think I need to re-investigate distance estimation... The method I found relies on the function's derivative. Since a few people have now mentioned distance estimation in the context of NOT relying on derivative, I suspect I've been doing it the hard way.
There is a thread (or several)  about this here from I guess a year ago or more.

Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #16 on: March 10, 2020, 06:20:30 AM »
Hi C0ryMcG,

This sounds pretty good. I'd appreciate to see any results you get.

Thanks.
Paul the LionHeart

Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #17 on: March 10, 2020, 07:25:09 AM »
Thanks Gerrit,

I have been doing a lot of reading over the past few days and I've leaned a lot. I have decided to use post rendering rather than trying to calculate each pixel in real time. This seems to offer more flexibility.

Offline xenodreambuie

  • Fractal Friar
  • *
  • Posts: 111
Re: Algorithm for Rendering Slope in a Fractal
« Reply #18 on: March 10, 2020, 08:14:46 AM »
Hi C0ryMcG; forward differencing is more flexible in not using analytic derivatives, but the usual way of calculating DE does still use a derivative (though it doesn't have to be analytic, as you can use forward differencing for that too, as I do for some formulas with a very complicated derivative.)

Hi LionHeart; not entirely; while pixel differencing can be a post-processing step, forward differencing with subsamples is useful to do in the render. Usually it does require separate iteration loops for each of the three subsamples, but the extra two are not independent of the primary so it can be convenient to bundle them together, though it all depends on what and how one is calculating. I just have separate iteration procedures for flat Julia, Julia with slopes, flat Mandelbrot and Mandelbrot with slopes, and plug in the one that is wanted. One big benefit of having everything together is for convenient oversampling for anti-aliasing, so no post-render processing is needed. (To be clear, I have separate iteration and pixel coloring procedures, which can be used together or separately. Previewing and rendering call them both for each pixel sample. I also buffer the preview data so color/lighting can be adjusted interactively, and that would not be real-time if the extra slope data wasn't already iterated.)

Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #19 on: March 10, 2020, 10:00:41 AM »
https://github.com/hrkalona/Fractal-Zoomer/blob/master/src/fractalzoomer/core/ThreadDraw.java#L3640

This is the post processing function, you only need to focus on light and bump mapping. For bump mapping focus on the case "bms.bumpProcessing == 0" for starters.

As I said, I used the bump mapping algorithm from mandel machine, and for light I used fractview's algorithm.

Also ignore the "postProcessingSmoothing" functions for now, this is just a small work-around for me in my code, to preserve the super-sampling, which is performed on a previous step. I dont store all the super-sampled iteration data, so I do the post-processing on a smaller data set.

Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #20 on: March 10, 2020, 10:11:49 AM »
Here are two samples as well.

Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #21 on: March 11, 2020, 06:40:03 AM »
Hi xenodreambuie,

I agree. Experimentally, I have found that some preprocessing helps a lot. I still have a long way to go with this. Thanks for the tip.

Hi superheal,

Thanks for the source code. This looks really good. I just need to understand some of the terms.

What do the terms
Code: [Select]
bms.bumpProcessing mean? Yes, I can start with 0, but what do the other values mean? I assume
Code: [Select]
image_iterations[loc] is an array of the iteration count for each pixel.

It looks a little like the approach C0ryMcG has taken in his code except the way you calculate the slope. I have good results with this so far. I think between the two approaches I can get even better results. Thanks to both of you.


Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #22 on: March 11, 2020, 07:17:50 AM »
Hi superheal,

I want to use your functions getGradientX() and getGradientY() but I'm not sure what this function means: ColorAlgorithm.transformResultToHeight(). I can't find it in Google.

Please advise what it means so I can program it.

Many thanks


Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #23 on: March 11, 2020, 09:11:08 AM »
the bms.bumpProcessing corresponds to this combobox. The initial implementation from mandel machine was using the rgb scaling option, thats why I told to start from this.

image_iterations is the array with the iteration data

ColorAlgorithm.transformResultToHeight() is implemented in my code, to handle some specific iteration values that I want to filter out. For instance I use negative values for some cases, on in binary decomposition I add 50 iterations, so later on I want to remove this addition because it "breaks" the smoothness of the image during post processing.
Also the max iterations are stored on this array, using a special magic number (1234567890), so with this function I convert this number to the actual height value (for example if max iterations are 500 then this function will return this value instead of the magic number)

For you implementation, skip that function completely, just just the raw continuous iteration values.

so for example
this line:
double it = ColorAlgorithm.transformResultToHeight(image_iterations[index], max_iterations);

is just

double it = image_iterations[index];


Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #24 on: March 11, 2020, 12:38:57 PM »
Thanks superheal,

This is a big help for seeing the options available.

I'm close but not quite there yet. I think my problems are in the conversion of colours
Code: [Select]
modified = rgbs[index]; and how to plot "modified". Maybe I can convert these to RGBTRIPLETS and see how I go. That's for tomorrow. It's bed time now.

Just one final question, what options did you use to get the two images you posted earlier?

Thanks for working with me.

Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #25 on: March 11, 2020, 01:03:51 PM »
For bump mapping I used all the default settings and a transfer factor of 5.
As for light, I used all the default settings, and Light Mode 3. Light is a bit more trickier to implement because you need to convert the colors into Lab color space, but if you need that, the code is also available.

The bufferedImage in java stores the color info as one int. Alpha, Red, Green, Blue.
if you want to extract the three chanels then:

int color = ... //some value

int r = (color >> 16) & 0xFF;
int g = (color >> 8 ) & 0xFF;
int b = color & 0xFF;

combining back into a single value:

int color = 0xFF | (red << 16) | (green << 8 ) | blue

Assuming red green and blue are in range of 0 - 255

Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #26 on: March 11, 2020, 09:33:57 PM »
Thanks superheal,

That makes it easy. I would appreciate the code to convert the colors into Lab color space as I want to achieve the effects you show in your images.

Your help is much appreciated.

Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #27 on: March 12, 2020, 09:20:26 AM »

Offline LionHeart

  • Uploader
  • *
  • Posts: 164
    • ManpWIN Fractal Generator
Re: Algorithm for Rendering Slope in a Fractal
« Reply #28 on: March 12, 2020, 12:00:34 PM »
Many thanks superheal,

This library is very vaulable, not only for my fractal program, but as a library of conversions. I appreciate it. However, I'm still not out of the woods.

Quote
This is the post processing function, you only need to focus on light and bump mapping.

I think I have the bump mapping working okay, but something is wrong with the light mapping.

Code: [Select]
                        case MainWindow.LIGHT:
                            if (ls.lighting) {
                                int original_color = modified;
                                modified = light(image_iterations, original_color, y, x, image_size);
                                modified = postProcessingSmoothing(modified, image_iterations, original_color, y, x, image_size, ls.l_noise_reducing_factor);
                            }
                            break;

light() is a very complicated function and I can't find the meanings of several variables such as lightVector[], gradient[],  shininess, gradient_offset, and a few more. Also the function blend() isn't found.

Do I need this light() function or is there a simplification?

So this is my dilemma:

Using C0ryMcG's code I get a beautiful result:



However, I need to store the derivative for each pixel (not a big problem), but I have to calculate a separate derivative for each fractal. This can be a lot harder.

Using the code from FractalZoomer with light() commented out, I get a lees than satisfactory result.



I assume this is because I am not using the light() function.

I like the approach of post production because any fractal in the x-y plane and iteration counts can be converted without knowing the function that created it. Also I don't have to store an array of calculated derivatives. It also seem s a bit faster.

Thanks for any suggestions.

Offline superheal

  • Strange Attractor
  • ******
  • Posts: 94
Re: Algorithm for Rendering Slope in a Fractal
« Reply #29 on: March 12, 2020, 01:01:58 PM »
obviously there is some bug! If you want you can send me that part of the code to see what is wrong.

bump mapping and light are two different things in my app, the pictures that I posted before showcase what is the effect for each of them.

Here are the default settings for light:
https://github.com/hrkalona/Fractal-Zoomer/blob/master/src/fractalzoomer/main/app_settings/LightSettings.java
and here are the default settings for bump mapping:
https://github.com/hrkalona/Fractal-Zoomer/blob/master/src/fractalzoomer/main/app_settings/BumpMapSettings.java

As for blend, you will need to implement it only if you choose to implement the portions of the code that do the blending algorithm.
If you check the light function in the end, it has an if clause for different coloring techniques. You can stick to the Lab part for now.

All the blending algorithms can be found here: https://github.com/hrkalona/Fractal-Zoomer/tree/master/src/fractalzoomer/core/blending
I used gimp's code for reference.

Edit: blending algorithms use interpolation as well, so here is the code:
https://github.com/hrkalona/Fractal-Zoomer/tree/master/src/fractalzoomer/core/interpolation


clip
Algorithm for Full Exploration of 3D Fractal in Realtime

Started by AranLeer on Fractal Mathematics And New Theories

13 Replies
837 Views
Last post April 26, 2019, 07:34:08 AM
by TGlad
xx
Custom 3D Fractal Formula Rendering on Mac

Started by jmseight on Noob's Corner

5 Replies
354 Views
Last post May 11, 2020, 04:30:34 AM
by kosalos
xx
Travel around 3d fractal world. Realtime rendering.

Started by sanbase on Fractal movie gallery

4 Replies
211 Views
Last post February 18, 2021, 06:12:08 AM
by sanbase
xx
How would quantum computing affect fractal rendering?

Started by greentexas on Programming

1 Replies
728 Views
Last post December 12, 2017, 01:40:20 AM
by eiffie
question
How to Generate a Derivative Slope for Mandelbar (Tricorn)

Started by LionHeart on Programming

12 Replies
355 Views
Last post January 08, 2021, 08:25:36 PM
by LionHeart