Raymarching Beginners' Thread
category: code [glöplog]
stupid graphician question : why so many blur passes
Because it works. See post above.
@The professionals from the gamedev and so on: How would you do a smooth blur? Also multiple passes?
@The professionals from the gamedev and so on: How would you do a smooth blur? Also multiple passes?
stupid graphician question #2 : looking at the screen shot ... i have the feeling that one woud be enough.... but well i m not the guy with the keyboard.
guessing here, based on my own failed experiment: the antialias has to be aware of the the gradient (basically the angle of the line) where it's antialiasing. You get that angle by sampling the neighbouring pixels (or blurring, and using the gradient of the blur).
Problem is, when the line is nearly horizontal or vertical, the sharp line you want to fix might have sections that are straight for say 5 pixels. When you do the pixel in the centre, a 1-pass blur will only sample the straight part of the line - i.e. it'll assume this line is straight, and not blur it correctly. You end up with a line that's blurry, but with noticeable steps still. With a bigger blur, you cover a larger area, making this less likely.
Problem is, when the line is nearly horizontal or vertical, the sharp line you want to fix might have sections that are straight for say 5 pixels. When you do the pixel in the centre, a 1-pass blur will only sample the straight part of the line - i.e. it'll assume this line is straight, and not blur it correctly. You end up with a line that's blurry, but with noticeable steps still. With a bigger blur, you cover a larger area, making this less likely.
With only one pass (actually two, for X/Y) you see what we tend to call SHARP BLURRING ARTIFACTS here at higher resolutions. The screenshot with all passes is useful for debugging but not representative quality wise - e.g. the fxaa3 looks crap at very low resolutions.
In addition to that - the blur passes are not very expensive.
In addition to that - the blur passes are not very expensive.
las: Is that refracted light or just some kind of reflection of awesomeness?
Also will your paper from upcoming seminar be available as pdf(or whatever you prefer) later.
Also will your paper from upcoming seminar be available as pdf(or whatever you prefer) later.
Second sentence was question too(see what I did there).
a13X_b: no that's fake SSS gone wild ;)
If you contact me via IRC you can have the slides with all the nice pictures now else you have to wait a bit :)
If you contact me via IRC you can have the slides with all the nice pictures now else you have to wait a bit :)
Come on guys - make some noise. I'm bored!
Working on it(noise literally). Need more vodka. Hopefully will finish on monday.
EU ircnet is undefeatable so I'll just wait.
EU ircnet is undefeatable so I'll just wait.
Try http://webchat.xs4all.nl/
Hi all, the latest ATI driver update seems to have broken my demo. Everything renders fine but just doesn't get sent to the final post process pass. For some reason it all seems to work while I'm using GLIntercept. I'm completely out of ideas of what to do :/
Mewler: debug with GDEbugger.
Distance functions (courtesy of iq, snatched from the "useless raysomething tutorial thread"):
Same coordinate-free method can (and should) be used for other primitives. For example, a plane
You can use the same for cylinders, cones, and any other shape that you can describe with vector operations (distances, projections/dots, mirrors, etc).
Code:
line: P = A + t * AB
sphere: |P - C| = r
substitute P
|AC + t * AB| = r
|AC + t * AB|² = r²
|AC|² + t² * |AB|² + 2*t*<AC,AB> = r²
So we have a quadratic equation with:
a = |AB|²
b = 2<AC,AB>
c = |AC|² - r²
therefore
t = -b +/- sqrt (b² - 4*a*c) / (2*a)
You can of course do b = <AC,AB> and a=1, and then t = -b +/- sqrt(b² - c)
Same coordinate-free method can (and should) be used for other primitives. For example, a plane
Code:
line: P = A + t * AB
plane: <P,C> = d
substitute P
<A + t * AB,C> = d
<A,AB> + t * <AB,C> = d
t = (d - <A,AB>) / <AB,C>
You can use the same for cylinders, cones, and any other shape that you can describe with vector operations (distances, projections/dots, mirrors, etc).
You lost me. How are they distance functions?
uhm. "intersection functions"...
Some people raytrace some stuff instead of raymarching it. I thought it would fit here :/
Some people raytrace some stuff instead of raymarching it. I thought it would fit here :/
Yes it does - I use that to accelerate my raymarching.
fixing a bug... for the line, it is:
<A,AB> + t * <AB,C> = d
t = (d - <A,C>) / <AB,C>
<A,AB> + t * <AB,C> = d
t = (d - <A,C>) / <AB,C>
Can tools like mathematica handle this type of work ?
iq, is your notation defined somewhere ?
Also is it just me, or 99% of the math found on the web is anything but self evident because of the extreme use of shorthand and no context definition.
Its like posting code snippet by renaming all variables using a single characters and removing ALL type definition, and using overloaded operators with different functions (but not defined)
Then you have something called math! :)
iq, is your notation defined somewhere ?
Also is it just me, or 99% of the math found on the web is anything but self evident because of the extreme use of shorthand and no context definition.
Its like posting code snippet by renaming all variables using a single characters and removing ALL type definition, and using overloaded operators with different functions (but not defined)
Then you have something called math! :)
@xernobyl: Thanks! That program is really useful. Manage to isolate the problem: the final post process pass is REFUSING to render any rendered textures. Just displays black. All other textures, like overlays work fine. Its strange because all other passes are working fine.
Hello World.
Neither a sphere nor a cube, just a simple ugly spikeball.
To all "beginners" (hi T21) - please use THIS thread, thanks.
Code:
float2 res; // Widht/Height
float t; // Time
float3 c[19]={
{1,0,0},{0,1,0},{0,0,1},
{.577,.577,.577},{-.577,.577,.577},
{.577,-.577,.577},{.577,.577,-.577},{0,.357,.934},
{0,-.357,.934},{.934,0,.357},{-.934,0,.357},
{.357,.934,0},{-.357,.934,0},{0,.851,.526},
{0,-.851,.526},{.526,0,.851},{-.526,0,.851},
{.851,.526,0},{-.851,.526,0}};
float spikeball(float3 p){
float l = length(p);
p = normalize(p);
float b=0;
for (int i=3;i<19;i++)
b=max(abs(dot(p,c[i])),b);
b=1-acos(b-.01)/(acos(-1)/2);
b=smoothstep(.78,1,b);
return l-2.2*pow(1.5,b*(1.-lerp(.1,2,sin(t+t)*.5+.5)*b));
}
// Rotation
#define R(p, a) p=cos(a)*p+sin(a)*float2(p.y,-p.x)
float f(float3 p){
p.z+=10.;
p.y+=.5;
float3 q=p;
R(p.yz,t);
R(p.xz,t+t+p.x*sin(t)*0.2);
float d = spikeball(p);
float nd = dot(q+float3(0.,3., 0.), float3(0., 1.,0.));
return min(nd,d)*0.8;
}
float as(float3 p, float3 n, float d, float i){
float s=sign(d);
float o=s*.5+.5;
for(;i>0;--i)
o-=(i*d - f(p+n*i*d*s))/exp2(i);
return saturate(o);
}
float4 main(float2 v:TEXCOORD):COLOR{
// p: Position / d: Direction
float3 p=float3(0,0,3);
float3 d=float3(v*float2(res.x/res.y,1), 0) - p;
d=normalize(d);
// Raymarching loop
float i, r, l, a, s, ml=.001;
for (i=0; i<1; i+=1/64.){
l = f(p);
p += l*d;
l = abs(l);
r += l;
if (l < ml*r) break;
}
// Compute normal
float2 epsilon = {.01,0};
float3 n=normalize(
float3(
f(p+epsilon.xyy) - f(p-epsilon.xyy),
f(p+epsilon.yxy) - f(p-epsilon.yxy),
f(p+epsilon.yyx) - f(p-epsilon.yyx)
)
);
return max(1+dot(n,d),0);
}
Neither a sphere nor a cube, just a simple ugly spikeball.
To all "beginners" (hi T21) - please use THIS thread, thanks.
*width... where is the frakkin' preview button, it's gone!
Thanks las! I actually could use a spikeball :)
I have the normal computed using this code and the result look good.
(the cylinder and rounded edge cube are lighted correctly)
I will post my followup question here.
So far this is a great complement to my little raytracing toy.
I have the normal computed using this code and the result look good.
(the cylinder and rounded edge cube are lighted correctly)
I will post my followup question here.
So far this is a great complement to my little raytracing toy.
Nevermind, got it working. Broke OpenGL by sending a bogus sampler type.
@las: Your using DX now? How is it, faster?
@las: Your using DX now? How is it, faster?
Quote:
Code:for (int i=3;i<19;i++) b=max(abs(dot(p,c[i])),b);
Why the abs() here? To make it symmetric?