Title: texture and displace the floor using the Kaliset Post by: tryptophan on April 16, 2013, 10:17:57 PM Hi I'm attempting to texture and displace the floor in DE-Raytracer-v0.9.1 in Fragmentarium using the Kaliset. So far I've been able to texture (color) the floor easily sampling a texture map within the trace function where it tests for a floor hit. With this method though I either need a gigantic texture or it has to be mirrored and repeated.
So the then I've attempted to use the Kaliset to color the floor and displace it. I've tried implementing it with his instruction within the DEF function but it doesn't seem to be working properly and is distorted. Also even if I am able to displace the floor with the Kaliset I'm not sure how to apply it to the floor color because in the function that is coloring the floor p is not available? Any recommendations? thanks Keith Title: Re: texture and displace the floor using the Kaliset Post by: cKleinhuis on April 16, 2013, 11:03:56 PM So you are quite active that is very nice
i can.not give you any hint A picture of the distortionon would be helpful generally speaking about the displacement then you would have to adjust the de for the ground plane and qhen talking about this you are back at a straight fractal surface :) So back to the dynamic endless ground plane texture, if you have a texture coordinate already you should have everything for obtaining a non stretched colormapping so give us a pic Title: Re: texture and displace the floor using the Kaliset Post by: tryptophan on April 16, 2013, 11:24:37 PM Hi Christian thanks for tips. I'm closer now but still having a few of problems. The first is that the texture is not texturing the whole plane. The next one is that now this is displacing the surface, the surface is now transparent in areas ( the white areas shouldn't be there, this the color photoshop assigns to a background when there is an alpha channel. Finally the normals aren't being adjusted which I've attempted to fix but with no success yet. Below is the code and and some images
for displacement: Code: float DEF(vec3 p) {Also it seems I need to call the Kaliset function twice to calculate shadows (DEF2) I'm also wondering if there is a way to avoid that? for coloring with texture bu not sure how to color with Kaliset: Code: if (floorHit) {Title: Re: texture and displace the floor using the Kaliset Post by: Kali on April 17, 2013, 12:41:00 AM Hi tryptophan!
Try returning "d/sc" instead of "d" if using the scale displacement method. But I've found it's better to use the Kaliset to directly distort the distance estimation this way: Code: d-=Kaliset(p)*kDisp; or Code: d+=Kaliset(p)*kDisp; About the set not filling the plane, it fills it but at different scales, so the more far from center, the values vanish for the current iteration number. Maybe you would want to try some tiling (but how to make it continuous?), or adjust the zoom by scaling the vector you pass to the Kaliset function, so the patterns fills at least the parts you want to be textured. And for the coloring, you must use the return value of the Kaliset function as a color index of a coloring palette. You can use this for 3 color palette: http://www.fractalforums.com/fragmentarium-b210/coloring-add-on-t14522/ or if you want more colors you can use this I implemented on my NODE-Raytracer: Code:
Also it's more accurate for the gradients than the rotate method of my first script. Title: Re: texture and displace the floor using the Kaliset Post by: tryptophan on April 17, 2013, 01:12:46 AM Hi Kali! thanks for the tips. I was going to ask you a question or two on your Kaliset thread but you found this anyways. BTW great formula there is a whole world in it.
Yes I found adding the Kaliset to p works better than scaling p. Now after doing that the function is working better although still not perfectly. It's still opening up the plane so there are holes in it. It is working perfectly though on object inside of the DE function. So next I'm going add a plane to that function to see how well it works. Oh yeah I was thinking if I needed to tile it to get it to extend to infinity that I could fold it so it mirrored. (like I'm doing already for the sampled texture but this way it will be dynamic and much larger than any reasonably sized texture) For the coloring - thanks a lot. I'll be checking that method out for sure - I've been able to learn tons from your formulas. Also I've been interested in checking your new NODE- raytracer. I'll have to get on that one next. thanks for the tips. cheers Keith Title: Re: texture and displace the floor using the Kaliset Post by: tryptophan on April 17, 2013, 01:22:08 AM So it looks like its work quite well on my own plane just not on the DE-Raytracers floor plane. Not sure why yet but this could work for now. Although I can't have separate coloring systems this way.
Title: Re: texture and displace the floor using the Kaliset Post by: tryptophan on April 17, 2013, 09:09:17 AM So I have tiling working decently on the Kaliset displacing and coloring my own plane infinitely. I've posted a few images here:
http://www.fractalforums.com/images-showcase-(rate-my-fractal)/hdr-lighting-and-kaliset-displacement-experiments/ Still haven't been able to get the floor plane to displace or texture properly. I'll have to leave that one for another day. It would be nice though because then you could use two different diplacement/coloring formulas - 1 for the floor and the other for the main object. Title: Re: texture and displace the floor using the Kaliset Post by: Kali on April 22, 2013, 04:13:57 AM I forgot to mention... try giving the plane some thickness: floorDist = abs(dot(floorNormal,p)-FloorHeight)-.1;
And about adding the displacement to p, instead of I meant to add/substract from d (distance estimation) directly. Adding to p makes the displacement to one direction only, buy modifying the distance, the displacement is made on the normal direction ;) Title: Re: texture and displace the floor using the Kaliset Post by: tryptophan on April 22, 2013, 05:42:50 AM Ah thanks for the tips Kali. I'll try both those out asap. I thought the dispacement wasn't working too well on my objects if I displaced it to much it would visibly not displace along the normal. Once I get it going I'll let you know how it goes.
BTW is possible to use your NODE-Raytracing without the buffer like the original DE-Raytracer? I found coming up with a method to do animation by having to render the same frame multiple times is really tricky. thanks again for the help cheers Keith Title: Re: texture and displace the floor using the Kaliset Post by: Kali on April 22, 2013, 12:02:07 PM BTW is possible to use your NODE-Raytracing without the buffer like the original DE-Raytracer? I found coming up with a method to do animation by having to render the same frame multiple times is really tricky. No, sorry, the rendering technique needs some frames, as it's not using any distance estimation at all, and have to find all the parts by varying the raysteps. Some objects needs little frames, though, but this raytracer was intended mainly for still images, and for rendering formulas without a distance estimator, as the brute-raytracer but with more options. If you are interested on the volumetric rendering thing (my last image), I'm planning to add this and other effects to a realtime distance-estimated renderer, I'll let you know when it's done. Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 15, 2015, 01:04:01 PM Hi. Need help, because i don't know glsl or other programming...
I created come plane for surface maping and sphere just for example. This plane rotated. Code: float surf(vec3 p) {So now i want to add kaliset to this plane without sphere, but i don't know how... How rotate plane with kaliset together? For surface mapping i used this Code: float k = Kaliset(p); Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on September 16, 2015, 05:44:15 PM If you want to reorient the scene, just transform the z input vector on main DE function.
Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 18, 2015, 06:40:55 PM If you want to reorient the scene, just transform the z input vector on main DE function. I don't know how to do that.upd.: I done! Just needed to wrie this Code: p=sdist; upd2.: rotate works and texturing works, but displace don't :headbatting: when i write Code: p+=sdist; when i write Code: p*=sdist; Title: Re: texture and displace the floor using the Kaliset Post by: cKleinhuis on September 18, 2015, 07:44:03 PM what patrik mean was exact this, modify the "p" input vector
transforming the input vector p of a DE(vec3 p) function can be done in several ways, multiplying it by a constant number scales it, adding a 3d vector shifts it, for rotation you need to multiply it with a 3x3 rotation matrix, code for that shall be found in the includes for the math functions ;) Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 18, 2015, 07:48:16 PM @cKleinhuis, thank you! I will try to translate what you say...
Title: Re: texture and displace the floor using the Kaliset Post by: cKleinhuis on September 18, 2015, 07:59:24 PM here i am talking about what you can do inside a DE() method
https://www.youtube.com/watch?v=pltkqEdxuzI Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 18, 2015, 08:23:12 PM Is that YOU? :o
I don't know that when see this video before ) Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 21, 2015, 07:21:30 PM Experiment with surface mapping. The garden of Kali`s trees and last DE-raytracer. I attached .frag file, but it's very resource-intensive (on gtx660 run 400x225)
Need to create single colormap for the Surface separately from main fractal. Surface needs debugging :help: (http://orig15.deviantart.net/ecac/f/2015/262/b/c/trees_by_crist_jroger-d9a818f.jpg) (http://orig15.deviantart.net/ecac/f/2015/262/b/c/trees_by_crist_jroger-d9a818f.jpg) Title: Re: texture and displace the floor using the Kaliset Post by: cKleinhuis on September 21, 2015, 08:01:14 PM Is that YOU? :o I don't know that when see this video before ) sure, this is one of my alter egos in my show :D Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 23, 2015, 12:48:37 AM :D I combined Terrain and Kaliset
(http://orig00.deviantart.net/53fe/f/2015/265/a/2/22_09_2015_01_by_crist_jroger-d9ajrci.jpg) (http://orig00.deviantart.net/53fe/f/2015/265/a/2/22_09_2015_01_by_crist_jroger-d9ajrci.jpg) Title: Re: texture and displace the floor using the Kaliset Post by: cKleinhuis on September 23, 2015, 10:19:06 AM wow, that tree gives the scene a strane sense of nature, looks cool!
Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on September 24, 2015, 02:09:22 PM And in my version of the raytracer there is a global 'translate' tab which does exactly this (and a bit more).
There's a full affine transformation allowing you to translate/rotate/scale the space. Ax an extra there's also 1-axis twist, stereographic projection and an interseting space noise. -- edit That's a reply for the previous page questions Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on September 26, 2015, 12:32:54 AM @Patryk Kizny, i get your code with camera settings. Very easy to use.
So there is another settings of Terrain+Kaliset and attached script with presets. Maybe code is wrong, i think something works badly... but this script very interesting to create different landscapes :) (http://pre04.deviantart.net/3545/th/pre/f/2015/276/1/7/melting_of_snow_by_crist_jroger-d9avguu.jpg) (http://orig06.deviantart.net/d171/f/2015/276/1/7/melting_of_snow_by_crist_jroger-d9avguu.jpg) Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on September 26, 2015, 02:09:17 PM This looks awesome!
Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on September 26, 2015, 02:49:10 PM And actually that could look even cooler if merged with the dirt effect from my latest raytracer update.
Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on October 04, 2015, 08:04:28 AM Terrain+Kaliset. Global illumination
(http://orig05.deviantart.net/1754/f/2015/276/a/4/on_the_river_by_crist_jroger-d9bvffk.jpg) (http://orig05.deviantart.net/1754/f/2015/276/a/4/on_the_river_by_crist_jroger-d9bvffk.jpg) Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on November 02, 2015, 06:40:53 PM I checked your frag and noticed you have some issues within the DE.
I am not sure what you meant there. Quote float DE(vec3 pos) { int i=0; for (i=0; i<Iterations; i++) { float h = height(pos); float k = Kaliset(pos); if (KTex) {orbitTrap=vec4(1,1,1,1)*(k*ColorScale+ColorOffset);} if (KHeightmap) { float sc=k*Strength; pos+=vec3(sc,sc,sc)*Strength2;} h += k; if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(pos.xyz,expsmoothing))); return (pos.z-Slope*h); } } Since return is within the "for" loop it's actually never going through the loop cause it breaks the loop on return. Also if KHeightmap is false, even if it did go through the loop, it wouldn't do much cause nothing changes there. And Iterations is bound to both terrain and main loop, so I'd suggest adding another control for that. 5-6 its for terrain are sufficient and in your presets there were like 25-35 values which is an overkill even for my Titan X. Finally you're nesting a lot of DE functions within a for loop which is a computational overkill (not sure if that's crucial for the intended result here). So a proposed alternate: Quote #info Terrain #include "MathUtils.frag" #include "DE-kn9.frag" #include "Classic-Noise.frag" #group Terrain // Number of differnt noise scales uniform int Iterations; slider[0,5,100] uniform int mIterations; slider[0,5,100] uniform int ColorIterations; slider[0,3,300] uniform bool fromFloor; checkbox[true] // Slope uniform float terrSlope; slider[-5,-0.5,5] uniform float kaliSlope; slider[-5,-0.5,5] uniform float FreqMul; slider[1,2,10] uniform float Offset; slider[0,0.4,1] uniform float AmpMul; slider[0,0.3,1] uniform float WaterLevel; slider[0.0,0.6,1] uniform float S; slider[0,1,3] float expsmoothing = 0.0; float height(vec3 pos) { float A = 1.0; float B = 1.0; float r = 0.0; for (int j = 0; j < 5; j++) { r+= B*cnoise(A*(pos.xy)+Offset); A*=FreqMul; B*=AmpMul; } if (r>WaterLevel) r = WaterLevel; return r; } vec3 baseColor(vec3 pos, vec3 normal) { float h = height(pos); if (h==WaterLevel) return vec3(0.0,0.0,1.0); h = 1.0-clamp(h, 0.0, 1.0); if (h>0.5) return vec3(h-0.5,1.0,h-0.5); if (h<0.5) return mix(vec3(0.0,0.0,1.0),vec3(0.0,1.0,0.0),h*2.0); } float DE(vec3 pos) { float h = height(pos); float k = Kaliset(pos); if (KHeightmap) { float sc=k*Strength; pos+=vec3(sc,sc,sc)*Strength2; } if (KTex) { orbitTrap=vec4(1,1,1,1)*(k*ColorScale+ColorOffset); } else { orbitTrap = min(orbitTrap, abs(vec4(pos.xyz,expsmoothing))); } float de = pos.z - (k * kaliSlope + h * terrSlope); return de; } Title: Re: texture and displace the floor using the Kaliset Post by: Crist-JRoger on November 02, 2015, 08:55:41 PM Wow! Your script quickly ) Thank you! As i say more times - i am not a programmer, i just open frag files, copy-paste code and see what happens.
If that possible, can you add this surface into raytracer? Maybe with 3 modes - terrain, kalitex, terrain+kalitex. I tried, but my videocard crash... And problem that i had when played with this. All scene has color from kalitex (i like this color palette!). When you add other object to this scene - it has color from kalitex too. Need to create manually different colors or color schemes for surface and other objects. So now i just don't using orbit color ) Title: Re: texture and displace the floor using the Kaliset Post by: Patryk Kizny on November 03, 2015, 01:50:49 AM I did not check your changes to the ray tracer. And did not study the color yet. For sure you can add color by saving the final point coords into color, this can be easily added to ray tracer. You can also implement color base color function after adding #define providescolor. So there's a bunch of options that you could blend: height, orbit trap, map, coords, normal. Could be fun. Adding multiple materials is tricky - would require lots of changes in the tracer. Good approach is already present in GI tracer. Would adapt it some day and integrate into mine. |