pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
Silicon, I'm not 100% that this is ray marching - did you read the old Zeno paper?

Also, your view seems to be orthogonal (exactly same travelling direction, different starting points), and not pinpoint perspective (same start position, different travelling direction) like "we are used to", which I assume is erroneous!

Keep going, everyone will help sort it out.
Ray marching > Sphere tracing.

He's marching along a ray - so that's an ray marching based algorithm.
And there is nothing wrong with an ortho view.
(e.g. if you are doing a 256b :)
added on the 2012-09-24 11:03:25 by las las
gloom: I'm not crazy I'm a violated genius.

T21: I can not heard more sound from my fans exactly because I've worked too much. but raymarching needs shaders of graphic cards. I do invent shaders for graphic cards from my softwares. It's not written anywhere, so I write it here.

I do maintain that graphic cards are the big problem of nowadays computer, and when computer can override them it's cleaner and I do prefer software raymarching than shader raymarching.
added on the 2012-09-24 11:35:50 by Bartoshe Bartoshe
Moreover, if you do not understand, explain me correctly why shaders arent compatible from nvidia, ati, intel etc ?

I do exeplain you that people here are silly and harrass me. it makes intel ingeneers wondering if they have rights because they do not want to experiment those people mind states.
added on the 2012-09-24 11:41:12 by Bartoshe Bartoshe
more than moreover, there is no patents, I won !
added on the 2012-09-24 11:42:45 by Bartoshe Bartoshe
moreover, do not joke with my sanity. financial crisis is due to psychiatry poisonning me with their shity meds. it's just you must know, that I'm a master and I will not code any shaders to be compatible, because it still stupid to code a shader.
added on the 2012-09-24 12:05:55 by Bartoshe Bartoshe
finally, to understand the problem, those people hallucinate me, and they slunder me to succeed in. the fact is that those people are racists and more they think they've got gives from god instead of feeling silly and they want to say they've been raped exactly to be such alienate and retarded people. I give them the idea, just so you know, but I'm the only sane. it's evident those people are not able to write a sentence correctly on a paper, but with my time machine they caused wars and alienations. you are only ignorants because you do not want to suffer, but it's antipsychiatry of huge level, and I'm demonstrating all the fact recording. Because it's simple to deny you hallucinate, and nobody can verify, but in fact, we have identified even policemen in the parasitism of my ntellectual properties. I work for militar purpose in criminology exactly.
added on the 2012-09-24 12:11:57 by Bartoshe Bartoshe
You are currently trying to derail a helpful thread. Could you please drop your thoughts somewhere else?
added on the 2012-09-24 12:47:12 by las las
it's interesting isn't it ? imagine your brain throught raymarching metaballs...
added on the 2012-09-24 13:16:21 by Bartoshe Bartoshe
las: I say he keeps going, then there will be grounds for a ban.
added on the 2012-09-24 13:20:06 by gloom gloom
I dunno, "brain throught" sounds pretty tasty.
added on the 2012-09-24 14:15:41 by ferris ferris
#akkuratsommeddamenemine...?
added on the 2012-09-24 14:16:14 by ferris ferris
I think the answer lies somewhere between 'ear plugs' and 'full-frontal lobotomy'.
added on the 2012-09-24 14:17:59 by raizor raizor
@Lord Graga: doesnt this set it to the projection view i set up through opengl functions?

Code:" pos_rotated = dv*mvpMat;\n"


i pass this from the vertex shader, which gets it from a opengl global

also.. you may have noticed that my later screenshots are a different resolution.. thats because I couldn't use my mvp matrix in my vertex shader anymore since if i were to use that there, my full screen quad would get rotated when i try to rotate the cube. thats also why I tried to write my own rotation matrix generator. without using the mvp matrix in the vertex shader, I couldn't maintain aspect ratio anymore since my aspect ratio was programmed into the projection matrix using opengl function calls. thats why the later screenshots have square aspect ratios. getting the aspect ratio correct will probably be the next thing i will try, probably first starting with trying to get Shabby's rotation matrix function to work in my program (thanks for that shabby!)
raizor, did I abuse of you ? try to apply your advice to yourself.
added on the 2012-09-24 15:20:55 by Bartoshe Bartoshe
Bartoshe, it was more a reference to the fan noise and mention of raymarching brains than a suggestion that you have your head operated on ;) I've never had much luck with passively cooled GPUs (without fans) but it seems they are starting to make more reliable and powerful ones such as this GTX-680 or this X670. Not sure about price but I expect they're quite expensive.

