Welcome to Fractal Forums

Fractal Software => Fractal Programs => Topic started by: Hedanito on October 19, 2013, 12:27:12 AM




Title: Fractal Raytracer
Post by: Hedanito on October 19, 2013, 12:27:12 AM
Fractal raytracer (temporary name) is a raytracer written in C++ and OpenCL that uses distance estimation to render fractals.
This tool is a graduation project for a bachelor degree in computer science (and probably beyond).

The goal of this tool is to create a flexible and easy to use environment for the user to work in.
The user should be able to create fractal images just by a few clicks, while also be able to go all out and rewrite the pipeline for their unique needs.

Features:
The tool is still in alpha and has a limited feature set, but it is worked on and updated very often.

The current features are:
 - Real time navigation of fractals.
 - Customizable fractals.
 - Customizable shaders.
 - Fractal and shader parameters editable inside the tool in real time.
 - High quallity image rendering.
 - Rendering of multiple fractals in the same scene and blending them (AND/OR).
 - Saving and loading of scenes.

Future versions will include:
 - Video rendering.

Download:
Latest version (http://goo.gl/3dHPCI)

Screenshots:
Screenshot 1 (http://i.imgur.com/UO5lJkn.png)
Screenshot 2 (http://i.imgur.com/AxzWSfa.png)

Renders:
Album (http://imgur.com/a/cBhJm)

Feedback:
If you enjoyed (or really hated) using the tool you can leave you feedback either in this thread or using this form:
Feedback form (https://docs.google.com/forms/d/1lAuIRFTXR-NxXzZ0F3cl9f0PwTmMUURGqfJCH8JSBuE/viewform)
Don't worry, it's only about 5 questions and most of it is multiple choice.

I also made a bug report form to make it easier to track down bugs, in case the tool does not work properly for you:
Bug report form (https://docs.google.com/forms/d/1DRS6CapqdiavYyHCPD9vT5JSEymp1PEn7mumkDfCZXs/viewform)

I would love to see what you guys can do with this, as I currently lack the math skills to make the really complex fractals.
And don't forget to check out this thread every so often because I will be updating it  ;D.


Title: Re: Fractal Raytracer
Post by: Nahee_Enterprises on October 19, 2013, 10:53:42 AM
    Fractal raytracer (temporary name) is a raytracer written in C++ and OpenCL that uses distance
    estimation to render fractals.
    This tool is a graduation project for a bachelor degree in computer science (and probably beyond).
    The goal of this tool is to create a flexible and easy to use environment for the user to work in.
    The user should be able to create fractal images just by a few clicks, while also be able to go all
    out and rewrite the pipeline for their unique needs.
            ............
    Download:    Latest version (https://dl.dropboxusercontent.com/u/24272518/Fractal%20Raytracer/Fractal_Raytracer_0_1_0.zip)
    Screenshots:    MengerSponge (http://i.imgur.com/G2ZcaMb.png)    Quaternion (http://i.imgur.com/rRoKDFU.png)
    Feedback:    If you enjoyed (or really hated) using the tool you can leave you feedback
            either in this thread or using this form:    Feedback form (https://docs.google.com/forms/d/1lAuIRFTXR-NxXzZ0F3cl9f0PwTmMUURGqfJCH8JSBuE/viewform)
            ............

Though I downloaded your latest version, it may be a few days before I will actually get around to giving it a try.   As soon as I do, I will let you know my findings.
 


Title: Re: Fractal Raytracer
Post by: eiffie on October 19, 2013, 06:45:04 PM
Very excited to give it a try! I like the ability to customize both the formulas and the tracer!
edit: my excitement faded :(
Tried to run on two separate machines both failed after creating buffers - I sent a report thru google docs. Probably need more current GPUs?? I see this must require OpenCL 2.0 support.


Title: Re: Fractal Raytracer
Post by: Hedanito on October 20, 2013, 12:21:56 AM
Very excited to give it a try! I like the ability to customize both the formulas and the tracer!
edit: my excitement faded :(
Tried to run on two separate machines both failed after creating buffers - I sent a report thru google docs. Probably need more current GPUs?? I see this must require OpenCL 2.0 support.

I myself run it on a GTX 580, which is the same generation as yours.
I also did multiple tests on a computer with a GTX 560 TI, almost the same as yours.
The first thing you could check out is if your drivers are up to date, these things can cause a lot of problems with resource intensive programs.

If that doesn't work I'll need more complete logs to help.
Stupid of me that I didn't add a log file, only a console.
You can however still copy from the console by first right clicking the console's title bar and going to Edit->Select All and then Edit->Copy.
If you could make a new report with the complete log that would be great (if you still have the error of course).
I'll add making a log file to my todo list for the next version.

This is why programmers often prefer console programming, if it works once it works everywhere.
Can't wait till someone with an ATI card tries it :tongue1:


Title: Re: Fractal Raytracer
Post by: Hedanito on October 20, 2013, 02:52:02 PM
Here is a little preview of the next version.

(http://i.imgur.com/muTYBn5.jpg)

I'll probably release it a the end of next week.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 07, 2013, 12:22:09 AM
It took me a while, but the update it here  ;D

Most important features for this update
 - Selectable Tracer
 - Selectable Material
 - High quality image rendering (with multisampling)
 - Separated interface from rendering so that it doesn't freeze when the render takes a while

Images and the download link can be found in the first post, let me know what you think  :)


Title: Re: Fractal Raytracer
Post by: eiffie on November 09, 2013, 09:40:02 PM
Sorry I hadn't seen your updates on this thread. Yes new drivers got it working for me. Seems to work as advertised. Nice work. I was able to write formulas but was hoping that the tracer would just return a color for the pixel. That way your software can be modified by users to produce any kind of rendering. It frees you up to concentrate on the gui. Things like materials are just parameters to the tracer. Other than that I would suggest trying to add hybrids. Good start though! Hope you keep going with it.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 25, 2013, 04:13:35 PM
Sorry I hadn't seen your updates on this thread. Yes new drivers got it working for me. Seems to work as advertised. Nice work. I was able to write formulas but was hoping that the tracer would just return a color for the pixel. That way your software can be modified by users to produce any kind of rendering. It frees you up to concentrate on the gui. Things like materials are just parameters to the tracer. Other than that I would suggest trying to add hybrids. Good start though! Hope you keep going with it.

Thank you for your feedback!
Good that updating the drivers fixed the problems, that saves me a lot of bug fixing.

And about just returning the pixel color: this can actually be done.
There is a file called "EntryPoint.cl" in the "Kernels/Other" folder.
This is the file that gets a ray and then outputs a color.
It calls all the tracer/shape/material files from here to generate an image.
So this file basically hides the complex stuff that the user doesn't have to worry about.

You could write anything in here like you suggested.
However, this would make the tool itself not much more than a display for what you are rendering.
So if you like hacking stuff together it can definitely be done, it just isn't very user friendly because the tool can't predict what you will do with it.


Title: Re: Fractal Raytracer
Post by: eiffie on November 25, 2013, 09:31:49 PM
Thanks I didn't see that! In my mind it frees you up to work on things like navigation/video output/parameter controls. Maybe not the things that interest you though? I'm going to go play with it now.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 27, 2013, 01:39:28 PM
Thanks I didn't see that! In my mind it frees you up to work on things like navigation/video output/parameter controls. Maybe not the things that interest you though? I'm going to go play with it now.

Actually those are things I'm working on right now ^^

(http://i.imgur.com/jiWUlwM.png)


Title: Re: Fractal Raytracer
Post by: eiffie on November 27, 2013, 05:42:15 PM
So I have been playing around and see that the shade function does most of what I wanted to script. I made a simple phong/shadow shader but there isn't a way to pass parameters to it. Or is there? Things like lightPosition, baseColor etc. And it would be really nice if there was a global float4 "trap" variable that would be set in the DistanceEstimation function and then used by the Shade function to determine the color. Fun playing around anyways!

Oh, and it would be great if the parameters were referenced by name. You would just need to search and replace the name with a_Parameter
  • . Like the new look.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 27, 2013, 07:10:06 PM
Currently Materials don't have their own parameters. Well, technically they do in the same way shapes have parameters, but there isn't an interface for this yet. Right now they just receive the shape parameters. This is definitely something that is going to be added in the future. Material parameters/textures/lights etc are the next thing on the list after I finished multiple object support. You could kind of cheat material parameters by adding them to the shape and then reading them in the shade function, but it would only work for that specific shape when you do that.

Orbit trapping also seems like a nice way to create interesting shading, but I do not know yet how I would implement this nicely. I will take a look at this as well once I start working on expanding the material features.

Referencing parameters by name could be a nice feature. It shouldn't be too hard to implement, I would just have to inject something like "#define Radius a_Parameter[0]" into the code. I'm not sure if it will cause any problems though, but I'll definitely play around with the idea.

Either way, thank you for your feedback so far, it is helping me a lot!
Also if you happen to create something cool I would love to see it  ;D


Title: Re: Fractal Raytracer
Post by: eiffie on November 27, 2013, 09:30:46 PM
Yes the #define should be an easy way to implement it. Then you don't need to worry about the order of the parameters - then if parameters are read from both the Material and Shape code that would be all you need I think. I will definitely post some stuff after playing a bit more.

One thing - I don't have the code with me but you can make these corrections to the mandelbulb.cl
For the calculation of dr you had something like
dr=pow(r,a_Parameters[0]-1.0)... that must be a typo - it should be a_Parameters[1]

and right now you have r=length(pos.xyz) at the start of the iteration loop - it should be at the end. If it doesn't bail out the value "r" is from the iteration before the last. After those corrections it looked good at any iteration. This is why I like the formulas in external readable format. I see Buddhi is doing the same with Mandelbulber now. But I don't think he has the shader external too.

Edit: Scratch all that. Attached are some files I was playing with. My SoC material renderer (don't even try to understand it) and a "null" tracer - it basically passes the work onto the material shader.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 28, 2013, 04:38:51 PM
Oh wow that looks awesome  :o.
It even has shadows and specular lighting, very cool indeed.
And also thank you for fixing the mandelbulb, I'm not very good at these kinds of maths, so I sometimes can't really tell if I'm doing something wrong  :embarrass:.

Now the reason for the "null" tracer, what were the main reasons for moving it to the material?
Was it the for the background, or the orbit trap you mentioned in a previous post, or anything else?
Or would you even say that having the tracer separated from the material actually limits the tool?

I also love the little "bug" with the mengersponge, where it shows lines between the cubes, almost as if they were etched into it.

Your shaders also revealed a bug in my code.
When I tried to render I noticed that I mixed up the red and blue channel when rendering to an image.
I didn't notice this before because all my renders were black and white.

Also would you mind if I added the so called "AmazingBox" to the set of shapes that come with the tool?
I will of course give you credit and put your name at the top of the file in the comments.
And if you don't mind, does it have a more technical name than "AmazingBox", or should I just leave it like that :P.


Title: Re: Fractal Raytracer
Post by: Hedanito on November 28, 2013, 06:24:07 PM
Well, your materials sure made everything look a lot better  ;D

(https://dl.dropboxusercontent.com/u/24272518/Fractal%20Raytracer/Images/Multi%20Object.png)


Title: Re: Fractal Raytracer
Post by: eiffie on November 29, 2013, 05:25:03 PM
The amazing box or mandelbox is by tglad another user here. I am sure he doesn't mind you using it in a free app. I believe I attributed it to him in the code. If not add it.

I had to use the null tracer for my shader because it takes multiple samples along the march. I think of the code as logically separated into "renderer" and "distance estimator". But it works this way too.

I am hopeful parameters will work in both types!


Title: Re: Fractal Raytracer
Post by: Hedanito on November 30, 2013, 02:30:55 AM
I'll try to contact him to make sure he doesn't mind. You did indeed mention in the code, I didn't look at that file before I posted.

The main reason I chose to do the tracer separately was so that different materials would not have to rewrite the same code, and also so that when multiple materials become a feature the tracer is consistent on all materials. But I am now seeing that this can severely limit the rendering, with for example your material. I am not entirely sure yet, but I might combine the tracer and material to one. This comes with it's own problems though, so I will have to do more research once I start working on the materials.

In other news, here is a picture of a mandelbulb eating a mengersponge (mengersponge & !mandelbulb).
(https://dl.dropboxusercontent.com/u/24272518/Fractal%20Raytracer/Images/OMNOMNOM.png)

P.S.
Sorry for using your material all the time  :tongue1:


Title: Re: Fractal Raytracer
Post by: eiffie on November 30, 2013, 06:29:47 PM
I haven't written a GUI for rendering fractals so you will have to figure out what works best. These are just my ideas if you care to ponder them.
You select a render engine like:
Fast - your step counts
Cartoon - like your normal material but with the sharp edges highlighted (easy to do, i have code)
Simple - like the phong shading model
Reflections.
Global Illumination.
etc.
These would all have their own set of parameters like MARCH_STEPS, DETAIL etc. (yes there is a lot of reuse of code in these)

Then you select a formula.
Each formula should also have a getMaterialProperties function. This function would be in the same .cl file as the function and the typical parameters are:
ColorIterations, BaseColorRed/Green/Blue, Specularity, SpecExp, Reflectivity
It would be nice if the renderer did not handle a specific material property it could be hidden.
This way each object/function has its own material and it can be based on the fractal function.  

To handle multiple objects and hybrids the renderer would call one function for DistanceEstimation and the application has assembled this function from the formulas selected in the GUI.

Rather than each formula returning a DistanceEstimation it should perform the given number of iterations and return the transformed point and its running derivative "dr". This way you can easily create hybrids by calling the functions in series or in a loop.

The assembled function would look something like this...

float DistanceEstimation(blah blah...){//this would be for a hybrid
  for(int i=0;i<MAIN_LOOP_ITERATIONS;i++){
    for(int j=0;j<MENGER_ITERATIONS;j++){
      Menger.Formula(...
    }
    for(int j=0;j<MANDELBULB_ITERATIONS;j++){
      MandelBulb.Formula(...
    }
  }
  return Sphere.DistanceEstimation(blah, blah);
}

Hybrids are a long way off I know. Just getting some thoughts out there.


Title: Re: Fractal Raytracer
Post by: 3dickulus on November 30, 2013, 07:25:25 PM
Quote
The assembled function would look something like this...

float DistanceEstimation(blah blah...){
  for(int i=0;i<MAIN_LOOP_ITERATIONS;i++){
    for(int j=0;j<MENGER_ITERATIONS;j++){
Menger.DistanceEstimation(...
  float d2=MandelBulb.DistanceEstimation(...
  return max(d1,-d2);
}

ahh, now I understand a bit better what you meant when we tried bool switch and got up to 5 or 6 functions... yes yes


Title: Re: Fractal Raytracer
Post by: eiffie on November 30, 2013, 07:50:45 PM
That looks cool 3dic! But you grabbed my text while I was editing. I fat fingered the enter key and you got my code mid-edit. Did it make any sense the way it was??? Anyways you made a nice picture of it. :)


Title: Re: Fractal Raytracer
Post by: 3dickulus on November 30, 2013, 08:09:42 PM

what tweaked in my brain was...
Quote
running derivative "dr"
and things make a bit more sense

my appologies to Hedanito, (nice work btw) I don't mean to barge in, just had to share mandelbulb +/- menger


Title: Re: Fractal Raytracer
Post by: eiffie on November 30, 2013, 08:26:20 PM
I usually make the point being tested a float4 (vec4) with the .w component set to 1 and use it as the running derivative "dr". Then it is easy to pass from function to function and it gets modified right along with the point being tested. But then you can't do 4d functions :(
Hey I didn't just hijack the thread I'm hijacking the entire app! lol


Title: Re: Fractal Raytracer
Post by: Hedanito on December 01, 2013, 10:08:42 PM
Version 0.3.0 is out!

This version added:
 - Completely reworked parameter editor
 - Multiple objects
 - Object positioning, orientation and scale
 - Object blending (OR/AND) and object inversion
 - Parameters can now be accessed in code by their name instead of their index

The download link can be found in the first post, or you can click here (http://goo.gl/LQoQAo).

Screenshot 1 (http://i.imgur.com/H5GwAJM.png)
Screenshot 2 (http://i.imgur.com/iypnEcA.png)


Title: Re: Fractal Raytracer
Post by: mclarekin on December 02, 2013, 04:12:28 AM
Like the potential of your program, what is the system requirements to run it?


Title: Re: Fractal Raytracer
Post by: Hedanito on December 02, 2013, 01:38:15 PM
Like the potential of your program, what is the system requirements to run it?

You need a Windows operating system, as well as a device with OpenCL support.
The best device for this would be a GPU, but it can also run on a CPU as long as it has OpenCL support.
The support mostly relies on the drivers, and most devices that are not very old should be able to run it.


Title: Re: Fractal Raytracer
Post by: eiffie on December 04, 2013, 05:56:23 PM
I forgot to mention the latest update works well! I'm going to continue describing my idea here since I've already started.
I'm looking for a system to generate code like this from a GUI... (vec4=float4)
Code:
//shapes
float PlaneY(vec4 z, float d){return (z.y+d)/z.w;}
float Sphere(vec4 z, float r){return (length(z.xyz)-r)/z.w;}
float RBox(vec4 z, float w, float r){return (length(max(abs(z.xyz)-vec3(w),0.0))-r)/z.w;}
float Cylinder(vec4 z, float h, float r){return max(abs(z.y)-h,length(z.xz)-r)/z.w;}

//formulas
void Menger(inout vec4 z){
z=abs(z);
if(z.x<z.y)z.xy=z.yx;
if(z.x<z.z)z.xz=z.zx;
if(z.y<z.z)z.yz=z.zy;
z=z*3.0-vec4(2.0,2.0,2.0,0.0);
if(z.z<-1.0)z.z+=2.0;
}
void AmazingBox(inout vec4 z){//by tglad
z.xyz=clamp(z.xyz,-1.0,1.0)*2.0-z.xyz;
z*=1.0/clamp(dot(z.xyz,z.xyz),0.25,1.0);
z+=vec4(0.0,6.8,0.0,1.0);
}

//distance estimate
float DE(in vec3 p){
vec4 z = vec4(p,1.0); //dr is the .w field
float d0,d1,d2,d3; //object distances
d0=PlaneY(z,1.0);
for(int i=0;i<3;i++){ //main loop
for(int j=0;j<2;j++){ //first formula
Menger(z);
}
if(i==0)d1=Cylinder(z,2.0,0.25); //conditional (on loop) grab of distance
for(int k=0;k<2;k++){ //second formula
AmazingBox(z);
if(i==0 && k==1)d2=Sphere(z,1.5); //conditional grab of distance
}
}
d3=RBox(z,1.0,0.1); //non-conditional
return min(d0,min(d1,max(d3,-d2))); //union(d0,union(d1,difference(d3,d2)))
}

So the user sets up loop counts and each loop can contain nested loops, formulas (transformations of space) and shapes (distance estimates). Then each shape has an associated material. Shapes can be conditional on loop counts. Materials can have more specific conditions like if(z.x<0.0). I suppose the GUI could be as simple as an indented list. You click an item to change its properties. This would handle separate objects and hybrids the same way.


Title: Re: Fractal Raytracer
Post by: Hedanito on December 05, 2013, 03:21:41 PM
I still don't fully understand the hybrid fractal calculations
Would you be able to create a hybrid fractal shape in my application?
That would probably make it easier for me to understand.
And I need to fully understand it to see if I can implement it in a way similar to the shape blending, or if it requires something much more complex.


Title: Re: Fractal Raytracer
Post by: eiffie on December 05, 2013, 08:39:27 PM
Here is the example in cl format. The very last line of the distance estimate does the shape blending so yes you would need to change the way your app works. You start with an empty loop and the user would need to select formulas and shapes (each shape being blended with the previous in some way).


Title: Re: Fractal Raytracer
Post by: Hedanito on December 06, 2013, 10:43:38 PM
So if I understand correctly, a hybrid fractal uses transforms from different types of fractals on the point given to the distance estimation, and then does a distance estimation of another shape based on that transformed point.

I can certainly see the usefulness of this, shown by the example you gave me.
The implementation of this does also not seem too difficult, it would just require another folder containing "Transforms" that I call in some code generated by the tool.

The main problem however would be the interface.
The current interface is not very well suited for this.
Now I don't mind reworking the interface, but I am a bit constrained with time at the moment.
I have to deliver the program to my school in about a month so they can grade it, and I am still working on shader parameters and also have to write a bunch of documentation.
I don't think rewriting the interface is an option this close to delivery.

That doesn't mean that I wouldn't change it in the future, but for now it will have to wait.
I'll probably rework the entire app anyway once I have finished the version I will give to the school.
There is some really messy code in there due to features that got added too late and don't work well with the older code.


Title: Re: Fractal Raytracer
Post by: eiffie on December 07, 2013, 05:38:44 PM
That sounds great Hedanito. The parameters for the shader are the important thing. I'm just putting out ideas that really I should have put in a GUI long ago. It would work the same if each transform could optionally return a distance estimate (base shape). Then the user chooses the functions they want and each function can have a base shape as a property or just pass the transformed point onto the next function. The user interface would be a bit easier that way.


Title: Re: Fractal Raytracer
Post by: Hedanito on December 07, 2013, 07:36:12 PM
Version 0.4.0 0.4.1 is out!
Well that was faster than usual  :o

This version added:
 - Combined "Tracer" and "Material" into "Shader"
 - Global and per object shader parameters
 - Added "Knot" and "Mandelbox" shape
 - Some other small things

The download link can be found in the first post, or you can click here (http://goo.gl/GZb57B).

Screenshot 1 (http://i.imgur.com/UO5lJkn.png)
Screenshot 2 (http://i.imgur.com/AxzWSfa.png)


Title: Re: Fractal Raytracer
Post by: Hedanito on December 18, 2013, 10:27:11 PM
Version 0.5.0 is out!

This version added:
 - Toolbar instead of random buttons on the screen
 - Loading and Saving of scenes.
 - Fixed bug where local shader parameters would reset when adding/removing objects

The download link can be found in the first post, or you can click here (http://goo.gl/3dHPCI).

This will be the last major version in a while.
I will be focusing on the documentation for school now, and soon after I will already be starting with my first job  ;D.
So yeah, kind of busy for the next month or two.
I'm still able to fix small bugs or add small features and of course discuss future versions, I'm not abandoning the project.
It's just the major versions that will be on hold for a while, until everything settled down.