-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
2,220 additions
and
204 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma kernel CSMain | ||
#include "voxels.hlsl" | ||
#include "Library\PackageCache\[email protected]/Shader/ClassicNoise3D.hlsl" | ||
|
||
RWStructuredBuffer<int> uVoxels; | ||
|
||
float3 uPosition = float3(0, 0, 0); | ||
float uFrequency = 0.1f; | ||
float uAmplitude = 0.5f; | ||
|
||
[numthreads(8, 8, 8)] | ||
void CSMain (uint3 dispatchID : SV_DispatchThreadID) | ||
{ | ||
const uint globalVoxelIndex = to1D(dispatchID); | ||
|
||
int3 coord = int3(dispatchID); | ||
float3 position = float3(coord) + uPosition; | ||
|
||
float noise = ClassicNoise(position * uFrequency) * uAmplitude; | ||
|
||
if (noise > 0) | ||
{ | ||
uVoxels[globalVoxelIndex] = 1; | ||
} else | ||
{ | ||
uVoxels[globalVoxelIndex] = 0; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#define CHUNK_SIZE 80 | ||
|
||
struct Vertex { | ||
float3 position; | ||
float2 texcoord; | ||
float3 normal; | ||
}; | ||
|
||
struct GeometryData { | ||
uint vertexCount; | ||
uint indexCount; | ||
}; | ||
|
||
struct ChunkFeedback { | ||
uint vertexOffset; | ||
uint vertexCount; | ||
uint indexOffset; | ||
uint indexCount; | ||
}; | ||
|
||
uint to1D(uint3 pos) { | ||
return pos.x + CHUNK_SIZE * (pos.y + CHUNK_SIZE * pos.z); | ||
} | ||
|
||
int to1D(int3 pos) { | ||
return pos.x + CHUNK_SIZE * (pos.y + CHUNK_SIZE * pos.z); | ||
} | ||
|
||
uint3 to3D(uint idx) { | ||
uint x = idx % CHUNK_SIZE; | ||
uint y = (idx / CHUNK_SIZE) % CHUNK_SIZE; | ||
uint z = idx / (CHUNK_SIZE * CHUNK_SIZE); | ||
|
||
return uint3(x, y, z); | ||
} |
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
File renamed without changes.
Oops, something went wrong.