I still stand by the ear-plugs comment though, unless you're rich :)

added on the 2012-09-24 15:48:46 by raizor raizor
BB Image
@Shabby: thanks for the tips!

heres my shader now:
Code:#define STRINGIFY(x) #x const static char *fs = STRINGIFY( uniform float t; mat3 genRotMat(float a0,float x,float y,float z) { float a=a0*3.1415926535897932384626433832795/180.0; return mat3( 1.0+(1.0-cos(a))*(x*x-1.0), -z*sin(a)+(1.0-cos(a))*x*y, y*sin(a)+(1.0-cos(a))*x*z, z*sin(a)+(1.0-cos(a))*x*y, 1.0+(1.0-cos(a))*(y*y-1.0), -x*sin(a)+(1.0-cos(a))*y*z, -y*sin(a)+(1.0-cos(a))*x*z, x*sin(a)+(1.0-cos(a))*y*z, 1.0+(1.0-cos(a))*(z*z-1.0) ); } float cubeDist(vec3 p){ float t0 = 0.5; float t1 = 0.6; float max = max(abs(p.x),max(abs(p.y),abs(p.z))); if(max > t1) return 0.0; else if(max > t0) return (t1-max)/(t1-t0); else return 1.0; } void main() { float spread = 1.0; float total=0.0; float delta=0.05; float minDepth=-1.0; float maxDepth=1.0; vec3 col=vec3(0.0,0.0,0.0); vec3 ray=vec3(0.0,0.0,0.0); mat3 rot=genRotMat(sin(t/2.0)*360.0,1.0,0.0,0.0); rot=rot*genRotMat(sin(t/2.0)*360.0,0.0,1.0,0.0); rot=rot*genRotMat(sin(t/2.0)*360.0,0.0,0.0,1.0); vec2 p; p.x=gl_TexCoord[0].s; p.y=gl_TexCoord[0].t; for(ray.z=minDepth;ray.z<maxDepth;ray.z+=delta){ vec3 temp; ray.xy+=p.xy*spread*delta; temp=ray.xyz*rot; total+=cubeDist(temp); col.x+=abs(temp.x*delta/20.0); col.y+=abs(temp.y*delta/20.0); col.z+=abs(temp.z*delta/20.0); } gl_FragColor=vec4(col.xyz*total,1.0); } );
can you post full source code for your "cube" ?
added on the 2012-09-25 09:19:49 by Bartoshe Bartoshe
with opengl part.
added on the 2012-09-25 09:21:29 by Bartoshe Bartoshe
SiliconLife, that looks dope! Lovely colours.
added on the 2012-09-25 09:31:53 by raizor raizor
@SiliconLife:
It is a beautiful color box!

I tried STRINGIFY macro, but it has a problem.
It replaces any sequence of ' ', '\t' and '\n' to a ' '.
Thus you can't use glsl preprocessor and 1 line comment(//).
And it is difficult to find wrong code when you got error messages with line number from glsl compiler.

This code can keep lines in shader code:
Code: #define STR_(x) #x #define STR(x) STR_(x) #define GLSL_LINE "#line " STR(__LINE__) " " __FILE__ "\n" #define _ \n const char* str = GLSL_LINE STR( uniform float t;_ _ void main()_ {_ gl_FragColor = vec4(sin(t), 0, 0, 1);_ }_ ); #undef _

but bit ugly.

When you learn or try experimental shader, there are useful shader tools:
shader toy, GLSL Sandbox, live coder, fragmentarium, etc.

When you make a executable, put your glsl code in external file and your program load it in debug build.
So that you don't need to rebuild your program after you edit your shader.
(If your executable is 1~64k, put glsl code in your program in release build)
added on the 2012-09-25 10:34:45 by tomohiro tomohiro
@SiliconLife - looking good - better than the usual sphere subtract cube :P

@tomohiro - always wondered why the preproc didn't work - thx for the heads up - tho no \r\n is useful sometimes :
http://www.gremedy.com/ :P
added on the 2012-09-25 11:15:34 by Shabby Shabby
@Bartoshe: here is the c++ code for linux, its just a generic full screen quad: http://pastebin.com/dmCc3GXG
can you post to shader.h ?
added on the 2012-09-25 16:54:28 by Bartoshe Bartoshe
well, the program needs shader.h to run... and I'm in the need of motivation, in fact.
added on the 2012-09-25 16:55:46 by Bartoshe Bartoshe

login

Go to top