Where do I start rendering worlds in 2 triangles? :D
category: general [glöplog]
Do you know/have any sample code with a simple raytracer done on a shader, maybe with a couple of spheres? I have no idea where to start... well I have an idea, but... my doubt comes to the whole structure of the code, not the math... at the moment. Do you do one pass per object? How does it work?
You very simply set up a program that renders a quad using a single pixel shader. In this shader, you handle it all. Complete traversal of the scene for each pixel. For smaller or test stuff you can very well even hardcode these scenes in the pixelshader itself. Otherwise you use shader constants and possibly texture data to feed your tracer.
Again, this is a simple approach. But most of those 4Ks don't do much else than this. And some of them have source available, so have a look..
Again, this is a simple approach. But most of those 4Ks don't do much else than this. And some of them have source available, so have a look..
(and obviously, you can use the interpolated position fed by your vertex shader, typically -1 to 1 on an both axii as your screen position)
Then again, I haven't done too much tracing in shaders yet, the more seasoned people can probably give some nice pointers as well. Also, there are a few more topics that have (psuedo) code in them - that should more or less give you an idea.
Then again, I haven't done too much tracing in shaders yet, the more seasoned people can probably give some nice pointers as well. Also, there are a few more topics that have (psuedo) code in them - that should more or less give you an idea.
you could do this:
http://sizecoding.blogspot.com/2008/11/intersecting-ray-with-spheres-glsl.html
aint the sphere_tracing every1 does right now tho, but theres a thread about sphere_tracing @pouet somewhere already !
http://sizecoding.blogspot.com/2008/11/intersecting-ray-with-spheres-glsl.html
aint the sphere_tracing every1 does right now tho, but theres a thread about sphere_tracing @pouet somewhere already !
Quote:
And some of them have source available
Obfuscated code is not what I call source :D
cocoon: that should help. I'll take a deeeper look.
Yeah I'm with you on that obfuscated thing - but not all have supplied it like that right?
That blog has some good 'start here' stuff on it too.
That blog has some good 'start here' stuff on it too.
There are a zillion raymarching topics on pouet. Also check out the iq presentation(s) which you most likely already know about...
yeh, and try start solving quartic equations. *bang*
xernobyl: opengl or directx? I have both for this, but only the old (and obfuscated shader source) ogl version in the released archieve (I'm using the effect as a "benchmark" for 1k framework experiments).
On the other hand, the ogl version is rendering a quad and the dx a single triangle so that's not what you are asking for ;)
xernobyl: http://iquilezles.org/www/material/isystem1k4k/isystem1k4k.htm
Just pick Lumos, Accio or Reducto. These are exactly what you are asking for.
Just pick Lumos, Accio or Reducto. These are exactly what you are asking for.
Ok, I get it for a few simple shapes, anything else that requires some sort of geometry sorting and a few optimizations is out of the question, like feeding a few triangles to a shader?
A new gfx card to play with on such a busy week...
IQ:
Really cool samples. I'm just trying it (VC 2008), and I get these results:
g4k_OGLShader:
It works, but flickers a lot. I'm not sure if it is an error or how it should work anyway... and maybe because of my drivers maybe? Whatever
g4k_Software:
Works perfect.
i1k_D3D9Shader:
1>.\src\intro.cpp(9) : fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory
i1k_OGLShader:
Shows a static image for few seconds, then some weird flickering for less than a second, then again the same static image.
i4k_D3D9:
1>.\src\intro.cpp(9) : fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory
i4k_OGL:
I'm not sure if this is working correctly or not. There is a rotating cube that looks fine and a continuous beep in the same tone as "music"
i4k_OGLShader:
The raytracing works fine, there is the same beep as in the thing above.
i4k_Software:
Looks to be working correctly, but very slow (maybe 10-15 fps) and no sound support.
My specs: Windows Vista SP2 32 bits, Intel Core 2 4400, Raden X1650, DirectX 10
What I have to do to be able to compile the d3dx9.h samples? I suppose I should download any SDK or whatever? Wich one? And should I install it doing anything special?
And, should I learn for the first time with the HLSL or the GLSL? Is there any difference in speed or something? I just want to code for Windows right now, so I don't need portability if that is a difference.
Really cool samples. I'm just trying it (VC 2008), and I get these results:
g4k_OGLShader:
It works, but flickers a lot. I'm not sure if it is an error or how it should work anyway... and maybe because of my drivers maybe? Whatever
g4k_Software:
Works perfect.
i1k_D3D9Shader:
1>.\src\intro.cpp(9) : fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory
i1k_OGLShader:
Shows a static image for few seconds, then some weird flickering for less than a second, then again the same static image.
i4k_D3D9:
1>.\src\intro.cpp(9) : fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory
i4k_OGL:
I'm not sure if this is working correctly or not. There is a rotating cube that looks fine and a continuous beep in the same tone as "music"
i4k_OGLShader:
The raytracing works fine, there is the same beep as in the thing above.
i4k_Software:
Looks to be working correctly, but very slow (maybe 10-15 fps) and no sound support.
My specs: Windows Vista SP2 32 bits, Intel Core 2 4400, Raden X1650, DirectX 10
What I have to do to be able to compile the d3dx9.h samples? I suppose I should download any SDK or whatever? Wich one? And should I install it doing anything special?
And, should I learn for the first time with the HLSL or the GLSL? Is there any difference in speed or something? I just want to code for Windows right now, so I don't need portability if that is a difference.
texel, you could download and install the directx sdk :D
And those who want sources for "big shader 4ks" that are not obfuscated, just take a look at valleyball
Update: after installing DirectX SDK, and doing nothing more, d3dx9.h samples works flawlessly :D
A note on IQs HLSL sample:
If you want to make a shader model 3 program, you have to make a shader model 3 vertex shader and pixel shader with shader model 3 too.
If you just change in the pixel shader the 2 by a 3 in the compile function, it doesn't work unless you add a vertex shader 3 too.
This took me a lot of hours to understand yesterday, so I think it could be worth to add a sample for sm3 (and sm4 maybe) in the Iqs code collection... I will tell him to do it.
If you want to make a shader model 3 program, you have to make a shader model 3 vertex shader and pixel shader with shader model 3 too.
If you just change in the pixel shader the 2 by a 3 in the compile function, it doesn't work unless you add a vertex shader 3 too.
This took me a lot of hours to understand yesterday, so I think it could be worth to add a sample for sm3 (and sm4 maybe) in the Iqs code collection... I will tell him to do it.
I have recently tried the IQ samples frameworks... thanks to IQ for it! At least it gives a simple overview about the think "2 triangles, 1 world"
(by the way.. IQ past some of source code of a procedural GFX in another poet thread)
what about make some "nehe" tutorials for intros? .. someone try get in examples like IQ ones and make some good explanation will be cool
(by the way.. IQ past some of source code of a procedural GFX in another poet thread)
what about make some "nehe" tutorials for intros? .. someone try get in examples like IQ ones and make some good explanation will be cool