News: Support us via Flattr FLATTR Link

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

 Pages: 1 [2] 3   Go Down
 Author Topic: Calculating normals  (Read 7670 times) Description: 0 Members and 1 Guest are viewing this topic.
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #15 on: November 21, 2009, 12:20:28 PM »

Can you share a snippet of code.  ie going from the 3d point calculated on the surface up to the point the normals found?
Why does the "small amount" cause issues?  I would assume that like when shooting more rays to get a normal, you step half the distance to the next pixel?

I have gotten the basic rendering working, but the excess of 5 rays per pixel is killing rendering time.

If you're using the method I suggested (which is basically the same as lyciums actually except that it's his method *combined* with the surface method) then the overhead for getting the points on adjacent rays should be negligible - if not then you're ray-tracing on the adjacent rays when you shouldn't be.
 Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
lycium
Fractal Supremo

Posts: 1158

 « Reply #16 on: November 21, 2009, 12:33:18 PM »

*ahem* it's not the same method at all, consider the behaviour of the "multiple rays" approach on the object silhouette and at visibility boundaries...
 Logged

David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #17 on: November 21, 2009, 12:53:40 PM »

*ahem* it's not the same method at all, consider the behaviour of the "multiple rays" approach on the object silhouette and at visibility boundaries...

Huh ? Remember I'm *not* ray tracing the adjacent rays, just using them to get my offset positions (using the position on the adjacent rays that's the same distance as the centre point from the viewpoint) - this is basically what you're doing except using different offsets.
Also I should add that since my previous post where I said "I do do limited tracing if the adjacent point is 'inside'" I have stopped doing that because I realised that generally the calculated DE value is OK to use even if we reached max iterations (as long as we aren't *too* far 'inside') - this point was brought home by the recent renders of the "Mandeliers" (I tried rendering them and found I couldn't because as soon as max. iter was hit my algorithm said "solid found"). BTW - is it just me or are the Mandeliers just a figment of the distance estimator's imagination, as I recall for Mandelbrots of negative power everywhere should be "inside" ?
 « Last Edit: November 21, 2009, 12:59:13 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #18 on: November 21, 2009, 12:55:53 PM »

Can you share a snippet of code.  ie going from the 3d point calculated on the surface up to the point the normals found?
Why does the "small amount" cause issues?  I would assume that like when shooting more rays to get a normal, you step half the distance to the next pixel?

I have gotten the basic rendering working, but the excess of 5 rays per pixel is killing rendering time.

If you're using the method I suggested (which is basically the same as lyciums actually except that it's his method *combined* with the surface method) then the overhead for getting the points on adjacent rays should be negligible - if not then you're ray-tracing on the adjacent rays when you shouldn't be.

I did some timings with and without lighting and got 1:54 and 1:49 with and 1:54 and 1:48 without. (for "with" I mean without shadow-tracing).
 « Last Edit: November 21, 2009, 01:02:14 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
JosLeys
Strange Attractor

Posts: 258

 « Reply #19 on: November 21, 2009, 01:37:04 PM »

Sorry if it was not clear :
The blue triangle represents the surface.
P is a point on the ray. The potential function is the distance to the surface.(which is zero on the surface)

So we take two other points, a distance d away in the x and y directions, and mesure the distance there.
The differences in distances give the surface normal components..
 Logged
subblue
Conqueror

Posts: 116

 « Reply #20 on: November 21, 2009, 06:25:09 PM »

I've been following the Mandelbulb discussion for a few weeks and have a GPU implementation working using Adobe Pixel Bender, but haven't yet managed to generate clean normals. I've been attempting to create a Jacobian matrix that Iq mentioned (further discussion in GPU gems), but without any success yet.

Below are the differentials defined by Mathematica and the code used to calculate it. I thought I'd share it in case anyone else can shed some light.

So in principle using the code below the normal should be created with n = normalize(Jacobian(z) * z), where z is the intersection point:

