// -------------------------------------------------------------------- protected virtual void UpdateMaterialParameters() { // Even though the material property block stuff isn't working for instancing we should still use it to avoid creating a new material for every object // It might break batching and cause a bunch of problems but there doesn't seem to be a better alternative, at least that I know of right now // Once instancing is 'fixed' this should allow it to render all objects with the same sprite together in one call so bit of a future investment L2DLRenderer.GetPropertyBlock(WorkingMaterialPropertyBlock); WorkingMaterialPropertyBlock.SetFloat("_Emission", Emission); WorkingMaterialPropertyBlock.SetFloat("_Occlusion", Occlusion); WorkingMaterialPropertyBlock.SetFloat("_Reflectance", Reflectance); WorkingMaterialPropertyBlock.SetFloat("_LightBleed", LightBleed); if (LightingTexture) { WorkingMaterialPropertyBlock.SetTexture("_Lighting", LightingTexture); } if (lightingFrame != null) { WorkingMaterialPropertyBlock.SetTexture("_Lighting", lightingFrame.texture); Vector2 textureSize = new Vector2(lightingFrame.texture.width, lightingFrame.texture.height); WorkingMaterialPropertyBlock.SetVector("_LightingStartUV", lightingFrame.rect.min / textureSize); WorkingMaterialPropertyBlock.SetVector("_LightingEndUV", lightingFrame.rect.max / textureSize); } else { WorkingMaterialPropertyBlock.SetVector("_LightingStartUV", new Vector2(0f, 0f)); WorkingMaterialPropertyBlock.SetVector("_LightingEndUV", new Vector2(1f, 1f)); } UpdateMaterialPropertyBlockParameters(WorkingMaterialPropertyBlock); l2DLRenderer.SetPropertyBlock(WorkingMaterialPropertyBlock); }
protected override void UpdateMaterialParameters() { base.UpdateMaterialParameters(); L2DLRenderer.GetPropertyBlock(WorkingMaterialPropertyBlock, 1); WorkingMaterialPropertyBlock.SetFloat("_Emission", EdgeEmissivePower); WorkingMaterialPropertyBlock.SetFloat("_Occlusion", EdgeOcclusion); WorkingMaterialPropertyBlock.SetFloat("_Reflectance", EdgeReflectance); WorkingMaterialPropertyBlock.SetFloat("_LightBleed", EdgeLightBleed); if (EdgeLightingTexture) { WorkingMaterialPropertyBlock.SetTexture("_Lighting", EdgeLightingTexture); } UpdateMaterialPropertyBlockParameters(WorkingMaterialPropertyBlock); l2DLRenderer.SetPropertyBlock(WorkingMaterialPropertyBlock, 1); }