Logo by mario837 - 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: Visit us on facebook
 
*
Welcome, Guest. Please login or register. November 20, 2025, 06:23:20 AM


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: Displacement and mapping fractals onto surfaces  (Read 1600 times)
0 Members and 1 Guest are viewing this topic.
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« on: November 01, 2015, 11:20:14 AM »

Hey,

At some point I wanted to do a true displacement add-on for the raytracer.
But sort of stuck. What I managed to do is simply a bump effect which manipulates normals so that the surface appears waved (depending on the texture used).
Bump is cool, but does not work on the edges, only on surfaces facing you.

Can you guys help me with how to do it?
Not asking for code, just the way to get there.

The other thing - how would I go about mapping a fractal onto a plane (so displaace a plane based on a DE) or further, onto a certain surface? Say hemisphere, sphere or sine-bent surface?

Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #1 on: November 01, 2015, 11:36:00 AM »

check the terrain.frag in Examples/Experimental folder
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #2 on: November 04, 2015, 01:52:50 PM »

Thanks, I checked that and I understand how height mapping works. Pretty easy.
Still, I can't understand how to displace a point on the surface of a fractal.
I mean the DE concept is something I understand in theory but is hard for me to grasp intuitively.

Can anyone give me a big picture?
Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #3 on: November 04, 2015, 04:51:04 PM »

please read the awesome inigo quiles introduction to modelling with distance functions, and jump to the "displacement" part
http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #4 on: November 04, 2015, 05:56:02 PM »

Yeah, basic adding operation sounds easy.

But:
To displace along normal I need another distance field that gives me normal at a given point.
So essentially I am thinking I need to:
- calculate DE for the fractal
- acquire normal
- construct displacement vector based on DE and normal
- calculate the new DE based on the acquired normal and displacement?



Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #5 on: November 04, 2015, 06:24:06 PM »

that is the point, you need the surface normal, transforming a already fractal surface is ultra heavy workload, because the distance is not enough, you then need to find the exact point for that particular distance, and then construct the surface normal for that point (could be done by shooting 2 rays from the CURRENT position) then transform the original found point by the displacement for that surface point and modify the resulting DE value that you obtained first wink

that would be "basically" it wink

but perhaps some clever dudes have another point of view for that case, this is just how i see it what has to be done to achieve the displacement effect for a fractal surface ....
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #6 on: November 04, 2015, 08:01:16 PM »

That looks like a path. Though I am still a bit unsure if it's doable at all within currently working architecture.

My reasoning is as follows (am I wrong?):
Even if I find a point on the fractal surface, its normal and push the point along the normal, the resulting displaced point will be a point somewhere else (for a different pixel or camera ray), not for the point that corresponds to the original ray.

Given the current tracer architecture, I think one can only displace along the camera ray. Which does not make much sense.

To do the real displacement, I guess I would need to cache all the calculated points somehow.
Now even if I did that, there will be 'black holes'.

Maybe this case could be worked around, by some clever analytical solution.
Or via some trickery on the input Z vector coming into DE function.









Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #7 on: November 04, 2015, 09:32:07 PM »

yay, you are right, there is a slight problem: you need the displaced forms of the neighbour points to obtain the normal ... sad i am out, perhaps someone else can help here to find a working/fast solution
Logged

---

divide and conquer - iterate and rule - chaos is No random!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #8 on: November 04, 2015, 09:32:57 PM »

stuff that would work is displacing the stuff with a map, and using a sphere mapping or something around your object, this way you would be pretty flexible and fast, and determined!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #9 on: November 04, 2015, 10:19:13 PM »

I am thinking about some other trickery - leave the fractal alone, just distort the incoming position vector before letting it spin within the fractal DE loop. However, again, it's hard to to anything precise here, because reversing the distortion would be terribly tough.
Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #10 on: November 06, 2015, 02:16:50 PM »

I got some success, but still it's not what I wanted.

Essentially, I am doing a "pretrace", store the light/shadow values in a variable and then re-trace again, but that time the DE function applies some noise based on the distort value obtained earlier.
It looks nice, however, the problem is that it does not give me a real 3d - it's only working more less as a map, thus the pixels change color, but are not shifted in fact. That causes problems with obscurance and depth.

Below is my color function.
Code:
[quote]SColor color(SRay Ray) {

float glow = 0.5;
vec3 hitNormal = vec3(0.0);

vec3 col = vec3(0.0);
vec3 col0 = vec3(0.0);
vec3 RWeight = vec3(1.);

SColor Color;

// Reflections loop
for(int i=0; i<= ReflectionsNumber; i++){
if (i>0) isPrimaryPass = false;
vec3 prevPos = SRCurrentPt(Ray);

// ----> TRACE <------
SRay RayOriginal = Ray;
Color = trace(Ray, hitNormal, glow);
vec3 curPos = SRCurrentPt(Ray);

// Re-trace for distortion
displacement.xyz = hitNormal;
displacement.w = (1-totalShadow) * totalLight;

hitNormal = vec3(0.);
Ray = RayOriginal;


// ----> TRACE Again <------
SColor Color2 = trace(Ray, hitNormal, glow);
Color.RGB =  Color2.RGB; // mix(Color.RGB, Color2.RGB, totalShadow);


col0 = Color.RGB;
...

and in DE

Code:
float DE(vec3 z){
        // some sin noise
float de_n = sin(z.x*DE_NoiseFreq.x)*DE_NoiseAmp.x + sin(z.y*DE_NoiseFreq.y)*DE_NoiseAmp.y + sin(z.z*DE_NoiseFreq.z)*DE_NoiseAmp.z;
float de_obj = Objects(z);
float de_hm = z.z;

        // displace only on the second pass
if (tracecount==1){
de_hm += de_n * displacement.w * ShadowDisplacement; // * gizmo;
}

float de_fin = smin(de_hm, de_obj, DE_HeightMapSmooth.y);

return de_fin;

}

Not sure if this approach will give me any good results.


* 01.jpg (24.62 KB, 1126x814 - viewed 346 times.)

* 02.jpg (46.25 KB, 1126x814 - viewed 195 times.)

* 03.jpg (29.6 KB, 1126x814 - viewed 355 times.)
Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Displacement Renderings Images Showcase (Rate My Fractal) cKleinhuis 12 3987 Last post March 15, 2007, 09:43:43 AM
by cKleinhuis
Spatial Displacement Mandelbulb3D Gallery lenord 0 967 Last post January 03, 2012, 02:56:37 AM
by lenord
HDR lighting and KaliSet displacement experiments Images Showcase (Rate My Fractal) tryptophan 5 3460 Last post November 05, 2015, 08:36:16 PM
by M Benesi
Texture Mapping 2D Fractals onto 3D Surfaces Movies Showcase (Rate My Movie) pinballpsycho 1 1919 Last post June 08, 2016, 01:12:13 AM
by mclarekin
Jump Displacement Star Cruiser Mandelbulb3D Gallery Syzwyzygy 1 992 Last post September 24, 2016, 11:33:02 PM
by 1Bryan1

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.226 seconds with 25 queries. (Pretty URLs adds 0.012s, 2q)