eiffie
Guest
|
|
« Reply #15 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!
|
|
|
Logged
|
|
|
|
Hedanito
Forums Freshman
Posts: 17
|
|
« Reply #16 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). P.S. Sorry for using your material all the time
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #17 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.
|
|
« Last Edit: November 30, 2013, 06:36:35 PM by eiffie »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #18 on: November 30, 2013, 07:25:25 PM » |
|
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
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #19 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.
|
|
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #20 on: November 30, 2013, 08:09:42 PM » |
|
what tweaked in my brain was... 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
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #21 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
|
|
|
Logged
|
|
|
|
Hedanito
Forums Freshman
Posts: 17
|
|
« Reply #22 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. Screenshot 1Screenshot 2
|
|
« Last Edit: December 01, 2013, 10:34:12 PM by Hedanito »
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #23 on: December 02, 2013, 04:12:28 AM » |
|
Like the potential of your program, what is the system requirements to run it?
|
|
|
Logged
|
|
|
|
Hedanito
Forums Freshman
Posts: 17
|
|
« Reply #24 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.
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #25 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) //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.
|
|
|
Logged
|
|
|
|
Hedanito
Forums Freshman
Posts: 17
|
|
« Reply #26 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.
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #27 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).
|
|
|
Logged
|
|
|
|
Hedanito
Forums Freshman
Posts: 17
|
|
« Reply #28 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.
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #29 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.
|
|
|
Logged
|
|
|
|
|