SAMPLERCUBE(sampler_InputTex);
float _FaceIndex;
float _LoD;
struct Attributes
{
float4 frag (Varyings input) : SV_Target
return SAMPLE_TEXTURECUBE(_InputTex, sampler_InputTex, input.texcoord);
return SAMPLE_TEXTURECUBE_LOD(_InputTex, sampler_InputTex, input.texcoord, _LoD);
}
ENDHLSL
public class ReflectionProbeCache
internal static readonly int s_InputTexID = Shader.PropertyToID("_InputTex");
internal static readonly int s_LoDID = Shader.PropertyToID("_LoD");
internal static readonly int s_FaceIndexID = Shader.PropertyToID("_FaceIndex");
enum ProbeFilteringState
Convolving,
// We can't use Graphics.ConvertTexture here because it does not work with a RenderTexture as destination.
void ConvertTexture(CommandBuffer cmd, Texture input, RenderTexture target)
m_ConvertTextureMPB.SetTexture("_InputTex", input);
m_ConvertTextureMPB.SetTexture(s_InputTexID, input);
m_ConvertTextureMPB.SetFloat(s_LoDID, 0.0f); // We want to convert mip 0 to whatever the size of the destination cache is.
m_ConvertTextureMPB.SetFloat("_FaceIndex", (float)f);
m_ConvertTextureMPB.SetFloat(s_FaceIndexID, (float)f);
CoreUtils.SetRenderTarget(cmd, target, ClearFlag.None, Color.black, 0, (CubemapFace)f);
CoreUtils.DrawFullScreen(cmd, m_ConvertTextureMaterial, m_ConvertTextureMPB);