Welcome to Fractal Forums

Fractal Software => Fragmentarium => Topic started by: Crist-JRoger on April 26, 2016, 03:07:23 PM




Title: 2D fractal as background for 3D
Post by: Crist-JRoger on April 26, 2016, 03:07:23 PM
There is one of ideas - put 2d fractal into 3d scene as background. Now i trying to do it by myself and will show... when there will be something to show  ;D 
I used equiRectangular for 2d transpose into the sphere. I think there will be good results with Sky or GI renderers. And more diversity for animation  :)


Title: Re: 2D fractal as background for 3D
Post by: Patryk Kizny on April 26, 2016, 03:50:25 PM
You can render to stills and put as background dynamically via qscript.
The other option is going for Synthclipse where you can mix shaders. And use output of one into another.
Or you can implement 2 things into one shader.


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 26, 2016, 04:27:10 PM
I think i chose third point  :dink:  Because i'm too far from scripting and  Synthclipse :o
Just copied code from 2D fractal and call vec3 backColor = 2Dfractal(vec2 pos); Strange... and it's work!
And now i search what will be vec2 pos  :-\  Ray.Direction.xy works well, but DoF not activated on background )


Title: Re: 2D fractal as background for 3D
Post by: 3dickulus on April 27, 2016, 02:12:44 AM
can you use jitter with 2Dfractal(vec2 pos); to get a DOF like "effect" ? fuzz it a little or maybe the antialias code could add some blur ;)

just a heads up, v1.0.24 removes unused sliders and stuff, so, if you add one it won't show up in the variable editor until you actually make use of it in the frag code, a group tab will show up but won't get populated if the vars are optimized out by the GPU compiler, I recall PK requested this, I'm working on hiding the empty tabs too :beer:


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 27, 2016, 10:02:51 AM
can you use jitter with 2Dfractal(vec2 pos); to get a DOF like "effect" ? fuzz it a little or maybe the antialias code could add some blur ;)
Why standard DoF don't works?

upd. Quickly tested IBL-Raytracer - DoF works on background.
If I simply called vec3 backColor = equirectangularMap(tex, Ray.Direction); in De-Kn2 it don't works
And Patryk Kizny's DE has the same issue.
So how correctly call background texture in DE-Kn2?


Title: Re: 2D fractal as background for 3D
Post by: 3dickulus on April 27, 2016, 02:35:04 PM
I think it's the order, who's first, DOF or background,

I find that clouds obscure fog but fog does not obscure clouds (much) and when order is swapped,
USE_IQ_CLOUDS code before KN_VOLUMETRIC code in color(SRay Ray)
fog obscures clouds and clouds do not obscure fog.

same thing with DOF? order is important


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 27, 2016, 02:54:33 PM
Wait wait  ;D IBL-Raytracer works well and there is the same order.


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 28, 2016, 08:13:30 PM
Okay I found  :)
Code:
vec3 backColor = equirectangularMap(Background, Ray.Direction+Ray.Offset);
Simply and I don't know how set the focus to background )) It does not matter, but it would be nice for full DoF control on background.





Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 29, 2016, 11:59:33 AM
Got a question... there is equirectangular map from IBL-Raytracer:
vec3 equirectangularMap(sampler2D sampler, vec3 dir) {   
   dir = normalize(dir);
   vec2 longlat = vec2(atan(dir.y,dir.x),acos(dir.z));
    return texture2D(sampler,BackRot+longlat/vec2(2.0*PI,PI)).xyz;
}
How rewrite sampler2D for vec2 finction?


Title: Re: 2D fractal as background for 3D
Post by: Patryk Kizny on April 29, 2016, 07:55:12 PM
can you use jitter with 2Dfractal(vec2 pos); to get a DOF like "effect" ? fuzz it a little or maybe the antialias code could add some blur ;)

just a heads up, v1.0.24 removes unused sliders and stuff, so, if you add one it won't show up in the variable editor until you actually make use of it in the frag code, a group tab will show up but won't get populated if the vars are optimized out by the GPU compiler, I recall PK requested this, I'm working on hiding the empty tabs too :beer:


Such a great news!


Title: Re: 2D fractal as background for 3D
Post by: Patryk Kizny on April 29, 2016, 07:58:41 PM
Got a question... there is equirectangular map from IBL-Raytracer:
vec3 equirectangularMap(sampler2D sampler, vec3 dir) {   
   dir = normalize(dir);
   vec2 longlat = vec2(atan(dir.y,dir.x),acos(dir.z));
    return texture2D(sampler,BackRot+longlat/vec2(2.0*PI,PI)).xyz;
}
How rewrite sampler2D for vec2 finction?

if you have an equirectangularly mapped image, there's no need to transform vector. Just use X/Y as long/lat coordinates and it'll work.

If you want to use flat maps, there's no need to map anything. Just sample coordinates straight off.


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 29, 2016, 08:16:41 PM
I have 2D fractal with x and y. I want put it in background for 3D scene. So i need some function vec3 backColor = 2Dfractal(vec2 xy, vec3 dir). dir = Ray.Direction+Ray.Offset
So I don't have such knowledge of GLSL to write it by myself. Now I got results with calling vec3 backColor = 2Dfractal(Ray.Direction.xy) and it looks not bad, but it's wrong code.
Without equirectangular it looks stretched and smooth.


Title: Re: 2D fractal as background for 3D
Post by: Patryk Kizny on April 29, 2016, 09:26:21 PM
Dig my tracer. There's already a simple 2D background implemented and for sure there's code for what you want to do.


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on April 29, 2016, 09:45:38 PM
I understand how put picture file to background and got it. The question is about 2D fractal  :)  it is not sapmler2D, it is vec2. Can you show how it will be?


Title: Re: 2D fractal as background for 3D
Post by: SCORPION on May 05, 2016, 01:39:05 AM
Сергей, я тебя понял, но совершенно не понимаю, зачем это надо?
И уж совершенно не представляю, как это реализовать на практике - рейтрейсеры то для 2D и 3D разные - как ихсвалить в общую кучу?
Всё таки проще сначала сделать 2D фрактал, затем вставить фоном в 3D проект....


Title: Re: 2D fractal as background for 3D
Post by: Crist-JRoger on May 05, 2016, 10:56:11 AM
Сергей, я тебя понял, но совершенно не понимаю, зачем это надо?
И уж совершенно не представляю, как это реализовать на практике - рейтрейсеры то для 2D и 3D разные - как ихсвалить в общую кучу?
Всё таки проще сначала сделать 2D фрактал, затем вставить фоном в 3D проект....
Ну почему же. 2Д фрактал легко помещается как фон. Чуть выше я писал об этом. backColor это vec3, 2Д фрактал тоже. Есть функция equirectangular для "развёртывания" в сферу.
Зачем? Для разнообразия  ;D И потому что это можно сделать даже не зная собственно GLSL  ;D  Например есть идея с 2-х мерными облаками, давно это хотел сделать. Сейчас в DE-Kn2 есть IQ-облака, то они как ни старайся, будут на фоне одним одинаковым слоем, тогда как на небе много облаков и очень разных - сначала перистые вдалеке, потом пониже кучевые ) Чтоб не усложнять код слоями из 3D облаков, можно реализовать некоторые 2D фоном. Кактинка тоже как вариант, но у картинки много ограничений. Плюс анимация фона, тут уже от фантазии зависит.
В аттаче тестовый рендер, он кривой. Криво работает DoF  :-\  Причины писал выше. Если интересно, посмотри. Там через #define BACK2D активирую эту штуку. Также #define BG_PIC -картинка на фон, сделал чтоб смешивалось с фракталом если активировать оба варианта.