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