Fabio’s shader always good to learn, full of wisdom and challenge
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
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.
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
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
//#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
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?
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
This would be cool, i wish i could code
can you tell me what type of light can be used
because when i added some additional lights
there was no difference.
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.
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.)