Welcome to Fractal Forums

Fractal Software => Fragmentarium => Topic started by: Patryk Kizny on July 27, 2015, 02:48:59 AM




Title: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on July 27, 2015, 02:48:59 AM
Hey,

I've done quite some modifications on the DE raytracer.
The work is based on Syntopia / Knighty / Eiffie / ChrisJRodgers heritage.

This is much work in progress and I hope to keep posting updates.
Detailed features list and more friendly version with some examples shortly.

Note:
If it does not compile for you, that's probably the overload of camera data on the #vertex part.
I plan on moving that to separate frags to allow easier switching on and off.



Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on August 01, 2015, 12:24:13 AM
Here we go with more public version of the raytracer.

DE-PK-1.0.11 Changelog

Shader updates

--> Color AO (it was lost in some previous versions guess since Kn2)
--> Better specular and diffuse falloff
--> Specular highlights take into account material color (different colors for diffuse and specular)
--> Ambient, Global Sun, Spotlight and Environment lighting working together including shadows
--> Cleaned up the structure of the code so now it's easier to add more lights if someone wanted
--> shading now takes into account material properties

Materials
-- Implemented basic materials, now used for floor and fractal
-- now implemented in main trace/light loop
-- there are still some leftovers in the code still refering to the old color, so it was not removed from the UI

Background
-- supports flat 2D background
-- supports equirectanguilar backgrounds

Pipeline
-- background processing is removed from the Post section (preparing for alpha transparency support and matte objects)

External camera
-- External camera is now removed from raytracer and can be added via 2 #include statements (wasn't that obvious)

Testing
What's not tested with the latest updates:
- atmospheric / volumetric effects
- clouds
- fog
all this probably needs cleaning up after shader updates.


Also cleaned up lots of code and added comprehensive info on possible #define triggers for hidden options.
Have fun.




Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on August 02, 2015, 12:35:10 AM
DE-PK-1.0.12 Changelog

Implemented dirt effect.
Based on AO, takes into account directionality, has color noise and experimental glow mode.
Cheap and easy but adds flavour. Inspired by dirt material in VRay renderer.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on August 02, 2015, 10:53:28 AM
A nice thingy with yesterday's update.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on September 14, 2015, 06:28:24 PM
 :D hi, your raytracer don't work ) I tried to understand what you did in code, but you changed everything... A lot of #ifdef ... so much, easy to lost in all of tabs...  :sad1:


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 16, 2015, 05:48:12 PM
Yeah, there's a lot of addons.

#ifdefs are added for the sake of modularity. You turn on only what's needed that way. Most of the #define statements that you can use are documented on top of the code (and should output to log window, but sometimes are cut). I posted also changelog in the code and above.

There were lots of modifications recently, especially after I moved to Nvidia (that development was on AMD), to make it run also on Nvidia cards.
I'll post an updated raytracer soon.

But there's a lot stuff and it may be hitting your GPU limits if it's not a decent unit.
I wasn't aware of limits on GPU for uniforms  etc…

What's exactly that is not working for you?
 


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on September 17, 2015, 08:16:06 PM
I run _Dirt_01 and see only gray background.
I tried to run standard mandelbulb.frag with your renderer.
#define PERFECT_DE - don't know what is it and for what
#define USE_PK_BACKGROUND - don't work
#define USE_PK_DIRT - don't know what is it and for what
#define TAG_LAYERS  - don't know what is it and for what
#define DEPTH_PASS  - don't know what is it and for what


Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 18, 2015, 01:07:51 AM
When I try to run _dirt01.frag I get a grey background and these errors:

Could not locate sampler2D uniform: BgMap
Could not locate sampler2D uniform: EnvMapDiffuse
Could not locate sampler2D uniform: EnvMapSpecular

My GPU is the nVidia GeForce GTX 750 Ti -- not top-of-the-range, but it does OK on Fragmentarium as a rule. This was with v1.00 'Cologne', but I tried 1.06 and it didn't help.



Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 18, 2015, 02:39:47 PM
Quote
Could not locate sampler2D uniform: BgMap
Could not locate sampler2D uniform: EnvMapDiffuse
Could not locate sampler2D uniform: EnvMapSpecular
You need to load maps into slots in the samplers. The settings I included probably point to my harddrive files.

