Progress On Ray Marching

still no meaningful  progress, just a couple of cylindrical object tests. below is a screen shoot showing that the scene rendered using a pretty low GPU. On resolution 1024 x 512 i got about 12 FPS. so bad in performance. Tested on nvidia gtx 980 for about 200+ fps. Pretty satisfying for next gen hardware. I need to add that this rendering system literally takes less than 1% CPU. that makes a big plus. if i build a threading system around this, i can have a pretty decent game engine. 20161212

See bellow. A cylinder can look really nice. I bake a high polygon model in blender. chop it to several pieces, bake the displacement maps on to textures using cylindrical projection, then put them together in c++. you can still notice the low FPS due to the same low performance integrated graphic card i’m using. Well feels like tessellation without geometry shader. if you look closely you will notice that the shadow still wrong. 20161212b

below are the Indian temple texture i previously use. this scene made out of cubes and one sphere. the stat on the upper left corner says 2 draw calls and 11 objects. basically i implemented composite type object, where objects are grouped together to minimize draw call, and decreasing render target switching. 20161212c

full size images image1 image2 image3


Optimization on Ray Marching

first optimization attempt is to make the render target as small as possible. so i change the render target color format from RGBA32 F to GR32 F. for depth buffer i store it on red channel which is 32 bit, and for the color part inside green channel which also 32 bit.

for the depth it is pretty straightforward, just store it right away and done. for the color part. the color are vec4 value, i use RGBA to Float encoding, so i can have single float value to store that vec4 color into one 32 bit channel.

if you interested in the encoding part you can read it here.

for rendering i need to disable any texture filtering because it might break the encoding and turn color into noise. as shown in the image below. disabling texture filtering exposed the primitive i’m using in the ray marching. yes i’m using cubes for estimating object volume. need a better approach.


here is the rendering window split, i think i can do a simple multi sampling for the color map and normal map to remove the voxelized looks.



[edit] i thought too much detail on depth voxelized my scene, turn out heighmap texture filtering are the problem here. bilinear filtering on the height texture create the voxelized effect. re enabling them fix the problem. i think that voxel looks can be a useful effect someday.

Ray Marching for geometry



i was wandering if it is possible to beat polygon count with ray marching. instead of just wondering around with the idea, i start coding. for start every object is like a terrain object. only use single height map and a color texture. usually people store height in the alpha channel, but i think alpha channel is required to make a non “cube object”. for example a coin. same technique, same primitive, plus alpha channel. check out the famous lion and wall texture being rendered.


from the distance function i can get a nice depth map of objects. and each object means doing a render target volley so i can compare the depth. here is a quick example of 2 object rendered. black means far from camera. notice the nice intersection between object.


next i create a simple deferred rendering by generating normal map. normal map generated from the depth field. also deferred rendering requires positions which also generated from the depth map. as you can see below, the 3 component of deferred rendering, the position is not being renderer. see the lower right square is the scene lit by a simple lighting calculation


the final image looks like this, well i drop the ambient lighting for more geometry exposure. as you can see artifact appear in some places. on the bottom middle part of the image, some sort of rippling appear. it is easily fix by increasing the color depth of the render texture. increasing render target texture from a8r8g8b8 to a32r32g32b32 sadly kill the performance. probably due to render target switching (volley).



i borrow some texture from these sites

steep parallax maping

cool indian temple texture


mecha+ rigging