Hi,
I’m implementing a parallax-occlusion shader. I want to achieve adaptive per-pixel LOD as in here:
The idea was described by Tatarchuk at GDC06: http://www.ati.com/developer/gdc/2006/GDC06-Tatarchuk-Parallax_Occlusion_Mapping.pdf
It involves the following steps:
- Compute the current mip map level
- For furthest LOD levels, render using normal mapping (threshold level)
- As the surface approaches the viewer, increase the sampling rate as a function of the current mip map level
- In transition region between the threshold LOD level, blend between the normal mapping and the full parallax occlusion mapping
Here’s a pseudocode of what I’m using in my CG frag shader:
...
fixed4 frag (v2f i) : COLOR {
fixed lodLevel = GetLodLevel( _uv );
if (lodLevel < 1.0) {
//...compute POM...
} else {
//...use normal maps instead...
}
}
However this terrifically slows down my shader instead of optimizing it. And also the main branch never executes. Only the “else” branch is executing. Am I not getting something here? Looks like both branches are executing at the same time.
Is it possible to achieve adaptive LOD withoug dynamic branching?
What implementation Tatarchuk speaks about in that paper? Is it possible with unity/current hardware?
Thanks!