textures initialization moved to paint manager

This commit is contained in:
doJester13 2021-03-07 00:38:18 +01:00
parent bef13dacfe
commit da5d9c79d4
2 changed files with 17 additions and 8 deletions

View File

@ -19,13 +19,28 @@ public class PaintManager : Singleton<PaintManager>{
CommandBuffer command;
void Start(){
public override void Awake(){
base.Awake();
paintMaterial = new Material(texturePaint);
extendMaterial = new Material(extendIslands);
command = new CommandBuffer();
command.name = "CommmandBuffer - " + gameObject.name;
}
public void initTextures(Paintable paintable){
RenderTexture mask = paintable.getMask();
RenderTexture extend = paintable.getExtend();
RenderTexture support = paintable.getSupport();
command.SetRenderTarget(mask);
command.SetRenderTarget(extend);
command.SetRenderTarget(support);
Graphics.ExecuteCommandBuffer(command);
command.Clear();
}
public void paint(Paintable paintable, Vector3 pos, float radius = 1f, float hardness = .5f, float strength = .5f, Color? color = null){
RenderTexture mask = paintable.getMask();

View File

@ -1,5 +1,4 @@
using UnityEngine;
using UnityEngine.Rendering;
public class Paintable : MonoBehaviour {
const int TEXTURE_SIZE = 1024;
@ -29,12 +28,7 @@ public class Paintable : MonoBehaviour {
rend = GetComponent<Renderer>();
rend.material.SetTexture(maskTextureID, extendIslandsRenderTexture);
CommandBuffer command = new CommandBuffer();
command.name = "CommandBuffer - " + gameObject.name;
command.SetRenderTarget(maskRenderTexture);
command.SetRenderTarget(extendIslandsRenderTexture);
command.SetRenderTarget(supportTexture);
Graphics.ExecuteCommandBuffer(command);
PaintManager.instance.initTextures(this);
}
void OnDisable(){