#define PERFECT_DE - not sure, it changes DE handling somehow, it was present in the Kn2 renderer that I based on.
#define USE_PK_BACKGROUND - it allows you to use flat 2D or equirect backgrounds
#define USE_PK_DIRT - it enables use of the dirt effect as shown on the renderings above. It's based on AO and generally adds dirt in inset parts of the fractal.

#define TAG_LAYERS
#define DEPTH_PASS

These are flags that enable output of Z-Depth as a grayscale OR layers color tagging.

Are you getting any errors on build?
It would be helpful if you were a bit more specific regarding what issues exactly you're facing.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on September 18, 2015, 06:51:21 PM
This logs and picture from Dirt_01.tiff Files
Code:
Fragment shader compiled with warnings: Vertex info
-----------
0(59) : warning C7011: implicit cast from "int" to "float"
0(60) : warning C7011: implicit cast from "int" to "float"

Fragment info
-------------
0(199) : warning C7011: implicit cast from "int" to "float"
0(839) : warning C7011: implicit cast from "int" to "float"
0(840) : warning C7011: implicit cast from "int" to "float"
0(840) : warning C7011: implicit cast from "int" to "float"
0(841) : warning C7011: implicit cast from "int" to "float"
0(841) : warning C7011: implicit cast from "int" to "float"
0(853) : warning C7011: implicit cast from "int" to "float"
0(853) : warning C7011: implicit cast from "vec4" to "vec3"
0(869) : warning C7011: implicit cast from "int" to "float"
0(869) : warning C7011: implicit cast from "vec4" to "vec3"
0(877) : warning C7011: implicit cast from "int" to "float"
0(877) : warning C7011: implicit cast from "vec4" to "vec3"
0(1380) : warning C7011: implicit cast from "int" to "float"
0(1381) : warning C7011: implicit cast from "int" to "float"
0(1594) : warning C7011: implicit cast from "int" to "float"
0(1595) : warning C7011: implicit cast from "int" to "float"
0(1596) : warning C7011: implicit cast from "int" to "float"
0(1596) : warning C7011: implicit cast from "int" to "float"
0(1703) : warning C7011: implicit cast from "int" to "vec3"
0(1707) : warning C7011: implicit cast from "int" to "float"
0(1708) : warning C7011: implicit cast from "int" to "float"
0(1708) : warning C7011: implicit cast from "int" to "float"
0(1708) : warning C7011: implicit cast from "int" to "float"
0(1710) : warning C7011: implicit cast from "int" to "float"
0(1711) : warning C7011: implicit cast from "int" to "float"
0(1712) : warning C7011: implicit cast from "int" to "float"
0(1712) : warning C7011: implicit cast from "int" to "float"
0(1712) : warning C7011: implicit cast from "int" to "float"
0(2046) : warning C7011: implicit cast from "int" to "float"
0(2046) : warning C7011: implicit cast from "int" to "float"
0(2047) : warning C7011: implicit cast from "int" to "float"
0(2047) : warning C7011: implicit cast from "int" to "float"
0(2049) : warning C7011: implicit cast from "int" to "float"
0(2049) : warning C7011: implicit cast from "int" to "float"
0(2049) : warning C7011: implicit cast from "int" to "float"
0(2050) : warning C7011: implicit cast from "int" to "float"
0(2050) : warning C7011: implicit cast from "int" to "float"
0(2050) : warning C7011: implicit cast from "int" to "float"
0(2054) : warning C7011: implicit cast from "int" to "float"
0(2121) : warning C7011: implicit cast from "int" to "float"
0(2210) : warning C7011: implicit cast from "float" to "vec3"
0(2211) : warning C7011: implicit cast from "int" to "float"
0(2211) : warning C7011: implicit cast from "int" to "float"
0(2213) : warning C7011: implicit cast from "int" to "float"
0(2213) : warning C7011: implicit cast from "int" to "float"
0(2213) : warning C7011: implicit cast from "int" to "float"
0(2213) : warning C7011: implicit cast from "int" to "float"
0(2213) : warning C7011: implicit cast from "int" to "float"
0(2214) : warning C7011: implicit cast from "int" to "float"
0(2214) : warning C7011: implicit cast from "int" to "float"
0(2214) : warning C7011: implicit cast from "int" to "float"
0(2214) : warning C7011: implicit cast from "int" to "float"
0(2214) : warning C7011: implicit cast from "int" to "float"
0(2215) : warning C7011: implicit cast from "int" to "float"
0(2215) : warning C7011: implicit cast from "int" to "float"
0(2215) : warning C7011: implicit cast from "int" to "float"
0(2215) : warning C7011: implicit cast from "int" to "float"
0(2215) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "int" to "float"
0(2217) : warning C7011: implicit cast from "float" to "vec3"
0(2218) : warning C7011: implicit cast from "int" to "float"
0(2218) : warning C7011: implicit cast from "int" to "float"
0(2328) : warning C7011: implicit cast from "vec4" to "vec3"
0(2374) : warning C7011: implicit cast from "vec4" to "vec3"
0(2377) : warning C7011: implicit cast from "vec4" to "vec3"
0(2383) : warning C7011: implicit cast from "float" to "vec3"
0(2385) : warning C7011: implicit cast from "int" to "float"
0(2436) : warning C7011: implicit cast from "int" to "float"
0(2436) : warning C7011: implicit cast from "int" to "float"
0(2436) : warning C7011: implicit cast from "int" to "float"
0(2437) : warning C7011: implicit cast from "int" to "float"
0(2437) : warning C7011: implicit cast from "int" to "float"
0(2437) : warning C7011: implicit cast from "int" to "float"
0(2438) : warning C7011: implicit cast from "int" to "float"
0(2465) : warning C7011: implicit cast from "float" to "vec3"
0(2906) : warning C7011: implicit cast from "int" to "float"




Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 19, 2015, 05:45:31 PM
OK, I got rid of the errors by uncommenting #define USE_PK_BACKGROUND, #define USE_PK_DIRT, #define USE_KN2_SHADER, #define USE_KB_IBL. The background image works if I point it at something that exists. But there is no object there, only the background and floor. Lots of warnings C7011, but I get those with DE-Kn9 and it still works.





Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 20, 2015, 03:14:53 PM
Warning do not matter. Just ignore them.
As for the objet not appearing - just try playing with the settings. Maybe the camera is off or the fractal is clipped to a volume that does not overlap it. First check the presets, otherwise just try to default everything.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 25, 2015, 06:23:37 PM
Dear all,

