You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

// DFVolume - Distance field volume generator for Unity
// https://github.com/keijiro/DFVolume
using System.Collections.Generic;
using UnityEngine;
namespace DFVolume
{
public class VolumeData : ScriptableObject
{
#region Exposed attributes
[SerializeField] Texture3D _texture;
public Texture3D texture {
get { return _texture; }
}
List<Vector4> _data;
public List<Vector4> data
{
get { return _data; }
}
#endregion
#if UNITY_EDITOR
#region Editor functions
public void Initialize(VolumeSampler sampler)
{
var bmp = sampler.GenerateBitmap();
var dim = sampler.resolution;
_texture = new Texture3D(dim, dim, dim, TextureFormat.RGBAHalf, true);
_texture.name = "Distance Field Texture";
_texture.filterMode = FilterMode.Bilinear;
_texture.wrapMode = TextureWrapMode.Clamp;
_texture.SetPixels(bmp);
_texture.Apply();
_data = new List<Vector4>();
foreach (var c in bmp)
_data.Add(new Vector4(c.r, c.g, c.b, c.a));
}
#endregion
#endif
}
}