Mip Mapping in the Domain Shader

Started by
2 comments, last by cephalo 10 years, 11 months ago

Ok, I want to do some displacement mapping in my domain shader, and some corresponding normal mapping in my pixel shader. I've never done displacement mapping before, but I would guess that it is very important to use the same mip mapping technique for both shader stages. In the pixel shader, mip-mapping happens sort of automatically so I don't really know exactly what's happening enough to emulate it in the domain shader.

I figure that for something this basic, there's probably a well established way to use the same mips for sampling in the domain and pixel shaders. Can anyone point me to an article somewhere with some code examples? I'm finding articles that say you should use mip-mapping in the domain shader, but nothing as to how to do that exactly.

Advertisement

It sounds like you just want to mip-map your normal map. Your normal map is just an image so I don't see why the default mip-mapping won't work automatically.

"default" mip-mapping only works in a pixel shader, since it's based on screen-space derivatives of your UV coordinates that are computed from neighboring pixels. For any other shader type you have to compute the mip level manually.

I would suggest reading through this article for some ideas regarding mip selection for displacement mapping.

Interesting. It was a misconception on my part that the mip levels would be the same on both shader stages, as the domain shader samples at a much lower frequency than the pixel shader.

This topic is closed to new replies.

Advertisement