Sign in to follow this  

Let's say 3 2D Textures and a TextureCube walk into a bar?

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

Well they don't actually walk in to a bar. However, sorry to disappoint but there's a small tiny issue. I have let's say 3 textures for now that are being set up in the rendering pipeline. They are 2D Textures and they are in a vector array.

unsigned int arraySize = TextureArrays.size(); //-- Obtain Vector Size.
devcon->PSSetShaderResources(0,arraySize ,&TextureArrays);

Great and dandy! However, I now have a TextureCube that I want to use for reflection purposes from the already existing cubemap. So, I grabbed the shader resource view from the cube map and bring it to the main rendering for the meshes. So, the three textures I was talking about : DIffuse, Normal, Specular. I want to add the Texture Cube to that. Would it go like this?

unsigned int arraySize = textureArray.size(); //-- Obtain three textures inside the vector.
devcontext->PSSetShaderResource(0,arraySize,&textureArray); //-- Diffuse, Normal, Specular.
if(cubemapShaderResourceView) ///-- Check to see if it's even loaded inside as ID3D11ShaderResourceView.
devcon->PSSetShaderResource(1,0,&cubemapShaderResourceView);


Or would it be just fine to be added inside the vector along with the Diffuse, Normal, Specular and whatnot. I was thinking because of how inside the shader the Diffuse, Normal, Specular are all Texture2D and the texturemap is TextureCube; so I didn't know how I should go about this...

 

I hope I kept it sweet and short and thanks for reading. Any feedback would be most appreciated.

Share this post


Link to post
Share on other sites

Since you're not setting textures, but instead shader resource views, it would be fine to add it as part of your array.  I assume you already create a shader resource view for all textures (2d and cube)?  If you did want to separate it then your second call isn't correct though.  The first parameter is the starting stage to set, the second is the number of resources, and the third is the array of resources.  In your second call you are setting 0 resources in the first stage.  It should really be more like this:

 

devcon->PSSetShaderResource(arraySize,1,&cubemapShaderResourceView);

 

This will set the next stage after the array, and set 1 resource.  Again though, as long as you create resources views for all textures, then you can set them all in the array and call PSSetShaderResource only once.

Share this post


Link to post
Share on other sites

Now, I understand what the second parameter of the whole PSSetShaderResources are. So, instance:

deviceContext->PSSetShaderResources(0,3,&myShaderResources); //-- Diffuse, Normal Speclar Mapping inside array. 

deviceContext->PSSetShaderResrouces(3,1,&myTextureCube); //-- TextureCube.

So, I think I'm understanding that the number of views are how many resources are inside that slot. So, in Slot 0 there would 3 number shader views. In the 3 slot there is only 1 number shader view...Am I understanding this correctly?

Share this post


Link to post
Share on other sites

This topic is 1379 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this