Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
artnas committed Apr 9, 2023
0 parents commit 04bdaf6
Show file tree
Hide file tree
Showing 81 changed files with 8,399 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# This .gitignore file should be placed at the root of your Unity project directory

/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uild_IL2CPP/
/[Bb]uilds/
/[Ll]ogs/
/[Ss]creenshots/
/[Rr]ecordings/

# Never ignore Asset meta data
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# TextMesh Pro files
[Aa]ssets/TextMesh*Pro/

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

Build*.zip

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

Tiled*Assets


# Crashlytics generated file
crashlytics-build.properties
/.idea/.idea.Punch/.idea/statistic.xml
/buildversion.txt

# Common IntelliJ Platform excludes

# User specific
**/.idea/**/workspace.xml
indexLayout.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml
/Assets/Deform/EditorResources/DeformSettings.asset
Assets/Plugins/Sirenix/Demos/Sample - RPG Editor.unitypackage.meta
Assets/Plugins/Sirenix/Demos/Editor Windows.unitypackage.meta
Assets/Plugins/Sirenix/Demos/Custom Drawers.unitypackage.meta
Assets/Plugins/Sirenix/Demos/Custom Attribute Processors.unitypackage.meta
Assets/Imported/AmplifyImpostors/Plugins/EditorResources/RenderPipelinePackages/ImpostorsURP.unitypackage.meta
Assets/Imported/AmplifyImpostors/Plugins/EditorResources/RenderPipelinePackages/ImpostorsLWRP.unitypackage.meta
Assets/Imported/AmplifyImpostors/Plugins/EditorResources/RenderPipelinePackages/ImpostorsHDRP.unitypackage.meta
Assets/Imported/AmplifyImpostors/Examples/SamplesURP.unitypackage.meta
Assets/Imported/AmplifyImpostors/Examples/SamplesLWRP.unitypackage.meta
Assets/Imported/AmplifyImpostors/Examples/SamplesHDRP.unitypackage.meta
UserSettings/Layouts/CurrentMaximizeLayout.dwlt
UserSettings/Layouts/default-2021.dwlt
ProjectSettings/RiderScriptEditorPersistedState.asset
13 changes: 13 additions & 0 deletions .idea/.idea.GPU Voxel Test/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.GPU Voxel Test/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.GPU Voxel Test/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Compute.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions Assets/Compute/feedback.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#version 460 core

#define CHUNK_SIZE 80

layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;

struct GeometryData {
uint vertexCount;
uint indexCount;
};

struct ChunkFeedback {
uint vertexOffset;
uint vertexCount;
uint indexOffset;
uint indexCount;
};

layout (std430, binding = 1) readonly buffer VoxelBuffer {
int data[];
} uVoxels;

layout (std430, binding = 6) buffer FeedbackBuffer {
GeometryData data;
} uFeedback;

layout (std430, binding = 7) writeonly buffer ChunkFeedbackBuffer {
ChunkFeedback data[];
} uChunkFeedback;

shared uint sVertexCount;
shared uint sIndexCount;

uint to1D(in uvec3 pos) {
return pos.x + CHUNK_SIZE * (pos.y + CHUNK_SIZE * pos.z);
}

int to1D(in ivec3 pos) {
return pos.x + CHUNK_SIZE * (pos.y + CHUNK_SIZE * pos.z);
}

uvec3 to3D(in uint idx) {
uint x = idx % CHUNK_SIZE;
uint y = (idx / CHUNK_SIZE) % CHUNK_SIZE;
uint z = idx / (CHUNK_SIZE * CHUNK_SIZE);

// uint z = idx / (CHUNK_SIZE * CHUNK_SIZE);
// idx -= (z * CHUNK_SIZE * CHUNK_SIZE);
// uint y = idx / CHUNK_SIZE;
// uint x = idx % CHUNK_SIZE;
return uvec3(x, y, z);
}

bool hasVoxel(in ivec3 coord) {
if (coord.x < 0 || coord.x >= CHUNK_SIZE ||
coord.y < 0 || coord.y >= CHUNK_SIZE ||
coord.z < 0 || coord.z >= CHUNK_SIZE) {
return false;
}

int idx = to1D(coord);
return uVoxels.data[idx] > 0;
}

void main() {
if (gl_LocalInvocationIndex == 0) {
sVertexCount = 0;
sIndexCount = 0;
}

barrier();

uint globalVoxelIndex = to1D(gl_GlobalInvocationID);

if (uVoxels.data[globalVoxelIndex] > 0) {
ivec3 coord = ivec3(gl_GlobalInvocationID);

uint vertexCount = 0;
uint indexCount = 0;

if (!hasVoxel(coord + ivec3(1, 0, 0))) {
vertexCount += 4;
indexCount += 6;
}

if (!hasVoxel(coord + ivec3(-1, 0, 0))) {
vertexCount += 4;
indexCount += 6;
}

if (!hasVoxel(coord + ivec3(0, 1, 0))) {
vertexCount += 4;
indexCount += 6;
}

if (!hasVoxel(coord + ivec3(0, -1, 0))) {
vertexCount += 4;
indexCount += 6;
}

if (!hasVoxel(coord + ivec3(0, 0, 1))) {
vertexCount += 4;
indexCount += 6;
}

if (!hasVoxel(coord + ivec3(0, 0, -1))) {
vertexCount += 4;
indexCount += 6;
}

atomicAdd(sVertexCount, vertexCount);
atomicAdd(sIndexCount, indexCount);
}

barrier();

if (gl_LocalInvocationIndex == 0) {
uint vertexOffset = atomicAdd(uFeedback.data.vertexCount, sVertexCount);
uint indexOffset = atomicAdd(uFeedback.data.indexCount, sIndexCount);

uint index = gl_WorkGroupID.x + 10 * (gl_WorkGroupID.y + 10 * gl_WorkGroupID.z);

uChunkFeedback.data[index].vertexOffset = vertexOffset;
uChunkFeedback.data[index].vertexCount = sVertexCount;
uChunkFeedback.data[index].indexOffset = indexOffset;
uChunkFeedback.data[index].indexCount = sIndexCount;
}
}
8 changes: 8 additions & 0 deletions Assets/Compute/feedback.comp.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 04bdaf6

Please sign in to comment.