Setting mipmap level ?

Started by
5 comments, last by Hornsj3 12 years ago
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.
Advertisement
What is your method for recreating your textures in direct3d?
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.

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.
You can't do anything in DX11 without writing a shader. There's no fixed function.

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)

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.

This topic is closed to new replies.

Advertisement