Skip to main content
gamedev.net
🔒 Locked

Texture Type from effect

Started by treeway Sep 13, 2006 at 4:24 PM 1 replies 800+ views
Original Post
treeway
treeway
Hi in my effect class I used to say which type of texture a texture was by having an extra semantic i.e.

texture SkyCube_Tex : CubeMap
<
   string ResourceName = "Materials\\Skybox\\Skybox.dds";
>;

samplerCUBE Environment = sampler_state
{
   Texture = (SkyCube_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};


texture ColourMap_Tex : 2dTexture
<
   string ResourceName = "Materials\\Skybox\\sky.jpg";
>;

sampler2D baseMap = sampler_state
{
   Texture = (ColourMap_Tex);
   ADDRESSU = WRAP;
   ADDRESSV = WRAP;
   MINFILTER = LINEAR;
   MAGFILTER = LINEAR;
};
okay that worked but doesnt conform to the DXSAS and is fiddely since RenderMonkey doesnt export these semantics. Now i have found that I can get the type of texture from the Sampler e.g. the samplerCUBE and Sampler2D above. However when i read in the


while((tempHandle = pEffect->GetParameter(NULL,index)) != NULL)
		{
			if (pEffect->GetParameterDesc(tempHandle,&tempParamDesc) == S_OK)
			{
				if (tempParamDesc.Name != NULL)
				{
					if(tempParamDesc.Semantic != NULL)
					{
						Semantics.push_back(new Semantic(tempParamDesc.Name,tempParamDesc.Semantic,index));
						base->logError((char*)tempParamDesc.Name,tempParamDesc.Semantic);
					}

			
					if(tempParamDesc.Type == D3DXPT_SAMPLER3D)
					{
						sprintf(base->buffer,"Volume Texture \n Name %s \n Type %d",tempParamDesc.Name,tempParamDesc.Type);
						base->messageBox(base->hWnd,base->buffer);
					}
					else if(tempParamDesc.Type == D3DXPT_SAMPLERCUBE)
					{
											
						for(UINT i = 0; i < tempParamDesc.Elements; i ++)
						{
							D3DXPARAMETER_DESC desc;

							if((SASHandle = pEffect->GetParameterElement(tempHandle,i)) != NULL)
							{
								pEffect->GetParameterDesc( SASHandle, &desc );
								if(desc.Type == D3DXPT_STRING)
								{
									base->messageBox(base->hWnd,desc.Name,"BOOM");
								}
							}
						}

						sprintf(base->buffer,"CubeMap Texture \n Name %s \n Type %d",tempParamDesc.Name,tempParamDesc.Type);
						base->messageBox(base->hWnd,base->buffer);
					}
					else if(tempParamDesc.Type == D3DXPT_SAMPLER || tempParamDesc.Type == D3DXPT_SAMPLER2D || tempParamDesc.Type == D3DXPT_SAMPLER1D)
					{
						sprintf(base->buffer,"Normal Texture \n Name %s \n Type %d",tempParamDesc.Name,tempParamDesc.Type);
						base->messageBox(base->hWnd,base->buffer);
					}

//... etc

The only thing that binds the Sampler description to the texture perameter is the name of the texture i.e Texture = (ColourMap_Tex);. Therefore as i parce through my effect I want to fnid the sampler states and then load the texture specified and bind it to the texture name. However I cant seem to read the actual Texture name part of the sampler state. how do i find it?
circlesoft
circlesoft
Have you tried using the more descriptive texture data-types? Like sampler, there are the following:

texture1Dtexture2Dtexture3DtextureCUBE


This type should be reflected in the D3DXPARAMETER_TYPE of the description of the texture.
treeway
treeway
yeah that was prety much my question... i have the samplers as sampler3D samplerCUBE sampler1D etc, but how do i find the texture specified within the sampler since the sampler blocks seem to only read with a perameter name and no members.

edit:

sorry didnt read your post properly i didnt know textureCUBE etc. existed will look into it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.