Hi, I'm just checking if somebody has any insight on this, because I'm almost ready to report this as a bug.
I'm trying to change the emission on a couple of renderers/material instances through property blocks. This exact same method works great in other scripts and for other renderers, but for some reason it doesn't work here.
On one renderer, the difference in emission intensity is minimal, and on the other, I see no noticeable change at all. It's possible that both renderers are changing in intensity, but the difference is just too small to see on one of them. The result is the same whether emissiveIntensityOn_LightRenderer is 100 or 10 000.
The first picture shows my renderers and how they should look (I manually changed the emission intensity in the material just to show).
I'm using this code to execute the change. (Same code as in the image) Through debugging I've verified that I've got the right renderers and materials.
void ChangeLightRenderer(bool on)
{
foreach (MeshRenderer renderer in renderers)
{
if (renderer == null) continue;
Debug.Log("RENDERER IS " + renderer.gameObject.name);
renderer.GetPropertyBlock(block_LightRenderer, materialIndex);
if (renderer.materials.Length > 1) currentLightRendererColor = renderer.sharedMaterials[materialIndex].GetColor(emissiveColorID_LightRenderer);
else currentLightRendererColor = renderer.sharedMaterial.GetColor(emissiveColorID_LightRenderer);
if (on) hdr = currentLightRendererColor * emissiveIntensityOn_LightRenderer;
else hdr = currentLightRendererColor * emissiveIntensityOff_LightRenderer;
block_LightRenderer.SetVector(emissiveColorID_LightRenderer, new Vector4(hdr.r, hdr.g, hdr.b, hdr.a));
renderer.SetPropertyBlock(block_LightRenderer, materialIndex);
}
}
I just don't understand. Does anybody have any insight, or are MaterialPropertyBlocks just broken or something?