private void DoRender() { Texture2D texture = new Texture2D((int)(_size.x * _pixelPerUnit), (int)(_size.y * _pixelPerUnit), TextureFormat.RGBA32, false, true); texture.wrapMode = TextureWrapMode.Clamp; Color[] color = new Color[texture.width * texture.height]; for (int x = 0; x < texture.width; x++) { for (int y = 0; y < texture.height; y++) { Vector3 worldPosition = transform.TransformPoint(GetLocalPosition(x, y, texture.width, texture.height)); float intensity = LightSampling.GetIntensity(worldPosition); int index = y * texture.width + x; color[index] = new Color(intensity, intensity, intensity, 1); } } texture.SetPixels(color); texture.Apply(); _spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), _pixelPerUnit); }
public void SetLightSampling(LightSampling sampling) { PrevalidateMaterial(); _currentMaterial = _currentMaterial.UpdateLightSampling(sampling); }