pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
stupid graphician question : why so many blur passes
added on the 2011-06-28 14:25:09 by nytrik nytrik
Because it works. See post above.
@The professionals from the gamedev and so on: How would you do a smooth blur? Also multiple passes?
added on the 2011-06-28 14:31:47 by las las
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.
added on the 2011-06-28 14:53:31 by nytrik nytrik
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.
added on the 2011-06-28 15:01:47 by psonice psonice
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.
added on the 2011-06-28 15:10:17 by las las
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.
added on the 2011-06-29 09:18:04 by a13X_B a13X_B
Second sentence was question too(see what I did there).
added on the 2011-06-29 09:35:53 by a13X_B a13X_B
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 :)
added on the 2011-06-29 23:36:50 by las las
Come on guys - make some noise. I'm bored!
added on the 2011-07-02 11:13:57 by las las
Working on it(noise literally). Need more vodka. Hopefully will finish on monday.
EU ircnet is undefeatable so I'll just wait.
added on the 2011-07-02 11:42:47 by a13X_B a13X_B
Try http://webchat.xs4all.nl/
added on the 2011-07-02 11:51:44 by las las
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 :/
added on the 2011-07-04 12:04:01 by Mewler Mewler
Mewler: debug with GDEbugger.
added on the 2011-07-04 14:10:55 by xernobyl xernobyl
Distance functions (courtesy of iq, snatched from the "useless raysomething tutorial thread"):

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).
added on the 2011-07-04 14:25:30 by raer raer
You lost me. How are they distance functions?
added on the 2011-07-04 15:21:05 by doomdoom doomdoom
uhm. "intersection functions"...
Some people raytrace some stuff instead of raymarching it. I thought it would fit here :/
added on the 2011-07-04 15:38:41 by raer raer
Yes it does - I use that to accelerate my raymarching.
added on the 2011-07-04 16:28:45 by las las
fixing a bug... for the line, it is:

<A,AB> + t * <AB,C> = d

t = (d - <A,C>) / <AB,C>
added on the 2011-07-04 20:27:39 by iq iq
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! :)
added on the 2011-07-04 23:34:57 by T21 T21
@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.
added on the 2011-07-05 09:18:27 by Mewler Mewler
Hello World.
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.
added on the 2011-07-07 02:44:51 by las las
*width... where is the frakkin' preview button, it's gone!
added on the 2011-07-07 02:45:35 by las las
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.
added on the 2011-07-07 04:15:05 by T21 T21
Nevermind, got it working. Broke OpenGL by sending a bogus sampler type.

@las: Your using DX now? How is it, faster?
added on the 2011-07-07 09:56:48 by Mewler Mewler
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?

login

Go to top