Code:
float3x3 Jacobian(float3 z)
{
float n = float(power);
float zm = dot(z, z);
float zm_n2 = pow(zm, n/2.0);
float zm_n3 = pow(zm, (n/2.0) - 1.0);
float x_y = dot(z.xy, z.xy);
float sxy = sqrt(x_y);
float atan_z = atan(sxy, z.z) * n;
float atan_x = atan(z.y, z.x) * n;
float sin_atan_z = sin(atan_z);
float sin_atan_x = sin(atan_x);
float cos_atan_z = cos(atan_z);
float cos_atan_x = cos(atan_x);
float z2 = z.z * z.z;
float xy = z.x * z.y;
float yz = z.y * z.z;
float xz = z.x * z.z;

float dx_x, dx_y, dx_z;
float dy_x, dy_y, dy_z;
float dz_x, dz_y, dz_z;

dx_x  = zm_n3 * n * z.x * sin_atan_z * cos_atan_x;
dx_x += zm_n2 * (-xz/(sxy * zm)) * n * cos_atan_z * cos_atan_x;
dx_x += zm_n2 * sin_atan_z * -(z.y/x_y) * n * sin_atan_x;

dx_y  = zm_n3 * n * z.y * sin_atan_z * cos_atan_x;
dx_y += zm_n2 * (-yz/(sxy * zm)) * n * cos_atan_z * cos_atan_x;
dx_y += zm_n2 * sin_atan_z * (z.x/x_y) * n * sin_atan_x;

dx_z  = zm_n3 * n * z.z * sin_atan_z * cos_atan_x;
dx_z += zm_n2 * (sxy/zm) * n * cos_atan_z * cos_atan_x;

dy_x  = zm_n3 * n * z.x * sin_atan_z * sin_atan_x;
dy_x += zm_n2 * (-xz/(sxy * zm)) * n * cos_atan_z * sin_atan_x;
dy_x += zm_n2 * sin_atan_z * (z.y/x_y) * n * cos_atan_x;

dy_y  = zm_n3 * n * z.y * sin_atan_z * sin_atan_x;
dy_y += zm_n2 * (-yz/(sxy * zm)) * n * cos_atan_z * sin_atan_x;
dy_y += zm_n2 * sin_atan_z * (-z.x/x_y) * n * cos_atan_x;

dy_z  = zm_n3 * n * z.z * sin_atan_z * sin_atan_x;
dy_z += zm_n2 * (sxy/zm) * n * cos_atan_z * sin_atan_x;

dz_x  = zm_n3 * n * z.x * cos_atan_z;
dz_x += zm_n2 * (xz/(sxy * zm)) * n * sin_atan_z;

dz_y  = zm_n3 * n * z.y * cos_atan_z;
dz_y += zm_n2 * (yz/(sxy * zm)) * n * sin_atan_z;

dz_z  = zm_n3 * n * z.z * cos_atan_z;
dz_z += zm_n2 * (-sxy/zm) * n * sin_atan_z;

return float3x3(dx_x, dx_y, dx_z,
dy_x, dy_y, dy_z,
dz_x, dz_y, dz_z);
}

I'd be interested to see Iq's approach to this
 Logged

www.subblue.com - a blog exploring mathematical and generative graphics
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #21 on: November 21, 2009, 06:43:02 PM »

Maybe I'm missing something here ?

*But* isn't it true that you need the Jacobian for the actual equaton for the point found ?
In which case in order to get the correct Jacobian you have to iterate it in a similar way to getting the derivative ?
i.e. You can't simply use the Jacobian for the Mandelbulb z^b+c, you have to use the Jacobian for the equation of the nth iteration of the formula.
At least that's what I thought and is the reason I abandoned using the analytical method for getting the normal.
 Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
cKleinhuis
Fractal Senior

Posts: 7044

formerly known as 'Trifox'

 « Reply #22 on: November 21, 2009, 06:58:08 PM »

just a note, you can use LaTeX inside posts !

like:

$z^n+c$
 Logged

---

divide and conquer - iterate and rule - chaos is No random!
fractalrebel
Fractal Lover

Posts: 211

 « Reply #23 on: November 21, 2009, 07:02:44 PM »

Sorry if it was not clear :
The blue triangle represents the surface.
P is a point on the ray. The potential function is the distance to the surface.(which is zero on the surface)

So we take two other points, a distance d away in the x and y directions, and mesure the distance there.
The differences in distances give the surface normal components..

Hi Jos,

Thats essentially the method I use, except I chose 4 neighboring points and determine the normals in pairs, and finally averge the normals to get a better approximation to the "true" normal. This adds very little overhead. Most of the calc time is for determining the fractal surface.
 Logged

fractalrebel
Fractal Lover

Posts: 211

 « Reply #24 on: November 21, 2009, 07:04:58 PM »

just a note, you can use LaTeX inside posts !

like:

<Quoted Image Removed>

Thanks! That will be vary useful.
 Logged

Buddhi
Fractal Iambus

Posts: 895

 « Reply #25 on: November 21, 2009, 09:40:03 PM »

With DE I think it's quite simple to calculate normal vector because we can calculate some central differences or gradient of potential function. But what we can do when calculating of DE is impossible, for example for some strange non-linear fractal formulas? Now I know only one method. It is not so fast but gives very accurate and smooth normals (fractal details are also sharp). It is something like central difference but average for some area.