Here's another update including a bunch of new features.
I included lots of examples.



Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 25, 2015, 11:01:59 PM
That one works for me. Thanks! May be too slow to do much on my card, though. :(

(What controls the object transparency?)



Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 25, 2015, 11:36:09 PM
There's no transparency here. Although there's a matte mode for the floor and object materials which causes object catch only shadows. That's for advanced compositing.

Note the example I posted has almost everything enabled and may get slow or not run on slower cards. But you can comment out includes and defines to simplify the renderer.


Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 26, 2015, 12:17:14 AM
Must be something about my card then? It certainly looks transparent.





Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on September 26, 2015, 05:35:06 AM
the presets --View 05 Top, 06 Bottom and From Center cause my GPU to lockup  :angry: sorry no debug info, it requires a reboot.
but the rest seems to work...


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 26, 2015, 08:23:15 AM
That's weird cause these are only camera view settings.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on September 26, 2015, 08:27:16 AM
Ellarien - the effect you show could be 2 things - either matte mode on the object or fog with background. When old school fog is used it blends with background. Another option is a flat bg map used as an ibl map. You should be using equirectangular maps for these.


Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on September 26, 2015, 08:57:44 AM
Using DE-Raytracer.frag when I apply the settings...
Code:
FOV = 1.35
Eye = 0,0,3
Target = 0,0,-3
Up = 0,1,0
the screen goes blank, zooming out past 0,0,6.28 and the bulb is visible again, this is 2xPi radius on any 0,0 axis, a bug I noticed some time ago,
in your DE-PK-1.1.6.frag this bug causes a GPU lock up! not just a blank screen, it's a divide by 0 bug afaik this is inherent to DE code using float math.


Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 27, 2015, 09:29:07 PM
Ellarien - the effect you show could be 2 things - either matte mode on the object or fog with background. When old school fog is used it blends with background. Another option is a flat bg map used as an ibl map. You should be using equirectangular maps for these.

I don't think I'm using any of those. What seems to make the difference is turning reflections on and off. So maybe a bug in the way reflections work with the background?


Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on September 29, 2015, 04:21:13 AM
Under the "Render" menu,
select "Output preprocessed script",
this will open a new tab with the complete script as it is when executed.

if you have editor line numbers turned on in preferences (v1.0.12) you will easily be able to find the right line for any error ;)
or you can save the preprocessed script and use your favourite editor to look at it while editing the fragment in Fragmentarium :D

