1
1
using System . Collections ;
2
2
using System . Collections . Generic ;
3
3
using UnityEngine ;
4
- using UnityEngine . Experimental . VFX ;
4
+ using UnityEngine . VFX ;
5
5
6
6
[ ExecuteAlways ]
7
7
public class MeshToSDF : MonoBehaviour
@@ -38,15 +38,14 @@ public class MeshToSDF : MonoBehaviour
38
38
public int sdfResolution = 64 ;
39
39
40
40
[ Tooltip ( "Offset the mesh before voxelization" ) ]
41
- public Vector3 offset ;
41
+ public Vector3 offset = new Vector3 ( 0.5f , 0.5f , 0.5f ) ;
42
42
[ Tooltip ( "Scale the mesh before voxelization" ) ]
43
- public float scaleBy = 1.0f ;
43
+ public Vector3 scaleBy = Vector3 . one ;
44
44
[ Tooltip ( "Number of points to sample on each triangle when voxeling" ) ]
45
45
public uint samplesPerTriangle = 10 ;
46
46
[ Tooltip ( "Thicken the signed distance field by this amount" ) ]
47
47
public float postProcessThickness = 0.01f ;
48
48
49
-
50
49
Mesh prevMesh ;
51
50
52
51
// kernel ids
@@ -178,7 +177,7 @@ private Vector3 Div(Vector3 a, Vector3 b) {
178
177
}
179
178
180
179
public RenderTexture MeshToVoxel ( int voxelResolution , Mesh mesh ,
181
- Vector3 offset , float scaleMeshBy , uint numSamplesPerTriangle ,
180
+ Vector3 offset , Vector3 scaleMeshBy , uint numSamplesPerTriangle ,
182
181
RenderTexture voxels = null ) {
183
182
var indicies = mesh . triangles ;
184
183
var numIdxes = indicies . Length ;
@@ -201,7 +200,7 @@ public RenderTexture MeshToVoxel(int voxelResolution, Mesh mesh,
201
200
MtVImplementation . SetInt ( "tris" , numTris ) ;
202
201
MtVImplementation . SetFloats ( "offset" , offset . x , offset . y , offset . z ) ;
203
202
MtVImplementation . SetInt ( "numSamples" , ( int ) numSamplesPerTriangle ) ;
204
- MtVImplementation . SetFloat ( "scale ", scaleMeshBy ) ;
203
+ MtVImplementation . SetVector ( "scale3d ", scaleMeshBy ) ;
205
204
MtVImplementation . SetInt ( "voxelSide" , ( int ) voxelResolution ) ;
206
205
207
206
if ( voxels == null ) {
0 commit comments