Logo by Khaotik - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. September 27, 2022, 04:23:39 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: DE Particle System ?  (Read 1567 times)
0 Members and 1 Guest are viewing this topic.
glennmarshall
Alien
***
Posts: 26


« on: July 12, 2013, 11:10:30 AM »

Hi
I'm trying to build a ray marched particle system at the minute - to allow me to create complex structures and animation.  Much like what is possible with Trapcode's Form -
http://www.redgiant.com/products/all/trapcode-form/

I need some help though creating individual scale / translation / rotation on repeated objects or 'particles'.

I've so far created a field of repeating cubes like in the images below.
Here's my code for this.
Code:
 float map(PVector p) {

    PVector cp=p.get();
    float x=rounder(cp.x, .8f);
    float y=rounder(cp.y, .8f);
    float z=rounder(cp.z, .8f);

    cp.x-=x;
    cp.y-=y;
    cp.z-=z;

    float DE=sdBox2(   cp, new PVector(.1, .1, .1));
    float bounds=sdSphere(p, 3);

    return max(DE, bounds);
  }

  float rounder(float ii, float vv) {
    return round(ii/vv) * vv;
  }

I've since been trying to translate the position of each cube with values from a 3d perlin noise field - to create a nice organic deformation of the overall structure.  But I just can't get it working - it looks messed up.  So this is my first problem I need help with.

I'm also trying to orient each cube in the same direction - in the image below I have sort of got it working on the XZ plane, but it's a 'bend' operation really - and also I could only get this working on 1 plane - I couldn't get a full 3d rotation - but just on one plane, e.g. XZ or XY only.  So I need help figuring out full rotation as well, and also how to scale each cube would complete the deal for me.

Thanks for any help,
Glenn.


* Screen Shot 2013-07-12 at 9.47.17 AM.png (187.7 KB, 784x584 - viewed 284 times.)

* Screen Shot 2013-07-10 at 12.07.45 PM.png (64.66 KB, 498x356 - viewed 452 times.)
« Last Edit: July 12, 2013, 11:16:11 AM by glennmarshall » Logged
eiffie
Guest
« Reply #1 on: July 12, 2013, 07:59:07 PM »

If you want to orient each cube to face the origin then create a lookat matrix from your x,y,z values.
In GLSL you can create that matrix like this...
Code:
mat3 lookat(vec3 v){
vec3 up=vec3(0.0,1.0,0.0),fw=normalize(v),rt;
if(abs(fw.y)>0.95){up=fw;fw=vec3(0.0,0.0,1.0);rt=normalize(cross(fw,up));fw=cross(up,rt);}
else {rt=normalize(cross(fw,up));up=cross(rt,fw);}
return mat3(rt,up,fw);
}
The function takes your vector (x,y,z) and returns a 3x3 matrix to rotate in that direction. It may have errors?huh?
But rotating each cube differently will cause a discontinuity so its not going to work well with ray marching.

Have you read this thread? Sounds similar.
http://www.fractalforums.com/index.php?topic=14990.0
Logged
glennmarshall
Alien
***
Posts: 26


« Reply #2 on: July 13, 2013, 10:02:36 AM »

thanks eiffie, i think i could get that working smiley
however scaling and translation are more important at the minute - the .frag link you posted kind of does that yes,
I'll keep trying anyways, cheers.
 
Logged
glennmarshall
Alien
***
Posts: 26


« Reply #3 on: July 13, 2013, 11:03:31 AM »

oh why doesn't this work!!
Code:
  float map(PVector p) {

    PVector cp=p.get();
    float x=rounder(cp.x, .6f);
    float y=rounder(cp.y, .6f);
    float z=rounder(cp.z, .6f);


    float n=noise(x, y, z); // get noise value 0...1 - each cube position should have same value;


    x+=n/2; // offset cube position of x with noise value


    cp.x-=x;  //set cube position
    cp.z-=z;


    float DE=sdBox2(   cp, new PVector(.1, .1, .1));
    float bounds=sdSphere(p, 3);

    return max(DE, bounds);
  }

I was hoping this would give me a wavy grid of cubes using perlin noise to affect the x translation of each cube - it just looks messed up though sad


* Screen Shot 2013-07-13 at 10.00.37 AM.png (114.57 KB, 910x497 - viewed 249 times.)
Logged
eiffie
Guest
« Reply #4 on: July 13, 2013, 05:25:44 PM »

One problem I see is that you sectioned the space into cubes with size 0.6 and then offset them by 0 to 1.0. You have to stay within the cubes! Even then you will see discontinuities.

I am curious if what you really wanted to do in the first place was reduce the object to smoke as in the link above? If that is the case just search for samples of cloud rendering with DE. That effect should be easy to produce (yeah easy to say).
Logged
glennmarshall
Alien
***
Posts: 26


« Reply #5 on: July 13, 2013, 06:10:29 PM »

ahh yes I see what you mean,
I tried this and it seems to be working better,

    float n=noise(x, y, z);
    n=(n*.6f)-.3f;

It's a bit limiting though - the cubes can only be displaced a modest distance - was hoping for more extremes, but I realize the DE technique makes this tricky.  Might have to rethink things.  I want to stay using the 'infinite space' idea to replicate the cubes - rather than within a confined space (as with the exploding fractal example), one reason being I want to create vast, infinite worlds with this technique.


* Screen Shot 2013-07-13 at 5.01.44 PM.png (93.12 KB, 847x436 - viewed 261 times.)
Logged
eiffie
Guest
« Reply #6 on: July 13, 2013, 07:12:28 PM »

One trick is to use two overlapping spaces. This allows you to have more room between the objects in a single space but when both spaces are drawn it looks dense. Takes twice as long to compute sad
Logged
glennmarshall
Alien
***
Posts: 26


« Reply #7 on: July 13, 2013, 07:36:14 PM »

yes nice idea - i'll try that out thanks.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Particle Accelerator 2d Art heavenriver 0 685 Last post April 10, 2011, 10:14:37 PM
by heavenriver
Religiouon Particle Nirvana Temple Mandelbulb3D Gallery KRAFTWERK 0 317 Last post November 15, 2011, 05:42:47 PM
by KRAFTWERK
Mathmatical Particle Program OSX only for now General Discussion Blace 2 1082 Last post June 21, 2013, 10:36:23 PM
by Blace
Plasma particle accelerator Still Frame Sergio CT 0 479 Last post May 26, 2014, 04:01:43 PM
by Sergio CT
The Particle Paradox Images Showcase (Rate My Fractal) Pauldelbrot 2 599 Last post July 03, 2014, 12:39:18 PM
by Pauldelbrot

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.164 seconds with 24 queries. (Pretty URLs adds 0.008s, 2q)