@Ellarien: attached is a version of ratracer frag with PKs mods that compiles with NO warnings, this may or may not behave the same as PKs original due to the funky int vs float stuff, there may have been precision or rounding that will be different.

@Patryk Kizny: test this out and let me know if the exr depth buffer save works ;) I haven't had much time to study what you've done but it shouldn't be too hard to make it work with EXR multipart file format. edit: it's in the "Post" tab.


Title: Re: Patryk Kizny Raytracer Updates
Post by: ellarien on September 29, 2015, 06:02:15 PM

@Ellarien: attached is a version of ratracer frag with PKs mods that compiles with NO warnings, this may or may not behave the same as PKs original due to the funky int vs float stuff, there may have been precision or rounding that will be different.



Thanks, I tried that, but it doesn't make any difference to the transparency issue.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on October 14, 2015, 08:01:35 PM
@Patryk Kizny, i spend some time playing with parameters in de-pk-116. And i found "bug" when lightsourse(spotlight) too long from scene. In original kn2 there is no bud here. Can you fix it?



Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on October 14, 2015, 11:41:34 PM
Thanks for feedback, I noticed similar things, but I am not fully sure what it is caused by.
However, there are some workarounds/tweaks - Try playing with NormalBackstep, FudgeFactor and Dither, in most cases it allows to minimize the negative effect.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on October 15, 2015, 06:50:35 AM
Thank you! But I still use knighty`s script :)
I tried to get your material features, so my "copy-paste" method don't works )


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on October 31, 2015, 02:48:03 PM
Here's the latest update.
A few minor tweaks, so not a major update now.
I included 'implicit cast' warning cleanups from Dick and there are a few tweaks to Dirt effect and IBL.

Note to users less familiar with coding - make sure to open DE-PK-1.1.8.frag (or check info messages in the log window).
This gives you information on how to enable certain functionalities. You do it be adding lines:

#define SOMETHING
before #include "DE-PK-1.1.8.frag"

Have fun and let me know about any bugs.


Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on October 31, 2015, 08:39:12 PM
name's not "Dick"  :-X now I know how Benesi feels  88)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on October 31, 2015, 09:00:50 PM
Is "Dick Ulus" better? Or I should use '3dickulus"?

Anyways, there's still a few bugs with IBL - still not totally happy with it.
Next step would be probably adding a bit of GI.


Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on October 31, 2015, 09:14:04 PM
here on FF I would prefer 3dickulus as that's my username,
when you come for dinner you can call me by my real name which is not "Dick Ulus"
this name stems from the term "the ridiculous in 3D" because that's what I was always attempting on my Amiga in the mid to late 80's :dink:

no worries though, I'm often referred to as "hey you" with the same results :D


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on October 31, 2015, 09:52:12 PM
Patryk Kizny, are you want to upgrade GI or add features from GI to DE-raytracer?
Did you try Sky-Pathtracer? It's much more cleaner and faster than GI,  and lighting... so wonderful  88)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on October 31, 2015, 11:20:18 PM
Not sure yet. Sky is a good idea.
As for now checking ant trying to understand Effie's GI.
Will see about merging some concepts into my tracer. A few bounces would actually make images look more organic. But don't want to kill the GPUs. There's already lots of stuff there.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 01, 2015, 11:07:28 AM
So why does your Vimeo say 'Dick Ulus'? That's where I took it from.


Title: Re: Patryk Kizny Raytracer Updates
Post by: 3dickulus on November 01, 2015, 11:33:59 AM
I don't use my real name anywhere on the internet, or at least I try not to use it. Regardless, on FF I am known by my username. If I used my real name and email on every site that requires a login to participate then I would be easily tracked and hacked.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 01, 2015, 01:43:40 PM
See attached 1.1.9
IBL seems to work properly now, added controls for how much IBL affects shadowed areas.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 01, 2015, 05:17:22 PM
Another update adds glossiness parameter to all materials.
This gives more control over reflections.
Though, the reflections still seem to be very buggy.



Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on November 01, 2015, 06:48:36 PM
Nice ))) You read my thoughts man! Can you add smooth parameter for reflections?  88)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 01, 2015, 07:04:00 PM
It's controlled separately for the floor and objects using glossiness sliders.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 05, 2015, 06:25:26 PM
@Patryk Kizny, i spend some time playing with parameters in de-pk-116. And i found "bug" when lightsourse(spotlight) too long from scene. In original kn2 there is no bud here. Can you fix it?

I have investigated the problem with and it looks like it's sitting in the main trace function, that simply breaks off the main loop. I think this is the matter of overshooting the surface.
I have no idea why it happens, but I can confirm it is also in the DE-Kn2 raytracer. Usually, it's possible to tweak everything using FudgeFactor.
t happens only in the center of the frame and against surfaces that are more perpendicular to the ray.



Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on November 05, 2015, 08:42:41 PM
DE-Kn2 cleaner )
I repeated test with the same parameters of lightsource distance.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on November 06, 2015, 12:03:24 AM
OK, probably these are 2 different issues then. Ill check with your test file.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 06, 2016, 10:48:12 AM
Played some time with glossy materials. Good work, Patryk!
Some parameters make lighting very similar to path-tracing renders. This is really cool! I'll try to combine material feature with latest changes in Knighty's DE. I hope that my video card does not burn  :o


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on April 06, 2016, 10:58:28 AM
It's cool you're playing with it!


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 06, 2016, 10:45:42 PM
I cut all code from DE-PK-1.1.9 besides materials. Just wanted to see how it works. This func makes reflections smooth
Code:
if (hitMat.glossiness>0.0){
vec3 jitter = hitMat.glossiness*(rand(curPos.xy*(float(subframe)+1.0))-0.5);
Ray = SRReflect(Ray, hitNormal + jitter, 0.*minDist);
}
So i have too much white dots, when glossiness = 0 and FudgeFactor=1, image has no artifacts when FudgeFactor decreased. Is any way to get smooth glossy material with FudgeFactor near 1?

Tests:
Raysteps=500,ReflNumer=1,FudgeFactor=1 / Raysteps=500,ReflNumer=1,FudgeFactor=0.4
(http://orig10.deviantart.net/6e62/f/2016/097/1/c/pk2_ff1_by_crist_jroger-d9y2rua.png)(http://orig13.deviantart.net/388e/f/2016/097/0/f/pk2_ff0_4_by_crist_jroger-d9y2rv7.png)

Raysteps=500,ReflNumer=2,FudgeFactor=0.4 / Raysteps=1000,ReflNumer=1,FudgeFactor=0.14
(http://orig06.deviantart.net/da6a/f/2016/097/6/c/pk2_ff0_4_refl2_by_crist_jroger-d9y2rvs.png)(http://orig03.deviantart.net/dcc5/f/2016/097/6/9/pk2_ff0_14_refl2_by_crist_jroger-d9y2rwk.png)

Finally nice lighting  88)
(http://orig12.deviantart.net/39f0/f/2016/097/4/f/pk3_2_by_crist_jroger-d9y2u6h.png)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 09, 2016, 11:23:41 AM
Glossiness is very nice material parameter and it makes lighting on scene more realistic. Maybe there is some way to repeat this parameter like GI but more faster?
I tried some different functions for jitter, they all works strange... Need help  :embarrass:
Original image
(http://orig09.deviantart.net/d3e6/f/2016/100/5/7/kn_pk_02_1_by_crist_jroger-d9ydhs5.jpg)

Patryk Kizny's
Code:
vec3 jitter = hitMat.glossiness*(rand(curPos.xy*(float(subframe)+1.0))-0.5);
(http://orig14.deviantart.net/7897/f/2016/100/a/a/kn_pk_02_2_by_crist_jroger-d9ydhss.jpg)

from Knighty's volumetric light
Code:
vec3 jitter = hitMat.glossiness*(rand(viewCoord+vec2(1.6183+float(subframe+1))));
(http://orig15.deviantart.net/9fe2/f/2016/100/4/6/kn_pk_02_3_by_crist_jroger-d9ydht2.jpg)

from Kali's volumetric light
Code:
vec3 jitter = hitMat.glossiness+rand(curPos.xy+vec2(subframe,subframe*1.12358))-.9;
(http://orig08.deviantart.net/291c/f/2016/100/b/c/kn_pk_02_4_by_crist_jroger-d9ydhtd.jpg)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on April 16, 2016, 08:58:27 PM
Two notes on that.
I based my work on Kn2 raytracer and I think that there was already a problem with reflections there.
I am aware of the fact that when I added all my features it could have gotten worse. I did not debug for reflections.

As for glossiness of materials on reflections - I think the problem is not the very jitter function but rather how environment is sampled and how the ray is reflected. Of top off my mind.

I am happy you're playing with all this.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 26, 2016, 10:08:19 PM
materials+texturing+hmapping

(http://orig08.deviantart.net/d14d/f/2016/117/9/a/hmap_dither_2_by_crist_jroger-da0g9i7.jpg) (http://orig08.deviantart.net/d14d/f/2016/117/9/a/hmap_dither_2_by_crist_jroger-da0g9i7.jpg)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on April 29, 2016, 07:59:56 PM
Inspiring. What fractal is that?
What's actually textured here? Can you share frag & maps?


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 29, 2016, 09:19:20 PM
Don't you recognize ?  ;D That's standard mandelbulb )
I got last Knighty's DE with terrain and better AO, added more terrains from your terrain generator, added texturing for terrain and simple mapping as M Benesi code in his smooth menger experiments. And M Benesi palette, it looks much better than standard.
If you want the same render, here is texrure I used http://ftourini.deviantart.com/art/tileable-stone-wall-texture01-217328604
p.s. I working in original version of Frag, because i go out of range in sliders very often and very far  :dink:

I got different renders when used original 3D+buffershader and yours. I saw - you cut tonemapping code from buffershader to 3D.frag. Is that right?




Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on April 29, 2016, 09:24:58 PM
Don't you recognize ?  ;D That's standard mandelbulb )
I got last Knighty's DE with terrain and better AO, added more terrains from your terrain generator, added texturing for terrain and simple mapping as M Benesi code in his smooth menger experiments. And M Benesi palette, it looks much better than standard.
If you want the same render, here is texrure I used http://ftourini.deviantart.com/art/tileable-stone-wall-texture01-217328604
p.s. I working in original version of Frag, because i go out of range in sliders very often and very far  :dink:

I got different renders when used original 3D+buffershader and yours. I saw - you cut tonemapping code from buffershader to 3D.frag. Is that right?




Yes, at some point I moved the post part from shader to 3d. There was some reason for it but actually I was just thinking yesterday if I can move it back ;)
Anyways, you should be using a full package of files from me (changes were across the range of files).

In my latest version, there are reflection environments per material and much more cool stuff. Plan on adding glossiness adjustments for reflections also.
This raytracer is getting really refined! Next step is adding motion blur (but that will work only under synthclipse if I do it).


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on April 29, 2016, 09:53:34 PM
I checked your changes with original De-Kn2. And if you do not mind I will use only your "materials feature" with my version of renderer ) Glossiness looks good for textured plane. So I wait any updates too
(http://pre01.deviantart.net/0e7b/th/pre/f/2016/119/2/e/bg_dof_test_by_crist_jroger-da0q183.jpg) (http://orig06.deviantart.net/5196/f/2016/119/2/e/bg_dof_test_by_crist_jroger-da0q183.jpg)


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on May 10, 2016, 02:56:28 AM
Guys, I need a bit of help. I am trying to implement proper glossiness parameter for reflections.
Essentially I am tackling into the reflections loop. After calculating color, the ray is reflected (bounced) off the last surface and we enter the next trace loop. At this stage I have a ray, hitpoint and of course normal.
 
Now the simplest glossiness could be implemented by adding a random bias vector to the bounced ray direction.
Bias 0 = fully glossy reflections. But this is not a proper way of doing it and produces ugly results.

A better solution seem to be sampling a random direction vector in the cone which axis the same as ray.direction vector.
Or, in other words, finding a uniformly distributed sample on a circle that is perpendicular to reflected ray.direction and using it as a bias vector.

And I am getting a bit stuck here - can you help me find a fast and reasonable way of implementing it? Something elegant?
I would like to avoid converting to spherical coordinates and back as it seems redundant.

Perhaps it's trivial, but can't find to seem a compact solution myslef nor google anything simple.
Thanks!


Title: Re: Patryk Kizny Raytracer Updates
Post by: hobold on May 10, 2016, 10:23:18 AM
Or, in other words, finding a uniformly distributed sample on a circle that is perpendicular to reflected ray.direction and using it as a bias vector.
just some observations that might help clearing the obstacle:

1. the disk to be sampled lies on a plane perpendicular to the reflected direction => reflected direction vector is that plane's normal vector

2. a reasonable 2D coordinate system on that plane can be constructed like this: find normal vector's component of smallest magnitude and compute the cross product of the normal vector with the unit vector of the respective axis to get a local coordinate axis on the plane (this computation can be optimized due to all the zeros in the axis vector). Another cross product delivers the other local coordinate axis on the plane.

The problem is now reduced to 2D. See, for example, http://mathworld.wolfram.com/DiskPointPicking.html


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 11, 2016, 11:31:40 AM
The problem is now reduced to 2D. See, for example, http://mathworld.wolfram.com/DiskPointPicking.html
interesting... I see that this math used in DoF calculating for bokeh:
Code:
vec2 uniformDisc(vec2 co) {
vec2 r = rand2(co);
return sqrt(r.y)*vec2(cos(r.x*TWO_PI),sin(r.x*TWO_PI));
}
If I want to paint only a circle around disk, how it will look mathematically? Like this:
 


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 12:00:03 PM
You could try using r = 1 - pow(u, exponent) instead of r = sqrt(u), higher exponent pushes points to the edge


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 11, 2016, 12:43:05 PM
Thank you very much for quick answer! But stupid question  :-\ - what is "u" in your formula?


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 12:48:28 PM
Corresponds to "r.y" in your code, a uniform random variable in [0,1).


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 11, 2016, 01:12:46 PM
It works!  :) Have some excess poins... strange
I tried to find the way for adding more bokeh, more than calculates in existing raytracer

upd: This looks little better, but still excess poins
r = pow((1-pow(u,exponent)), 1/exponent)


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 01:27:27 PM
Are you using the sin-based "random number generator"? It's extremely non-uniform, maybe sometimes returns NaNs, who knows... :)

/spoilt OpenCL programmer


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 11, 2016, 01:33:15 PM
Yes, all frags uses sin-based RNG by default. I'll check with Wang hash, later.. my working PC doesn't support 4 shaders
Thank you for help!  :)


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 01:53:56 PM
Friends don't let friends use that sin-thing :) It is 100% certainly causing tons of errors everywhere it's used.

The Wang hash, while infinitely better than the sin-thing in all ways, still is not a good uniform random number generator (it's not even a random number generator, just a uniform-ish hash function)... if you're doing Monte Carlo, you want something accurate and high quality, else additional samples are more damaging the image than improving it (by injecting more and more influence of the b0rked function).


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on May 11, 2016, 02:17:30 PM
What can you suggest then?
I posted a bunch of noise functions here: http://www.fractalforums.com/index.php?topic=22522.0
But these are usually pretty expensive.


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 02:56:42 PM
Erm, those are something totally different though: those are noise functions, continuous functions like Perlin noise.

What's needed here is a (uniform) random number generator, or RNG. RNG (or tables) is needed for things like Perlin noise, not vice versa.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on May 11, 2016, 02:58:10 PM
Oh, right. Forgot about that.


Title: Re: Patryk Kizny Raytracer Updates
Post by: lycium on May 11, 2016, 03:11:16 PM
I've probably said it too often by now, but i still think it's somewhat a shame that we have kinda shared goals but work separately.

I'm in Wroclaw from friday to tuesday, in case you want to maybe meet up; might end up living there a few months even.


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on May 11, 2016, 04:51:45 PM
I've probably said it too often by now, but i still think it's somewhat a shame that we have kinda shared goals but work separately.

I'm in Wroclaw from friday to tuesday, in case you want to maybe meet up; might end up living there a few months even.

We have a great party here on Friday evening - come over.
https://www.facebook.com/events/555370944644986/


Title: Re: Patryk Kizny Raytracer Updates
Post by: phtolo on May 11, 2016, 10:01:39 PM
Here's an example rng I have used in Framentarium.

Code:
int rand(in out ivec2 prnp)
{
int r0 = prnp.y >> 15;
int r1 = prnp.x ^ r0;
r0 = r1 << 17;
prnp.y = r0 ^ r1;
prnp.x = 69069 * prnp.x;
r1 = prnp.x ^ prnp.y;
return r1;
}

Inside your main function, create a seeded variable to keep the current state:
Code:
ivec2 prnp = ivec2(1257353,135);

Then call rand with the current state-variable to get a random value:
Code:
int irnd = rand(prnp);
float frnd = float(rand(prnp) & 0xfffffff)/268435455.0;


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 12, 2016, 10:16:35 AM
Here's an example rng I have used in Framentarium.
  I copied your code into calculating disk for Dof. And nothing ) image is clear, Dof don't works absolutely. Anyway wanghash works!

The Wang hash, while infinitely better than the sin-thing in all ways, still is not a good uniform random number generator (it's not even a random number generator, just a uniform-ish hash function)... if you're doing Monte Carlo, you want something accurate and high quality, else additional samples are more damaging the image than improving it (by injecting more and more influence of the b0rked function).
What is better?  :embarrass:
Found this post (http://www.reedbeta.com/blog/2013/01/12/quick-and-easy-gpu-random-numbers-in-d3d11/) on 1 google page )
With wang hash "holey" bokeh works well. Thank you!


Title: Re: Patryk Kizny Raytracer Updates - Need help!
Post by: Patryk Kizny on May 14, 2016, 08:43:10 PM
Need help. I guess it's a basic thing, but can't get my head around that.

- I have implemented a multi material thing in the raytracer.
- say therea are fractal objects with different materials, and two DEs;
Code:
m1, m2, de1, de2
- there's a function to blend between these materials:
Code:
blendMat(m1, m2, ratio)
working more less like mix(f1, fr, r) but on structs.

final DE is computed using IQ's sminpol function:

Code:
// polynomial smooth_ min (k = 0.1); --> fastest
float sminpol(float a, float b, float k) {
    float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
    return mix(b, a, h) - k * h * (1.0 - h);
}

as follows:

Code:
DE = sminpol(de1, de2, k);

Now as far as I understand based on documentation: http://www.iquilezles.org/www/articles/smin/smin.htm
sminpol returns values that are equal to min(de1, de2) or smaller.

Now what I need is to find a ratio that would blend materials. I don't need anything fancy, linear interpolation is fine.
It should give me:
0 if distance from DE to de1 == 0
1 if distance from DE to de2 == 0
[0 ... 1] for the smoothed corners.

How?


Title: Re: Patryk Kizny Raytracer Updates
Post by: eiffie on May 14, 2016, 09:26:01 PM
Have you tried just using the value "h" from IQ's formula to mix the materials?


Title: Re: Patryk Kizny Raytracer Updates
Post by: Patryk Kizny on May 14, 2016, 09:40:09 PM
Here are two options:

[01] Blending with k as you suggested:
[02] Blend with the following formula:

Code:
float br = (min(de1, de2) / max(de1, de2)); // this gives 1 at the joints and 0 at non-smoothed areas
float m = de1<de2 ? 1 : 0; // comparing DE to check which one was closer if it was not blended
matBlendRatio = mix(m, 0.5, br); // blend between original object color and perfectly blended color (1/2 ratio) on joints

This looks more less good but I believe it is not an elegant solution. Someone with a better math skills could probably come with a simpler and way more elegant mapping function.

// edit
Actually, when I used separate K for color blending and a separate one for geometry this gives me good control. Solved, thanks!


Title: Re: Patryk Kizny Raytracer Updates
Post by: Crist-JRoger on May 18, 2016, 08:29:33 AM
Stupid quesion, but as user I dare to ask..
Is there other way to render 3D objects, faster and easy than DE(I am confused in terms of, in this case I am referring to the use of a raysteps) and the same time having similar characteristics? Just spend some time at shadertoy site, some shaders works well even on slow Intel GPU. Than with Eiffie's help i moved one shader to DE-render and it has become slow...


Title: Re: Patryk Kizny Raytracer Updates
Post by: eiffie on May 18, 2016, 01:57:06 PM
If you use 3D.frag to set up the camera it does multi-sampling. The shaders on ShaderToy typically do not use multi-sampling so they are faster.
To answer your question (is there a faster method than DE) yes just turn the DE into a mesh and draw it as millions of polygons. Look at other threads for information on how to do that.