Code:
for (double xx = -1.0; xx <= 1.0; xx += 0.2)
{
double xxx = a + xx * delta;
for (double yy = -1.0; yy <= 1.0; yy += 0.2)
{
double yyy = b + yy * delta;
for (double zz = -1.0; zz <= 1.0; zz += 0.2)
{
double zzz = c + zz * delta;
double op = 1.0 - ComputeIterations(xxx, yyy, zzz, N);
nX += op * xx;
nY += op * yy;
nZ += op * zz;
}
}
}
double normalizeFactor = sqrt(nX * nX + nY * nY + nZ * nZ);
if (normalizeFactor > 0.00001)
{
nX = nX / normalFactor;
nY = nY / normalFactor;
nZ = nZ / normalFactor;
}

Maybe someone knows any other universal algorithm. I tried to found something in Internet but without result.
 Logged

David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #26 on: November 21, 2009, 10:04:58 PM »

@lycium:

Here's the difference in the DE angles found using essentially the same method I'm using in 3D and the analytical method on the good old complex 2D Mandy, just compare the 2 layers, granted it's not perfect but it is pretty close:

Code:
Fractal2 {
::1/Eaahn292XWPyuNS6+uB8/hC57ucKlrlvQP4xLNMm2+OAn+xBogORqsK1W5ykL1pq5X/lLa
jSUSMWqbjuRfqUM+YEBpo4SwvY/lU4WaxP99f3DPcL/WRWysf3+Txze4b57u9ay6lzf41s8X
mM7fq/pHUwf6cKkf7jko5zf4Q2tXPtL5w9ib5nTve97/uDpnPnf8FrsZHvldJ5Hm/4qfUV20
XOmE99f3+TXUlP1UiDpvnrLiGrzZXgXzg/O50+9PsPvI7Y6Bld9lbpH3leZ3j33fYmWGFoX+
IZ2/I7Y2lc43toZey5nLx+XKU6SysDH2/49iv+T/5f+7P/lvlfDe9fcJdXuCgvUc6cmHZe8t
nfxirVl6+wy/U/QvCrqxrmKK4C+SpGdVrRJRP6r4nf+Q6x7pFJHP59R7+Q9Evyd9W6lbJz/x
5eeUW2O9T8InqB4a2tkof7H229RZpXK+409b+rwDn2ll8P195UdB6+w0jvo6n6r+yKyeL10L
rneme4ravjXxudJ9419ZXKbthTHOc6opB/fdJ98/q8pzmSS328AKd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mAGm3EQ
S9mAeu3EwS+mAB23EwQ/mAW+3EIQAnAWG4EIQBnAGO4EwSCnABW4EwSDnABe4EwQEnAam4EI
QFnAWu4EIQGnAK24EwTHnAe+4EwSInABG5EQRJnABO5EIQKnQosyJQkWOhgZBCIQi5EwxMnA
Gq5EwxNnQgX/dQC25EQTPnAF+5EYQQnATG6EEiiOBqc0JghkOBOs0JEONdCI4pTAHRdC4YqT
ALVdC45qTANZdCIZrTgCddCs4rTgChdCcYsTgKldCY4sTz5ynGMndCMJtTgLrdCYotTjxVCa
EBQDl6OBec3Jwk8OBes3Jgk+OB083JQiAPBMM4ppp+jAYwTgNFeCY4wzKO3kOeuXlTDeJjQi
nALW8EkhGPBO84JIDReC8YyTQGq8E4xlngMk5JwjNPBZozTgFfeCyQonAPG9EkhSPBec6JID
peC8Y1TQGa9EYxrngME7JwjZPhwp2TQGu9EoRunAP29EYTvngM87JgmgPBCM8JgniPB+c85n
ATO/EoQ6nwgs+Z1P9TmVYXvGwHuc6mhANT+h4tPY+yZym4HMgnEtOKOa7qVl/e0Gj/2+slrX
9UU5DibkY16yfTDn932uJataKvf/3VaAt1gjnKL+8HqMP18B/+v7/Hw2LvJa
}

Just to add that you'll notice there are significant differences if you zoom in but if you put another layer of the Mandy on top using my class "Field estimator" outside colouring in distance estimator "distance" mode and use a solid black "outside" with opacities set such that the black area only appears closer than a certain distance away from inside and then leave that layer on and turn the middle layer on and off to see the two different DE angle colourings you should see that the method I use matches the actual outline of the DE at the threshold set by the transparency in the top layer whereas the analytical angle is showing the angle based on true inside - obviously in 3D the former is a better option i.e. the DE angles and hence the normals should match the shape of the actual rendered solid not the shape of the true "inside".

 « Last Edit: November 21, 2009, 11:40:29 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #27 on: November 21, 2009, 10:34:36 PM »

