Jump to content
  • Advertisement
Sign in to follow this  
vNeeki

OpenGL Setting mipmap level ?

This topic is 2455 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

Hi

I would like to port my opengl renderer to D3D in order to be able to switch between them at runtime , although i hit a wall when attempting to set the mipmap level!

In opengl you just pass in the mipmap level in glXXTexImage2D functions , but D3D texture loader seems to not allow such arguments.

..So i would like to ask if that's possible in D3D(10,11) and if not ...is there any workaround ?

Thanks for looking.

Share this post


Link to post
Share on other sites
Advertisement
Assuming you have created a texture2d object with mip maps in Directx11, you can create a shader resource view which contains one or all mip levels.

If you create it with all mip levels, you can choose the mip level you want to sample in your shader. Not to confuse you further, but the method is actually Load, not sample. Sample uses a sampler, which I don't think can select mip levels directly ( you have to create a shader resource view with a single mip if you want to sample ... I think). If you have a multiple mip-map level resource you can use load to get the value at (x,y,z) where z is the mip level.

Share this post


Link to post
Share on other sites

Assuming you have created a texture2d object with mip maps in Directx11, you can create a shader resource view which contains one or all mip levels.

If you create it with all mip levels, you can choose the mip level you want to sample in your shader. Not to confuse you further, but the method is actually Load, not sample. Sample uses a sampler, which I don't think can select mip levels directly ( you have to create a shader resource view with a single mip if you want to sample ... I think). If you have a multiple mip-map level resource you can use load to get the value at (x,y,z) where z is the mip level.


Waaah so its impossible to avoid writing shaders ohmy.png
This is a no-go for me then.I can't mess my source base just to support directx rendering mellow.png

@Slig Commando
That's the problem , i haven't displayed anything on screen yet since i wasn't able to figure out which was the proper method for loading a mipmapped texture.

Share this post


Link to post
Share on other sites

If you create it with all mip levels, you can choose the mip level you want to sample in your shader. Not to confuse you further, but the method is actually Load, not sample. Sample uses a sampler, which I don't think can select mip levels directly ( you have to create a shader resource view with a single mip if you want to sample ... I think). If you have a multiple mip-map level resource you can use load to get the value at (x,y,z) where z is the mip level.


You can use SampleLevel if you want to explicitly set a mip level (or you can pick a value in between two mip levels and filter between them)

Share this post


Link to post
Share on other sites

You can use SampleLevel if you want to explicitly set a mip level (or you can pick a value in between two mip levels and filter between them)


Oh Nice.

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!