HOME | DD

#globalillumination #godrays #iq #montecarlo #renderer #shader #fragmentarium #pathtracer #volumetriclighting
Published: 2017-09-14 13:29:30 +0000 UTC; Views: 2508; Favourites: 75; Downloads: 59
Redirect to original
Description
Created by Inigo Quilez - iq/2016 www.shadertoy.com/view/Xtt3WnLicense Creative Commons Attribution-NonCommercial-ShareAlike 3.0
More info here
My adaptation of this shader for Fragmentarium. This renderer is very simple, contains 2 lights - ambient and direct. So very important to have some space for light into scene.
Main feature - volumetric light as known as "God Rays"
Have fun!
upd.: added floor with rotate, materials for every object, separate colors for background and ambience, better de and shadows.
Related content
Comments: 24
Sabine62 [2017-09-14 19:19:34 +0000 UTC]
Thank you for sharing here too!
The fog is a fantastic addition!
👍: 0 ⏩: 1
C-JR In reply to Sabine62 [2017-09-15 12:52:05 +0000 UTC]
you are very welcome!
Do you need separation between background color and color of ambient light?
👍: 0 ⏩: 1
Sabine62 In reply to C-JR [2017-09-15 16:23:43 +0000 UTC]
Yes, if it can be done...... But only if it's not too much work!
Sometimes, especially with reflective surface it is much nicer to have different colours...
And I must say I am very much impressed with your work on this path tracer, Sergej! I have tried many times to combine features into something altered, but all I end up is 'a forest' of errors leading to 3 new errors once I get 1 fixed!
👍: 0 ⏩: 1
C-JR In reply to Sabine62 [2017-09-15 18:03:58 +0000 UTC]
I was inspired by IQ, especially his works with fractals and renderers and all works on shadertoy.com, it turns out that it is very easy - create shaders )) I searched "godrays", "voluetric light", "global illumination", "monte carlo", ... ... So there are too much examples. So than i found his youtube playlist and was surprised how easy he explain so difficuls things ) here www.youtube.com/watch?v=0ifChJ… and here too www.youtube.com/watch?v=emjuqq… That's great!
Colors... ok, maybe something else?
oh, and this, this too www.youtube.com/watch?v=aNR4n0… just watched now )
👍: 0 ⏩: 1
Sabine62 In reply to C-JR [2017-09-17 20:20:40 +0000 UTC]
I think I really need a "how-to" to get shadertoy code into Fragm! Somehow I am doing it very wrong! I will search FF for more info on that. IQ does great stuff. Thank you very much for the links, I have just subscribed to his youtube-channel Also took a very quick look at your last link!
Ohh, what to wish for... 3D posilight like in de-kn2cr11?
Ambilight? You said this was very difficult, didn't you?
And InFocusWidth?
A rotatable Floor (with color?) This is just for lazy me, Ialways forget where I already put the 3Drotate-floor (without colour) and then have to start from scratch AGAIN!!!
And (correct me if I am wrong) HitDistance works like Detail?
👍: 0 ⏩: 1
C-JR In reply to Sabine62 [2017-09-19 10:37:13 +0000 UTC]
This code was given to me by Eiffie when I answer - "is that possible to port shader from shadertiy to Frag?":
- #vertex
void main(void){gl_Position = gl_Vertex;}
#endvertex
uniform vec2 pixelSize;
uniform float time;
uniform int subframe;
#define iResolution vec3(vec2(1.0)/pixelSize,1.0)
#define iGlobalTime time
#define iFrame subframe
#define iMouse vec4(0)
void mainImage(out vec4 fragColor, in vec2 fragCoord);
void main() {
mainImage(gl_FragColor,gl_FragCoord.xy);
}
Name this ShaderToy.inc and use it like any include file...
#include "ShaderToy.inc"
//copy the text from any ShaderToy Image Tab (here is the default "new" shader)
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
fragColor = vec4(uv,0.5+0.5*sin(iGlobalTime),1.0);
}
so if you want add scene from shadertoy, replace mainImage to yours. And there will be no camera, no fov, no moove. Need add at least Progressive2D.frag, but 3D.frag better, so this is very long work...
About 3D poslight... here I found a lot of bugs when use lighting sphere. So i'll try on this shader, maybe it will better.
Floor - done, other material for floor - in progress, for now I get 2 different colors - for fractal and for floor.
Ambilight - just from background. No background - no ambilight I can make different colors background/ambilight. Maybe can fix, no promise.
👍: 0 ⏩: 1
Sabine62 In reply to C-JR [2017-09-20 23:27:15 +0000 UTC]
Yes I saw that post back then about the emissive lights!
But it is not what I meant with 3D-light, luckily In de-kn2cr11 I can use ctrl-middle mouse button and place the spotlight wherever I want. And if that is troublesome I can use the three lightsliders (x,y,z). But newIQPath has only x,y-sliders?
I have looked at he floor colour, but it is so "woven" into the whole structure of the other raytracers, that I had no idea how to untangle it! Have the rest of the floor (3-axis plus height) working well, but better to be fitted into the path tracer itself than add every time manually
"No promise"... Sergei, I am already so thankful for all your great work! You are pushing the possibilities of the path-and raytracers to new limits! Everything that you can manage is a big added bonus, and what is not possible is just not possible
Thank you also for the Shadertoy-code! I will test this weekend, see if I can get it to work too
👍: 0 ⏩: 1
C-JR In reply to Sabine62 [2017-09-21 07:41:21 +0000 UTC]
I don't know nothing about using ctrl-middle mouse button, I always use sliders ) Emissive light in Path = 3D light in DE
Two coordinates enough for light in the sky and place it in evey point of the inner side of the sphere. Here transformation from 2 coords to 3:
- vec3 sunDir = vec3(sin(SpotLightDir.x*PI)*cos(SpotLightDir.y*PI/2.0), sin(SpotLightDir.y*PI/2.0)*sin(SpotLightDir.x*PI), cos(SpotLightDir.x*PI));
For real 3D source of light needs a lot of changes, so finally it will be looks like emissive light in GI renderer.
About floor... It just another object on scene. In DE raytracers just see DEF function (open DE-Raytracer.frag for example, in notepad++ and choose C++ syntax - everything is immediately visible)
1) We call DE
float DE(vec3 pos) ; // Must be implemented in other file
2) get normal for this DE
vec3 normal(vec3 pos, float normalDistance)
3) Then get normal for floor
vec3 floorNormal = normalize(FloorNormal);
4) Combine DE and floor onto one
float DEF(vec3 p)
... ... ...
and then in trace function see
dist = DEF(p); - here we "call" DE and floor both
and theeeeen use floorHit to divide floor and DE ) call normals and call colors )
So, in PathTracers by Eiffie he used more simple and convenient way. He created map with objects and special normal function with calling every id od object. So now no need to create again and again new normal finction for every new odject ) So you can add objects as many as you like. And every object will has own material (not only color).
p.s. I updated newIQPath here and on fractalforums too.
👍: 0 ⏩: 1
Sabine62 In reply to C-JR [2017-09-21 09:27:40 +0000 UTC]
For the floor I had used this (stolen from DE-Kn2cr11, very close to what you do)
#group Floor
uniform bool EnableFloor; checkbox[false]
uniform vec3 FloorNormal; slider[(-1,-1,-1),(0,0,1),(1,1,1)]
uniform float FloorHeight; slider[-15,0,15]
//uniform vec3 FloorColor; color[1,1,1]
bool floorHit = false;
float floorDist = 0.0;
vec3 floorNormal = normalize(FloorNormal);
float fSteps = 0.0;
.
rest of program here with old DE renamed to DE1
.
float DE(vec3 p) {
float d = DE1(p) ;
if (EnableFloor) {
floorDist = abs(dot(floorNormal,p)-FloorHeight);
if (d
return d;
} else return floorDist;
} else {
fSteps++;
return d;
}
}
Works well, but you already saw the flaw of this: much better to have a general normalisation for every shape!
With the '3D-light' like I meant I can place a light in front of the scene and I cannot manage that with the lights as they are now.
Hopefully this weekend I will have some real time to play with fragm and your goodies!
Quick update Congratulations on the floor, Sergej, it is fantastic to be able to adjust floor reflections as well!
One 'stupid' question: when saying normalisation, in very simple terms: that is controlling the behaviour of how a light-ray hits the surface of a structure at right angles?
👍: 0 ⏩: 1
C-JR In reply to Sabine62 [2017-09-21 10:01:59 +0000 UTC]
You can rename, but nothing will change, you need call DE in trace function and DE1 in fractal.
You can add floor2, floor3 or other object. I tried add terrain, so with great Knighty help, we have terrain in DE So it could be any another fractal.
I know what mean 3D light source Maybe I'll try add it in this renderer. But this is pathtracer, this code very similar to Eiffie's GI, but not to DE-Kn... Finally as i said, it will looks like emissive light And i don't like this way, too many artifacts
Normals need for lights/shadows, texturing... Yes, right angles Oh found picture )) so tnorm is our normal vector )
cse.csusb.edu/tongyu/courses/c…
I used calculating normal for divide textures here. The flat plane - grass, steep slope - stones.
👍: 0 ⏩: 1
Sabine62 In reply to C-JR [2017-09-21 12:03:54 +0000 UTC]
Oh that tnorm-image is perfect for understanding! Thank you! So easy once you know it :} But that is often so
Hm, maybe Knighty or Eiffie one day can look at the emissive light Like you say, as it is in the thread you posted it is not really very good yet...
👍: 0 ⏩: 1