-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Hey I am a new learner. Appreciate your excellent work for the package.
I am wondering how we can get the SDF value by sampling the sdf texture?
To be more specific, now we have SDFTexture.sdf(RenderTexture) and SDFTexture. worldToSDFTexCoords(Matrix4*4),
Below is what I thought:
// Transform the vertex using the provided matrix
var transformedVertex = m_worldToSDFTexCoords * new Vector4(vertex.x, vertex.y, vertex.z, 1.0f);
var textureCoords = new Vector3(transformedVertex.x, transformedVertex.y, transformedVertex.z);
// Ensure the texture coordinates are within the texture bounds
textureCoords.x = Mathf.Clamp01(textureCoords.x);
textureCoords.y = Mathf.Clamp01(textureCoords.y);
textureCoords.z = Mathf.Clamp01(textureCoords.z);
// How to read the SDF value from the texture at the specified texture coordinates? Like below?
var sdfValue = m_sdf.GetPixel(textureCoords.x, textureCoords.y, textureCoords.z);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels