Skip to content

Commit

Permalink
add switch on (single or all removal component) (UI & code)
Browse files Browse the repository at this point in the history
  • Loading branch information
NUZEROVI committed Nov 2, 2022
1 parent 7883b0d commit bd033cb
Show file tree
Hide file tree
Showing 32 changed files with 4,461 additions and 493 deletions.
67 changes: 50 additions & 17 deletions Assets/Debugging/ShaderDebugging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ namespace UnityVolumeRendering
{
public class ShaderDebugging : MonoBehaviour
{
public GameObject target;
public GameObject target, target_Mask;

private Material material;
private ComputeBuffer buffer;
public Vector4[] element;
private string label;
private Renderer render;
private Material material, material_Mask;
private ComputeBuffer buffer, buffer_Mask;
public Vector4[] element, element_Mask;
private string label, label_Mask;
private Renderer render, render_Mask;

MeshRenderer meshRenderer;
Material mat;
MeshRenderer meshRenderer, meshRenderer_Mask;
Material mat, mat_Mask;


void Load()
Expand All @@ -26,32 +26,64 @@ void Load()
}
buffer.SetData(element);

label = string.Empty;
render = target.GetComponent<Renderer>();
material = render.material;
label = string.Empty;
}

void Load_Mask()
{
buffer_Mask = new ComputeBuffer(10, 16, ComputeBufferType.Default);
element_Mask = new Vector4[10];
for (int i = 0; i < buffer_Mask.count; i++)
{
element_Mask[i] = new Vector4(0, 0, 0, 0);
}
buffer_Mask.SetData(element_Mask);

label_Mask = string.Empty;
}

void Start()
{
Load();
VolumeRenderedObject[] objects = FindObjectsOfType<VolumeRenderedObject>();

VolumeRenderedObject[] objects = FindObjectsOfType<VolumeRenderedObject>();
if (objects.Length == 1)
{
render = objects[0].GetComponent<Transform>().GetChild(0).GetComponent<Renderer>();
material = render.material;
Load();
meshRenderer = objects[0].meshRenderer;
mat = meshRenderer.material;
}

VolumeRenderedObject_Mask[] objects_Mask = FindObjectsOfType<VolumeRenderedObject_Mask>();
if (objects_Mask.Length == 1)
{
render_Mask = objects_Mask[0].GetComponent<Transform>().GetChild(0).GetComponent<Renderer>();
material_Mask = render_Mask.material;
Load_Mask();
meshRenderer_Mask = objects_Mask[0].meshRenderer;
mat_Mask = meshRenderer_Mask.material;
}
}

void Update()
{
Graphics.ClearRandomWriteTargets();
material.SetPass(0);
material_Mask.SetPass(0);

material.SetBuffer("buffer", buffer);
Graphics.SetRandomWriteTarget(1, buffer, false);
Graphics.SetRandomWriteTarget(1, buffer, false);

material_Mask.SetBuffer("buffer_Mask", buffer_Mask);
Graphics.SetRandomWriteTarget(2, buffer_Mask, false);

buffer.GetData(element);
buffer.GetData(element);
buffer_Mask.GetData(element_Mask);

label = (element != null && render.isVisible) ? element[0].ToString() : string.Empty;

label = (element != null && render.isVisible) ? element[0].ToString() : string.Empty;
label_Mask = (element_Mask != null && render_Mask.isVisible) ? element_Mask[0].ToString() : string.Empty;
}

void OnGUI()
Expand All @@ -64,7 +96,8 @@ void OnGUI()

void OnDestroy()
{
buffer.Dispose();
buffer.Dispose();
buffer_Mask.Dispose();
}
}
}
116 changes: 59 additions & 57 deletions Assets/Debugging/ShaderDebugging_Mask.cs
Original file line number Diff line number Diff line change
@@ -1,70 +1,72 @@
using UnityEngine;
//using UnityEngine;

