pouët.net

Raymarching Beginners' Thread

category: code [glöplog]
thx Las - I just tried the ray warp with your setup - it kinda works :P

http://glsl.heroku.com/e#4008.0
added on the 2012-09-20 21:25:02 by Shabby Shabby
This old one is similar http://glsl.heroku.com/e#865
Using the sandbox http://glsl.heroku.com/e#4016.0

But it's not the same effect, because the cubes in texas, are also tilted with the wave normal.

That's more hard to do in raymarching because the symmetryis are not regular like in a checkboard.
Cool thx !

Quote:
But it's not the same effect, because the cubes in texas, are also tilted with the wave normal.



That's why you need to modify the ray "in flight" this gives the correct warp so the cubes tilt'n'stuff.

Just need to sort out the errors when stepping from one rep domain to another with a different height - I guess u can predict the step size to take based on the Height mod function you use.
added on the 2012-09-20 23:15:42 by Shabby Shabby
well - modifying the ray "in flight" will give you horrible artifacts :)
added on the 2012-09-20 23:19:44 by las las
Quote:
well - modifying the ray "in flight" will give you horrible artifacts :)


It does indeed :) I have no Idea what that is - maybe it's a distance traveled error or something - maybe you calc the correct distance with some fake integration shenanigans.
added on the 2012-09-20 23:24:22 by Shabby Shabby
I can't look at shaders/raymarching... it's just so addictive LOL
Another shader, based on the last ones... :)
Tile Waves
Considering modifying in flight: as long as your ray follows certain curve (not dependent on sampled distance values), it should be OK as long as in each iteration you don't move further away from sampled position as the returned safe distance.
added on the 2012-09-21 10:55:51 by KK KK
Quote:

not dependent on sampled distance values

Well, that's boring than.
added on the 2012-09-21 11:54:36 by las las
that one dependent on the sampled distance but works out quite well, hmm. ;)
added on the 2012-09-21 18:34:20 by las las
the problem with raymarching is that I should use nvidia chipset instead of my quiet intel integrated. this means huge fan sounds from my computer and moreover, it will never works on all platforms.
added on the 2012-09-23 17:53:34 by Bartoshe Bartoshe
If you happen to prefer intel's gl implementation over nvidia's, then i'm at a loss of words.
added on the 2012-09-23 18:12:53 by kbi kbi
shaders are not uniforms ! did you know I was the great inventor brain for shaders ? when everybody used graphic cards to make 3d, I was finnishing my own engine that is 8500 polys in 70% of vertical blank on P133 animated and shadowed stuff. it was incredible the time I've spent to make software shaders to get this particular stuffs, and I was looking for automatise my routines. It's because we invent too clear type for windows in Huge Crowd. those people recognize themselves as amateurs, as directx8 and directx9 camera matrix was corrected by my care. at now, I've developped unusefull tools and games and libraries to make cross platform games and I'm threaten like an alienate by people here that feel strange with huge sound of the daemon. well, microsoft is the bullshit and my fingers make it possible. do you understand I use computers now like everybody people who buy software, computers without the understandings of maths ?
It's reality that I say, and when I'm getting injured by rez like if I was an alienate or a criminal, I'm very disappointed, and it makes different version of shaders.
added on the 2012-09-23 18:22:26 by Bartoshe Bartoshe
I've studied the matrix gram-schmidt orthonormalisation in "prepa" before ingeneer school.
added on the 2012-09-23 18:40:55 by Bartoshe Bartoshe
let's say people here are really silly ones !
added on the 2012-09-23 18:48:20 by Bartoshe Bartoshe
i'd say we all have studied gram-schmidt orthogonalization of matrices at school, (two years) before university....

i'm answering this part of your comments because it's the only part i understand from it :)
added on the 2012-09-23 20:18:08 by iq iq
What iq said follow by WTF!!!
added on the 2012-09-23 20:23:14 by maytz maytz
drop those pills, Bartoshe, they are making you brain-dead. For real.
added on the 2012-09-23 21:47:21 by kbi kbi
Bartoshe I didn't see a way to msg you directly:
But please read what you write before posting.
Or maybe wirte in French and use Google translate ?

You come out as lunatic and are just polluting this thread with drivel.

If you are frustrated because you cant see or write ray-marching code because you cant stand the noise of an nvidia card? yes?
Then you should look at 28nm fanless models and explore/apply your mathematical knowledge without any fan noise.

