Fabio Policarpo - Relief Mapping with Correct Silhouettes

While someone saw my video test on youtube and ask me to share the code, I believe, this forum is always the best place to share.

Not all feature are implemented, like depth correction, shadow map…etc (since, I still don’t understand completely :p)

Antonio Hui

Tips: For the relief texture, please turn off the “Generate Mip Maps” option of the Texture Importer.

210969–7762–$relief_correct_silhouettes_181.shader (4.9 KB)
210969–7763–$texture_199.zip (377 KB)

1 Like

Anyone interested on this too ??

[ paper demo from original creator ]
http://www.fabio.policarpo.nom.br/Demos.html

Fabio’s shader always good to learn, full of wisdom and challenge :slight_smile:

In fact, porting his shader to unity is quite easy, almost 95% unchanged from the original code. However, I still don’t understand how to make the multi-layered normal maps and the workflow to prepare the textures :stuck_out_tongue:

Tips: To get the best result, when import the relief and normal maps, please disable the “Mip Maps” and set the “Filter Mode” to “Point” on Texture Importer.

Antonio Hui

(ps. I didn’t port the shadow map part yet :stuck_out_tongue: )

210990–7769–$quad_depth_relief_mapping_254.shader (6.14 KB)

1 Like

Surrender all your shaders and no one will get hurt.

Yes, this looks awesome. Even without source, I’m just interested in the approach. I’m not familiar with relief mapping beyond basic parallax stuff.

Ha, ha! :lol: Very nice shaders, I’ll have to try this.

Edit: I just gave this a spin and love it. Nice! :slight_smile:

Great shaders , beautiful

Norby :slight_smile:

I understand the first shader and think it’s awesome - this is what all games are going to be using soon, no doubt. Can you provide some insight as to what’s going on in the second, though, please? It looks great, regardless.

Happy to know that everyone love these shaders. I will upload another unity port of Fabio’s shader, “Relaxed Cone Stepping for Relief Mapping”, that is from chapter 18 of GPUGems 3 of Nvidia’s book.
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch18.html

hi Jessy, this is the right paper to start with. In fact, I don’t understand too much yet. I still study from it :slight_smile:
http://fabio.policarpo.nom.br/docs/Multilayer_ReliefMapping_I3D2006.pdf

Also, chapter 5 of this book Advanced game development with programmable graphics hardware By Alan H. Watt, Fabio Policarpo tell the whole story too. Enjoy !

Antonio Hui

1 Like

Thanks for the extra references! Can you please save this thread by truncating that URL, though?

[url=http://example.com]Site Name[/url]

Impresive shaders, thank you so much. I guess the special textures for the second one can currently only be built with a 3DMax plugin?

A technique to improve the small details of the original relief mapping shader…

Comparison between the “relaxed cone stepping” (left) and original relief mapping (right) algorithm.
Those are using the same amount of intersect searching value, 15(linear), 5(binary).

You may enable one of them to see the difference :slight_smile:

//#pragma fragment pixel_shader_normal
//#pragma fragment pixel_shader_relief
//#pragma fragment pixel_shader_quadcone
#pragma fragment pixel_shader_relaxedcone

Also, comment in/out the border clamp define to en/disable the border clamp.
(small improvement, big impact ! the silhouettes is back :))

#define BORDER_CLAMP
	// border clamp
	float alpha=1;	
#ifdef BORDER_CLAMP
	if (texcoord.x<0)alpha=0;
	if (texcoord.y<0) alpha=0;
	if (texcoord.x>tile) alpha=0;
	if (texcoord.y>tile) alpha=0;
#endif

I try to kept the code as close to original paper as possible. Hope that it is easy for everyone to study (include myself :p)

The next step is find out the way to prepare the texture. If anyone knew the solution please tell us. many thanks :slight_smile:

Antonio Hui

ps. for more detail on the algorithm, please read the following. have fun !
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch18.html

211354–7784–$texture_863.zip (1.36 MB)
211354–7785–$relaxed_cone_relief_mapping_112.shader (7.87 KB)

Hi Antonio

This looks fantastic.
would it be possible to use a sequence of pictures in the slots
to create wave animation ?
good work

Norby

This is a fascinating thread, the shaders are wonderful, but how does one go about making some of these relief maps? What tools are out there to produce them?

Hi Norby,

The answer is YES ! (of course, not by me :p)

Fabio Policarpo have a better idea ! I knew he wrote a new paper (maybe on SIGGRAPH 2008) talking about how to animate the relief and normal map within the fragment shader interactively. I saw his demo in youtube sometime ago. (but forgot the link :s)

Once I found the above paper and the sample code, for sure, I will port it to Unity ASAP too. Good Luck to myself :slight_smile:

Antonio Hui

Hi Antonio

This would be cool, i wish i could code :sweat_smile:
can you tell me what type of light can be used
because when i added some additional lights
there was no difference.

Norby

If you look at the shader settings, you can set up the light inside the shader. It would be a bit of work to get these shaders split into passes and compatible with Unity’s lighting pipeline.

thanks Daniel
for clarifying this.

norby

  1. In fact, learning Cg shader is not so hard, when you have a good teacher to start with. I started to learn Cg from this video few months ago.

http://unity3d.com/support/resources/unite-presentations/shader-programming-course

A big THANKS to Amir Ebrahimi and Aras Pranckevičius !

Antonio Hui

Awesome awesome stuff.

I couldn’t get relaxed_cone_relief_mapping.shader to work. And quite frankly, I didn’t really understand what to put in the available fields for the quad_depth_relief_mapping shader.

But just seeing the Relief_correct_silhouettes shader working was pretty amazing.

If anyone could set me straight on the stuff I didn’t get right I’d appreciate it.

Also, how are the Relief Maps created? I tried using some normal maps and they didn’t work.

Edit: Ahh… I see that you’re asking the same thing about making the maps

It is because, lack of height information. That is stored in the fourth channel - alpha. (red, green, blue channel for x,y and z component of the normal.)

Simply, Relief Map = Normal Map + Height Map :slight_smile:

Antonio Hui