Add color import
This commit is contained in:
@@ -119,7 +119,7 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1001 &594024951
|
||||
--- !u!1001 &49971200
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
@@ -131,6 +131,18 @@ PrefabInstance:
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
@@ -163,6 +175,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: splat_45000
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8980549144392899874, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@@ -438,4 +454,4 @@ SceneRoots:
|
||||
m_Roots:
|
||||
- {fileID: 1826889290}
|
||||
- {fileID: 1911516433}
|
||||
- {fileID: 594024951}
|
||||
- {fileID: 49971200}
|
||||
|
||||
@@ -71,9 +71,9 @@ namespace SplatVfx
|
||||
_cachedBuffers.sh = NewBuffer<float>(SplatCount * 45);
|
||||
|
||||
_cachedBuffers.position.SetData(PositionArray);
|
||||
// _cachedBuffers.scale.SetData(ScaleArray);
|
||||
_cachedBuffers.scale.SetData(ScaleArray);
|
||||
// _cachedBuffers.rotation.SetData(RotationArray);
|
||||
// _cachedBuffers.color.SetData(ColorArray);
|
||||
_cachedBuffers.color.SetData(ColorArray);
|
||||
_cachedBuffers.opacity.SetData(OpacityArray);
|
||||
// _cachedBuffers.sh.SetData(SHArray);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace SplatVfx
|
||||
set => _positionBufferProperty = value;
|
||||
}
|
||||
|
||||
// public string AxisBufferProperty
|
||||
// { get => (string)_axisBufferProperty;
|
||||
// set => _axisBufferProperty = value; }
|
||||
public string ScaleBufferProperty
|
||||
{ get => (string)_scaleBufferProperty;
|
||||
set => _scaleBufferProperty = value; }
|
||||
|
||||
// public string ColorBufferProperty
|
||||
// { get => (string)_colorBufferProperty;
|
||||
// set => _colorBufferProperty = value; }
|
||||
public string ColorBufferProperty
|
||||
{ get => (string)_colorBufferProperty;
|
||||
set => _colorBufferProperty = value; }
|
||||
|
||||
public string OpacityBufferProperty
|
||||
{ get => (string)_opacityBufferProperty;
|
||||
@@ -40,11 +40,11 @@ namespace SplatVfx
|
||||
[VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
ExposedProperty _positionBufferProperty = "PositionBuffer";
|
||||
|
||||
// [VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
// ExposedProperty _axisBufferProperty = "AxisBuffer";
|
||||
[VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
ExposedProperty _scaleBufferProperty = "ScaleBuffer";
|
||||
|
||||
// [VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
// ExposedProperty _colorBufferProperty = "ColorBuffer";
|
||||
[VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
ExposedProperty _colorBufferProperty = "ColorBuffer";
|
||||
|
||||
[VFXPropertyBinding("UnityEngine.GraphicsBuffer"), SerializeField]
|
||||
ExposedProperty _opacityBufferProperty = "OpacityBuffer";
|
||||
@@ -60,8 +60,8 @@ namespace SplatVfx
|
||||
{
|
||||
// component.SetUInt(_splatCountProperty, (uint)SplatData.SplatCount);
|
||||
component.SetGraphicsBuffer(_positionBufferProperty, SplatData.PositionBuffer);
|
||||
// component.SetGraphicsBuffer(_axisBufferProperty, SplatData.AxisBuffer);
|
||||
// component.SetGraphicsBuffer(_colorBufferProperty, SplatData.ColorBuffer);
|
||||
component.SetGraphicsBuffer(_scaleBufferProperty, SplatData.ScaleBuffer);
|
||||
component.SetGraphicsBuffer(_colorBufferProperty, SplatData.ColorBuffer);
|
||||
component.SetGraphicsBuffer(_opacityBufferProperty, SplatData.OpacityBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using Unity.VectorGraphics;
|
||||
using Unity.VisualScripting;
|
||||
using System.Collections;
|
||||
using Unity.Collections;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
|
||||
/*******************************************************************************
|
||||
TODO:
|
||||
@@ -37,13 +38,16 @@ namespace SplatVfx.Editor
|
||||
[ScriptedImporter(1, "ply"), BurstCompile]
|
||||
public sealed class SplatImporter : ScriptedImporter
|
||||
{
|
||||
const float SH_C0 = 0.28209479177387814f;
|
||||
|
||||
#region ScriptedImporter implementation
|
||||
|
||||
[BurstCompile]
|
||||
public override void OnImportAsset(AssetImportContext context)
|
||||
{
|
||||
var ply = ParsePLYFile(context.assetPath);
|
||||
var header_info = ParseHeader(ply.header);
|
||||
|
||||
|
||||
var data = ImportAsSplatData(header_info, ply.binaryData);
|
||||
data.name = Path.GetFileNameWithoutExtension(context.assetPath);
|
||||
context.AddObjectToAsset("data", data);
|
||||
@@ -59,6 +63,7 @@ namespace SplatVfx.Editor
|
||||
|
||||
const string DefaultVfxPath = "Assets/vfx-graph-gs/SplatVFX.vfx";
|
||||
|
||||
[BurstCompile]
|
||||
GameObject CreatePrefab(SplatData data)
|
||||
{
|
||||
var go = new GameObject();
|
||||
@@ -67,7 +72,7 @@ namespace SplatVfx.Editor
|
||||
|
||||
var binderBase = go.AddComponent<VFXPropertyBinder>();
|
||||
var binder = binderBase.AddPropertyBinder<VFXSplatDataBinder>();
|
||||
|
||||
|
||||
binder.SplatData = data;
|
||||
|
||||
return go;
|
||||
@@ -77,6 +82,7 @@ namespace SplatVfx.Editor
|
||||
|
||||
#region Reader implementation
|
||||
|
||||
[BurstCompile]
|
||||
(string header, byte[] binaryData) ParsePLYFile(string filePath)
|
||||
{
|
||||
using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
@@ -103,6 +109,7 @@ namespace SplatVfx.Editor
|
||||
return (headerBuilder.ToString(), binaryData);
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
(string format, int num_element, List<(string, string)> properties)
|
||||
ParseHeader(string header)
|
||||
{
|
||||
@@ -144,6 +151,7 @@ namespace SplatVfx.Editor
|
||||
return (format, num_element, properties);
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
SplatData ImportAsSplatData((string format, int num_element, List<(string, string)> properties) header_info, byte[] binaryData)
|
||||
{
|
||||
var splatData = ScriptableObject.CreateInstance<SplatData>();
|
||||
@@ -182,7 +190,54 @@ namespace SplatVfx.Editor
|
||||
break;
|
||||
|
||||
case "opacity":
|
||||
splatData.OpacityArray[i] = 255 / (1 + math.exp(-val));
|
||||
splatData.OpacityArray[i] = 1 / (1 + math.exp(-val));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (property.name.StartsWith("f_dc"))
|
||||
{
|
||||
switch (property.name[5])
|
||||
{
|
||||
case '0':
|
||||
splatData.ColorArray[i].r = 0.5f + val * SH_C0;
|
||||
|
||||
break;
|
||||
|
||||
case '1':
|
||||
splatData.ColorArray[i].g = 0.5f + val * SH_C0;
|
||||
|
||||
break;
|
||||
|
||||
case '2':
|
||||
splatData.ColorArray[i].b = 0.5f + val * SH_C0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else if (property.name.StartsWith("scale"))
|
||||
{
|
||||
switch (property.name[6])
|
||||
{
|
||||
case '0':
|
||||
splatData.ScaleArray[i].x = val;
|
||||
Debug.Log(splatData.ScaleArray[i].x);
|
||||
|
||||
break;
|
||||
|
||||
case '1':
|
||||
splatData.ScaleArray[i].y = val;
|
||||
|
||||
break;
|
||||
|
||||
case '2':
|
||||
splatData.ScaleArray[i].z = val;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
+2384
-350
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user