With DE I think it's quite simple to calculate normal vector because we can calculate some central differences or gradient of potential function. But what we can do when calculating of DE is impossible, for example for some strange non-linear fractal formulas? Now I know only one method. It is not so fast but gives very accurate and smooth normals (fractal details are also sharp). It is something like central difference but average for some area.

Maybe someone knows any other universal algorithm. I tried to found something in Internet but without result.

My delta DE distance estimation method can be used in such cases (provided you can get an accurate smooth iteration value) essentially the same way as using the analytical DE *except* you obviously can't use the analytical calculation for the normal you can only use either the solid surface found or the central difference method.

Note that my current formula for UF uses exactly the same method to get the normals for both analytical DE and delta DE i.e. get the DE values at the points at the same distance from the viewpoint as the central point on adjacent rays giving 5 points including the central point, assume all 5 DE values are perfect *and* along the relevant rays and calculate the normal using the assumed surface points.
 « Last Edit: November 21, 2009, 10:39:53 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #28 on: November 22, 2009, 12:13:08 AM »

With DE I think it's quite simple to calculate normal vector because we can calculate some central differences or gradient of potential function. But what we can do when calculating of DE is impossible, for example for some strange non-linear fractal formulas? Now I know only one method. It is not so fast but gives very accurate and smooth normals (fractal details are also sharp). It is something like central difference but average for some area.

Maybe someone knows any other universal algorithm. I tried to found something in Internet but without result.

My delta DE distance estimation method can be used in such cases (provided you can get an accurate smooth iteration value) essentially the same way as using the analytical DE *except* you obviously can't use the analytical calculation for the normal you can only use either the solid surface found or the central difference method.

Note that my current formula for UF uses exactly the same method to get the normals for both analytical DE and delta DE i.e. get the DE values at the points at the same distance from the viewpoint as the central point on adjacent rays giving 5 points including the central point, assume all 5 DE values are perfect *and* along the relevant rays and calculate the normal using the assumed surface points.

Just to add that to get an accurate smooth iteration value for more esoteric formulas e.g. involving transcendentals or conditionals then see here:

http://www.fractalforums.com/3d-fractal-generation/re-true-3d-mandelbrot-type-fractal/msg8714/#msg8714

In even worse cases then you can use exponential smoothing (with appropriate scaling adjustments) in the delta DE method as an alternative to iteration smoothing, the only real drawback? with that is that it is generally a noticeably different outline to either solid on iteration or solid on DE based on potential/iteration.
 « Last Edit: November 22, 2009, 12:27:56 AM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
gaston3d
Guest
 « Reply #29 on: November 23, 2009, 10:18:45 PM »

Hi,

all methods based on gradient requires smooth potential function which is very hard or impossible to get when formula function is true/false only.

I use method like this (2D equivalent, see picture):

1. raytrace R(t) by small "dt" values (~1e-3) until hit the object (blue line), then fine tune hitpoint using bisection method until |R(t1)-R(t2)|<epsilon (~1e-9)

2. create small "cube" around hitpoint getting four points ABCD (8 points in 3D case); parameter N~100 gives size of the cube around ~2*1e-7

3. search points P1, P2 on the surface - bisection between proper point pairs (one "in" one "out"); in 3D case, it may sounds weird, there can be 12 points (not belonging to the same surface...)

4. having set of points on the surface calculate normal as average of partial normals (perpendicular to green lines, or triangles in 3D case)

"cloud" set of points on the surface can be used in another methods:

1. approxiamte points by ordinary plane using least squares method; having plane equation, normal vector is trivial (hard...)
http://www.infogoaround.org/JBook/LSQ_Plane.html

2. make local analytical parametric surface R(u,v) and calculate partial derivatives (dR/du, dR/dv) that leads to exact normal vector (very hard I think...)
http://en.wikipedia.org/wiki/Parametric_surface#Notation

I've used method described by David in Reply #1 some time ago and results were fine (x & y +/- 0.25 of a pixel).
It's not necessary to raytrace 4 rays from camera location, you can use ray distance "t" from central point and trace surrounding 4 rays forward or backward.
One disatwantage is when central point is on the edge of the object, then one of additional points can miss the fractal and you raytrace till hit the bounding sphere or other far part of the object.
 hitpoint_square.gif (13.15 KB, 640x484 - viewed 557 times.) « Last Edit: December 04, 2009, 08:35:27 PM by gaston3d » Logged
 Pages: 1 [2] 3   Go Down