BTW, you can write this type of stuff on the CPU... but I'm afraid you CPU will heat up and the fan will spin.
added on the 2012-09-24 02:43:19 by T21 T21
just learned how to raymarch in a couple hours, here are pics of my progress from not knowing shit about what to do.. to a simple raymarched cube

BB Image
BB Image
BB Image
BB Image

i might put my 3d julia set in a raymarcher next..

for beginners, here is my shader code for example purposes:

Code:static const char *vs = \ "varying mat4 mvpMat;\n" "void main(void)\n" "{\n" "gl_Position=gl_Vertex;\n" "gl_TexCoord[0]=gl_Vertex;\n" "mvpMat = gl_ModelViewMatrix;\n" "}\n"; const static char *fs=\ "uniform vec3 pos;\n" "uniform vec3 dim;\n" "uniform float scan_radius;\n" "uniform float delta;\n" "uniform mat3 rot_mat;\n" "varying mat4 mvpMat;\n" "bool inside(float x, float y, float z){\n" " vec4 dv;\n" " vec4 pos_rotated;\n" " dv.x = x - pos.x;\n" " dv.y = y - pos.y;\n" " dv.z = z - pos.z;\n" " dv.w = 1.0;\n" " pos_rotated = dv*mvpMat;\n" " if(abs(pos_rotated.x)>dim.x) return false;\n" " if(abs(pos_rotated.y)>dim.y) return false;\n" " if(abs(pos_rotated.z)>dim.z) return false;\n" " return true;\n" "}\n" "void main() {\n" " float x = gl_TexCoord[0].s;\n" " float y = gl_TexCoord[0].t;\n" " float z;\n" " int count = 0;\n" " for(z = -scan_radius; z < scan_radius; z+=delta)\n" " {\n" " if(inside(x,y,z)){\n" " count++;\n" " }\n" " }\n" " float c = float(count)/(scan_radius/delta);" " gl_FragColor = vec4(c,c,c,1.0);" //" gl_FragColor = vec4(abs(x),abs(y),0.0,1.0);" "}";
i tried to generate my own rotation matrix to pass to the fragment shader but failed miserably lol.. anyone know what was wrong with it?

Code:void gen_rot_mat(float x, float y, float z, float rot_mat[]){ rot_mat[0] = cos(y)*cos(z); rot_mat[1] = sin(y)*cos(z); rot_mat[2] = -sin(y); rot_mat[3] = -cos(x)*sin(z)+sin(x)*sin(y)*cos(z); rot_mat[4] = cos(x)*cos(z)+sin(x)*sin(y)*sin(z); rot_mat[5] = sin(x)*cos(y); rot_mat[6] = sin(x)*sin(z)+cos(x)*sin(y)*cos(z); rot_mat[7] = -sin(x)*cos(z)+cos(x)*sin(y)*sin(z); rot_mat[8] = cos(x)*cos(y); }
SiliconLife - well done - but the stringify macro is your friend!


#define STRINGIFY(x) #x

char* vs=STRINGIFY(
...
shader code without quotes
...
);
added on the 2012-09-24 04:04:20 by Shabby Shabby
and here's my rot mat funk that I pass to gl via a mat4 uniform - which works a treat:
where glRotatMat has already been filled with Identity:

float glIdentMat[16]={1,0,0,0, 0,1,0,0, 0,0,1,0 ,0,0,0,1};

void glesRotatef( float a, float x,float y, float z)
{
float angle=a*PI_OVER_180;
glRotatMat[0] = 1+(1-cos(angle))*(x*x-1);
glRotatMat[1] = -z*sin(angle)+(1-cos(angle))*x*y;
glRotatMat[2] = y*sin(angle)+(1-cos(angle))*x*z;
glRotatMat[4] = z*sin(angle)+(1-cos(angle))*x*y;
glRotatMat[5] = 1+(1-cos(angle))*(y*y-1);
glRotatMat[6] = -x*sin(angle)+(1-cos(angle))*y*z;
glRotatMat[8] = -y*sin(angle)+(1-cos(angle))*x*z;
glRotatMat[9] = x*sin(angle)+(1-cos(angle))*y*z;
glRotatMat[10] = 1+(1-cos(angle))*(z*z-1);
glesMultMatrix(GL_MODELVIEWMAT,glRotatMat);
gMatrixChanged=true;
}
added on the 2012-09-24 04:13:29 by Shabby Shabby
T21: don't argue with a crazy person. :)
added on the 2012-09-24 07:54:02 by gloom gloom

login