void phongShaderOverride::updateShader(
	MHWRender::MShaderInstance& shader,
	const MHWRender::MAttributeParameterMappingList& mappings)
{
	// Cache resolved name if found to avoid lookup on every update
	if (fResolvedSpecularColorName.length() == 0)
	{
		const MHWRender::MAttributeParameterMapping* mapping =
			mappings.findByParameterName("specularColor");
		if (mapping)
		{
			fResolvedSpecularColorName = mapping->resolvedParameterName();
		}
	}

	// Set parameter
	if (fResolvedSpecularColorName.length() > 0)
	{
		shader.setParameter(fResolvedSpecularColorName, fSpecularColor);
	}
}
void simpleNoiseShaderOverride::updateShader(
	MHWRender::MShaderInstance& shader,
	const MHWRender::MAttributeParameterMappingList& mappings)
{
	// Handle resolved name caching
	if (fResolvedNoiseMapName.length() == 0)
	{
		const MHWRender::MAttributeParameterMapping* mapping =
			mappings.findByParameterName("noiseLookupMap");
		if (mapping)
		{
			fResolvedNoiseMapName = mapping->resolvedParameterName();
		}
	}
	if (fResolvedNoiseSamplerName.length() == 0)
	{
		const MHWRender::MAttributeParameterMapping* mapping =
			mappings.findByParameterName("noiseLookupMapSampler");
		if (mapping)
		{
			fResolvedNoiseSamplerName = mapping->resolvedParameterName();
		}
	}

	// Set the parameters on the shader
	if (fResolvedNoiseMapName.length() > 0 &&
		fResolvedNoiseSamplerName.length() > 0)
	{
		// Set a point-clamp sampler to the shader
		if (!fNoiseSamplerState)
		{
			MHWRender::MSamplerStateDesc desc;
			desc.filter = MHWRender::MSamplerState::kMinMagMipPoint;
			desc.addressU = desc.addressV = desc.addressW =
				MHWRender::MSamplerState::kTexClamp;
			desc.minLOD = 0;
			desc.maxLOD = 0;
			fNoiseSamplerState =
				MHWRender::MStateManager::acquireSamplerState(desc);
		}
		if (fNoiseSamplerState)
		{
			shader.setParameter(fResolvedNoiseSamplerName, *fNoiseSamplerState);
		}

		// Generate the noise lookup table texture if necessary
		if (!fNoiseTexture)
		{
			MHWRender::MRenderer* renderer =
				MHWRender::MRenderer::theRenderer();
			MHWRender::MTextureManager* textureMgr =
				renderer ? renderer->getTextureManager() : NULL;
			if (textureMgr)
			{
				// First, search the texture cache to see if another instance of
				// this override has already generated the texture. We can reuse
				// it to save GPU memory since the noise data is constant.
				fNoiseTexture =
					textureMgr->findTexture(sNoiseLookupTextureName);

				// Not in cache, so we need to actually build the texture
				if (!fNoiseTexture)
				{
					// Get Maya's noise table
					const std::vector<float>& noiseData = GetMayaNoiseTable();

					// Create a 3D texture containing the data
					MHWRender::MTextureDescription desc;
					desc.setToDefault2DTexture();
					desc.fWidth = desc.fHeight = desc.fDepth =
						MRenderUtil::noiseTableCubeSide();
					desc.fFormat = MHWRender::kR32_FLOAT;
					desc.fTextureType = MHWRender::kVolumeTexture;
					desc.fMipmaps = 1;
					fNoiseTexture = textureMgr->acquireTexture(
						sNoiseLookupTextureName,
						desc,
						(const void*)&(noiseData[0]),
						false);
				}
			}
		}

		// Set the texture to the shader instance
		if (fNoiseTexture)
		{
			MHWRender::MTextureAssignment textureAssignment;
			textureAssignment.texture = fNoiseTexture;
			shader.setParameter(fResolvedNoiseMapName, textureAssignment);
		}
	}
}