• Welcome to Dark Bit Factory & Gravity.
 

How to achive this morphing sphere

Started by ryt, January 07, 2014

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ryt

Probably some of you have seen this demo http://www.pouet.net/prod.php?which=11016. In these pictures in lower right corner is a sphere that is changing its shape. I wonder how I can build this sphere. What would be a starting point.
I assume it is some sin function with changing amplitude with random values.



There are also other demos that have a similar changing sphere but in this one it is really easy to see it.

combatking0

I would start by having each point on the sphere having coordinate values (longitude and latitude) and individual radius values.

You can then raise or lower individual points by adjusting the radius values and move them around a little by making slight adjustments to the coordinates.
You are our 9001st visitor.
Challenge Trophies Won:

ryt

I was thinking of something like that. So if we transform that to spherical coords so that longitude and latitude become theta and phi we would have:

x = A*cos(theta)*sin(phi)
y = A*sin(theta)*sin(phi)
z = A*cos(phi)

where 0<=theta<2PI and 0<=phi<=PI and A is the amplitude.

With that we can create a sphere.  So then I think we should make A a function of theta and phi. It could be a function of interpolated random values. Also the continuity should not be broken. But I don't know how to ensure that.
Maybe also there should be two amplitudes like A and B, one for theta and one for phi.

I don't know if I am going in right direction. Probably there are also errors in formulas I wrote.

combatking0

This sounds familiar. One of my previous contest entries generated a wireframe sphere using theta and phi values and a radius value, but only 3 points were raised or lowered at a time.

I've also put together a grid of floating cubes which undulate over a grid of sine waves, one controlling the x-coordinate of the waves and the other over the y-coordinate.

It shouldn't take much to combine both of these effects into one amazing demo! Now I've got to dig out my source codes.
You are our 9001st visitor.
Challenge Trophies Won:

hellfire

Quote from: ryt on January 07, 2014
Also the continuity should not be broken. But I don't know how to ensure that.
So you want a smoothly changing, repeatable value for two coordinates, theta & phi.
That's basically like creating a repeatable plasma pattern (like these for example).
Plasmas are done by adding several layers of sine waves over each other and change the starting phase of each wave to animate the whole pattern.
To make them repeatable, the width and height must be a decimal multiple of the wave-length.
Another (probably easier) way is to add several repeatable bitmaps over another and move each map into a different direction to get animation.

The effect in the screenshot seems to move each vertex-position along different x,y,z-offsets.
But displacing along the vertex-normal works very well, too.
Challenge Trophies Won:

combatking0

#5
I've put up a basic dot-rendered sphere here: http://fx.barcodebattler.co.uk/waveSphere/

I'll add some comments to the code soon and add the wavey effects.
You are our 9001st visitor.
Challenge Trophies Won:

ninogenio

ohh nice one ck! K+

i am excited too see it wave about..
Challenge Trophies Won:

ryt

#7
I gave it a little tought. We have theta and phi so we could animate about these two in their own direction, like in a 2D system. Actualy that is spherical coord system.
To animate in lets say phi we could make:

A = sin(phi*freq+time)

where freq could also change. To change it in theta we could just add another sin or cos like A = sin(phi*freq+time) + cos(theta*freq+time).
So we would get some animated values based on a normal as hellfire mentioned it.
I hope this makes sense and that this will animate the sphere. I wonder how this could be extended so it animates in x, y, z also.

hellfire

Quote from: ryt on January 08, 2014
I wonder how this could be extended so it animates in x, y, z also.
Have a look at this wonderful rgb plasma by Dr_D.
It creates smoothly changing rgb values for each x,y-coordinate.
That's pretty much like the (x,y,z) from (theta,phi) you're looking for!
You can simply add the resulting rgb to the original vertex position.
You just have to find a way to make it repeatable, though.
Challenge Trophies Won:

combatking0

I have annotated my source and adjusted the look of the sphere - the link to the page is in my previous post.

The sphere uses the phi/theta to x/y/z conversion you're looking for. If the annotations don't explain it well enough, please ask me for more details.

Waves will come tomorrow.
You are our 9001st visitor.
Challenge Trophies Won:

ninogenio

#10
@ck im just waiting till the waves come then i am going too have a proper dive into your source too see how you go about this.

Quote
Have a look at this wonderful rgb plasma by Dr_D.
It creates smoothly changing rgb values for each x,y-coordinate.
That's pretty much like the (x,y,z) from (theta,phi) you're looking for!
You can simply add the resulting rgb to the original vertex position.
You just have to find a way to make it repeatable, though.

nice one hellfire! im just in the middle of giving this a go, so too make the effect repeatable would it just be something like if (nticks>somenicetimeval) restarttimer(nticks); and adjust somenicetimeval too whatever gives a nice repeat with no skipping..
Challenge Trophies Won:

Canopy

sure i've seen a nice writeup on the "jelly cube" effect that works a similar way (the newer version of that effect, not the scanline one)

something like break a cube into a grid of sub cubes and wiggle the vertices

combatking0

It's wobbling all over the place now - just click on the checkboxes in the bottom-left corner of the page to get it started.
You are our 9001st visitor.
Challenge Trophies Won:

ninogenio

#13
ck thats awesome mate k++

i actually tried too modify your code too try hellfire's method but after spending hours trying too figure html out i threw the towel in  :). i am going too start a different thread for that though.

so i just turned too good old freebasic too try dr_d plasma effect out i havent looked in too making it seamless atm but it still looks quite good.. its just a different method of achieving roughly the same effect. so between me and you that's two ways down. which just leaves the multiple bitmap's traveling in different directions method hellfire mentioned i would like too give that a try too but would need a little more info on how too go about it.

any who the plasma effect is attached.... exe and code.
Challenge Trophies Won:

combatking0

I guess my code is a bit hard to follow, as it is effectively two demos mashed together (Illumisphere and Ghoulish Cubes) with minimal optimisation. Where were you stuck with it? I'll do my best to explain.

Your exe looks cool, it's how I imagine a magnetic field to look if it were visible.

I can't imagine how the bitmap plasma would work, but it's probably viable.
You are our 9001st visitor.
Challenge Trophies Won:

ninogenio

#15
thanks ck. your code is perfectly readable mate, its when i started hacking at parts of it everything went belly up lol. i am having a little trouble with debugging(tracing vars etc) but rather than hijack this thread ill start a new post and hopefully work through some of the issues im having in html  :cheers:

i wasn't 100% happy with my point's version of this. i thought it was a little hard too see the effect. so i have modified my code too render faces or wireframe tris it looks much better now again source and exe attached
Challenge Trophies Won:

combatking0

No problem - let me know when you want me to show you a method of debugging JS variables.

Hopefully the discussion so far has been helpful for the original topic.
You are our 9001st visitor.
Challenge Trophies Won:

ryt

I was a lot busy these days so I haven't implement any of formulas I wrote yet. But I red all the posts though.
combatking0 when I saw the first version of the sphere it just looked awesome even if it was only rotating. Now it is even better  :) and I can just say wow.
Now I will try to implement these formulas and take a look at your code and the tutorial for rgb plasma by Dr_D that hellfire mentioned.

ninogenio

errmm....

i think you will find attached to my posts dr_d's plasma working on vertex's?!?...
Challenge Trophies Won:

ryt

Yes the vertex version is attached to one of your posts. I haven't looked it before.
It looks cool but it is really a little harder to see the whole object. I will check the source.