hi all! i’m kinda developing a standard, general purpose ray marching shader “engine” and a simple “library” all in .fx files. i’m making progress, there are already some useful stuffs in it.
but i’d like to have it as a kinda “community built” stuff. i mean if anybody has the affinity to improve it please do so because now it doesn’t have any kind of optimization and produces some ugly artifacts which i couldn’t overcome. also it doesn’t have more advanced primitives and modifiers (like BVH and stuff), only the sphere has texture mapping and i haven’t tried any texture based data input yet (there are some placeholders though)
so the stuff itself:
http://dl.dropbox.com/u/1218206/RayMarcher%20help-DirectX%20Renderer_2012.05.11-05.24.33.png
geometries/primitives: (geometries.fx)
every geometry have to be expressed in distance and could be transformed by altering the current ray position before calculating the geometry itself. i’m planning to use a structure called “geometrydata” as output for geometry functions which contains a float “distance” and a float2 “texture” coordinate. currently only the sphere uses this structure.
i need help in calculating the texture coordinates for the other primitives too (i’m not a math expert)
and i need a lot of help in calculating distance of an arbitrary mesh stored in textures (separate textures for vertices and for indices i thought of a flexible data format too).
modifiers: (modifiers.fx)
they alter the ray position so a geometry will be “tricked” and will be rendered somewhere else as it’s supposed to by default. they return a float3 altered ray position. i need help in bending and in finding out how to do fish-eye
operators: (modifiers.fx)
mainly for boolean modelling. which operation wouldn’t involve material blending that returns a structure called “opdata” which has 2 parts a float “distance” and an int “material”
materials: (materials.fx)
scene management happens in shaders i copied Kian Bashiri’s method (materials have separate int ID’s and distanceField.fx manages them). materials.fx is only a list of used materials and their basic properties (like colors as it’s now, but i’m planning to put there textures and light reaction properties too) also i would define ray direction modifiers here too (like reflection and refraction) since i couldn’t do any of them i just wrote the function prototypes there.
shaders: (shaders.fx)
they return the structure “shaderdata” which has float “lightness” for altering main color and int “operations” for debugging. the current shadows are ugly i’d need some help with that too.
currently i only implemented sun light but creating a point light is quite straightforward i was just lazy. i don’t know how to do spotlight though
the main shader (RayMarcher.fx) output 4 rendertargets (color, position, normal, debug). it compiles for a loooong time so don’t be confused vvvv isn’t freezed permanently, and it’s very gpu-heavy so watch your temperature too.
also i’m curious if something like this could be done in vvvv: http://www.iquilezles.org/www/articles/raypolys/raypolys.htm
references:
http://www.mazapan.se/news/2010/07/15/gpu-ray-marching-with-distance-fields/
http://www.iquilezles.org/www/index.htm
that’s all. if somebody has some opinion idea please share it!
there you can see it in action (10.9 kB)