Jump to content
  • Advertisement
Sign in to follow this  
nadine_wan

How to compute LOD in pixel shader?

This topic is 5402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my program, I need to compute the mipmap level for each vertex or each fragment manually. Is there any feasible way to compute it in vertex or pixel shader? The sample codes from NVidia give the following method, HPosition = mul(matModelViewProj, Obj.Position); LOD = (HPosition.z/HPosition.w)*MaxMipmapLevel. The resulting LOD ranges from 2.7~4.3, though I define mipmaps from Level 0 to level 6, given a 256 base texture. I think LOD should have values from 0~6 rather than 2.7~4.3. Do I miss something in this process? Does anyone know another better approximation method to compute LOD? And I wonder where such computation takes place, in vertex shader or in pixel shader? Thanks a lot! Nadine

Share this post


Link to post
Share on other sites
Advertisement
Quote:

And I wonder where such computation takes place, in vertex shader or in pixel shader?


Depends on what you want to do. Just bear in mind that the LOD level may differ in between 2 vertices, so I guess you may want to keep it on the pixel shader. It does depend on what you want to do though.

Quote:

Does anyone know another better approximation method to compute LOD?


I suppose you could manually create your LODS such that the alpha channel of the texture represents the LOD level (ie. alpha=0 on your first mipmap level, alpha=1 on your second etc..) assuming you don't need it already. Then just simply read your alpha value and obtain your LOD level. It's a bit of a hack, but I guess it could work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!