forked from samuelbigos/signed_distance_fields_in_unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup, add eikonal pass, update Unity.
- Loading branch information
1 parent
c2d64fc
commit 1c11960
Showing
45 changed files
with
1,247 additions
and
1,484 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
#pragma kernel SDFGen | ||
|
||
RWTexture3D<float> _sdfTex; | ||
uint _sdfTexSizeX; | ||
uint _sdfTexSizeY; | ||
uint _sdfTexSizeZ; | ||
float _sdfRadius; | ||
float _sdfDistMod; | ||
float _sphereRadius; | ||
#include "../Includes/SDF.cginc" | ||
|
||
float sdSphere(float3 pos, float radius) | ||
{ | ||
return length(pos) - radius; | ||
} | ||
RWTexture3D<float> _sdfTexOut; | ||
float _sphereRadius; | ||
|
||
[numthreads(8,8,8)] | ||
void SDFGen(uint3 id : SV_DispatchThreadID) | ||
{ | ||
float3 uv = float3(float(id.x), float(id.y), float(id.z)) + float3(0.5f, 0.5f, 0.5f); | ||
uv /= float3(float(_sdfTexSizeX), float(_sdfTexSizeY), float(_sdfTexSizeZ)); | ||
|
||
float3 centre; | ||
centre.x = 0.5f; | ||
centre.y = 0.5f; | ||
centre.z = 0.5f; | ||
float sphereRadius = _sphereRadius / (_sdfRadius * 2.0f); | ||
float dist = sdSphere(uv - centre, sphereRadius); | ||
|
||
dist = clamp(dist / _sdfDistMod, -1.0f, 1.0f); | ||
dist = dist * 0.5f + 0.5f; | ||
_sdfTex[id.xyz] = dist; | ||
float3 uv = kernelToUV(id); | ||
float3 pos = uvToWorld(uv); | ||
float current = sdSphere(pos, float3(0.0f, 0.0f, 0.0f), _sphereRadius); | ||
|
||
_sdfTexOut[id.xyz] = pack(current); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.