namespace UnityVolumeRendering
{
public class ShaderDebugging_Mask : MonoBehaviour
{
public GameObject target_Mask;
//namespace UnityVolumeRendering
//{
// public class ShaderDebugging_Mask : MonoBehaviour
// {
// public GameObject target_Mask;

private Material material_Mask;
private ComputeBuffer buffer_Mask;
public Vector4[] element_Mask;
private string label_Mask;
private Renderer render_Mask;
// private Material material_Mask;
// private ComputeBuffer buffer_Mask;
// public Vector4[] element_Mask;
// private string label_Mask;
// private Renderer render_Mask;

MeshRenderer meshRenderer_Mask;
Material mat_Mask;
// MeshRenderer meshRenderer_Mask;
// Material mat_Mask;


void Load()
{
buffer_Mask = new ComputeBuffer(10, 16, ComputeBufferType.Default);
element_Mask = new Vector4[10];
for(int i=0; i < buffer_Mask.count; i++)
{
element_Mask[i] = new Vector4(0, 0, 0, 0);
}
buffer_Mask.SetData(element_Mask);
// void Load()
// {
// buffer_Mask = new ComputeBuffer(10, 16, ComputeBufferType.Default);
// element_Mask = new Vector4[10];
// for(int i=0; i < buffer_Mask.count; i++)
// {
// element_Mask[i] = new Vector4(0, 0, 0, 0);
// }
// buffer_Mask.SetData(element_Mask);

label_Mask = string.Empty;
render_Mask = target_Mask.GetComponent<Renderer>();
material_Mask = render_Mask.material;
}
// label_Mask = string.Empty;
// //render_Mask = target_Mask.GetComponent<Renderer>();

// }

void Start()
{
Load();
VolumeRenderedObject_Mask[] objects_Mask = FindObjectsOfType<VolumeRenderedObject_Mask>();
if (objects_Mask.Length == 1)
{
meshRenderer_Mask = objects_Mask[0].meshRenderer;
mat_Mask = meshRenderer_Mask.material;
}
}
// void Start()
// {
// VolumeRenderedObject_Mask[] objects_Mask = FindObjectsOfType<VolumeRenderedObject_Mask>();
// if (objects_Mask.Length == 1)
// {
// render_Mask = objects_Mask[0].GetComponent<Transform>().GetChild(0).GetComponent<Renderer>();
// material_Mask = render_Mask.material;
// Load();
// meshRenderer_Mask = objects_Mask[0].meshRenderer;
// mat_Mask = meshRenderer_Mask.material;
// }
// }

void Update()
{
Graphics.ClearRandomWriteTargets();
material_Mask.SetPass(0);
material_Mask.SetBuffer("buffer_Mask", buffer_Mask);
Graphics.SetRandomWriteTarget(2, buffer_Mask, false);
// void Update()
// {
// //Graphics.ClearRandomWriteTargets();
// material_Mask.SetPass(0);
// material_Mask.SetBuffer("buffer_Mask", buffer_Mask);
// Graphics.SetRandomWriteTarget(2, buffer_Mask, false);

buffer_Mask.GetData(element_Mask);
// buffer_Mask.GetData(element_Mask);

label_Mask = (element_Mask != null && render_Mask.isVisible) ? element_Mask[0].ToString() : string.Empty;
}
// label_Mask = (element_Mask != null && render_Mask.isVisible) ? element_Mask[0].ToString() : string.Empty;
// }

void OnGUI()
{
GUIStyle style = new GUIStyle();
// void OnGUI()
// {
// GUIStyle style = new GUIStyle();

GUI.color = Color.white;
style.fontSize = 32;
}
// GUI.color = Color.white;
// style.fontSize = 32;
// }

void OnDestroy()
{
buffer_Mask.Dispose();
}
}
}
// void OnDestroy()
// {
// buffer_Mask.Dispose();
// }
// }
//}
Loading

0 comments on commit bd033cb

Please sign in to comment.