Git Product home page Git Product logo

minimalcompute's Introduction

Minimal Compute Shader Examples

Minimal test scenes contains compute shaders, compute buffers etc Playing with the transport between CPU <-> GPU

Unity version : 2022.2.4f1+, contains both BuiltinRP and Universal Render Pipeline (URP) scenes
See branches for older Unity versions
Tested with : Win DX11

Scene Image Description
๐Ÿ”ท 01_Compute_Texture ๐Ÿ”ท
01_1_Basic The most basic one, edit texture with compute shader, shader takes the texture for rendering
01_2_FallingSand Example of using compute to animate texture pixels
01_3_Fluid_2D GPU Fluid. Ref to Scrawk/GPU-GEMS-2D-Fluid-Simulation
01_4_Fluid_3D A 3D version based on above GPU Fluid
๐Ÿ”ท 02_StructuredBuffer ๐Ÿ”ท
02_1_StructuredBufferNoCompute ComputeBuffer can also be used in Shader, not just ComputeShader. The folder contains implementation of unlit vert-frag, surface shader and unlit URP shader
02_2_ComputePaintTexture Paint the texture by sending object positions to compute shader with StructuredBuffer
02_3_RotatingCircles Similar to above, just another playground scene
02_4_ComputePaintTexture_DFT Similar to above but drawing with Epicycles using Discrete Fourier Transform. Ref to The Coding Train's youtube video
02_5_ComputeParticlesDirect GPU Particle, drawing fixed no. of particles
02_6_ComputeSketch Draw quads on the screen with color filled by compute shader
๐Ÿ”ท 03_GPU_to_CPU ๐Ÿ”ท
03_1_StructuredBufferWithCompute Another basic one, use compute to calculate some data and send back to CPU
03_2_AsyncGPUReadback Similar to StructuredBufferWithCompute, but use AsyncGPUReadback to get array data back to CPU
03_3_AsyncGPUReadbackTex Result is same as ComputeUAVTexture, but this scene uses AsyncGPUReadback to get texture data back to CPU, and CPU send the texture data to Shader for rendering
03_4_AsyncGPUReadbackMesh Update mesh vertices with compute + AsyncGPUReadback to get the vertex data back to CPU for physics
03_5_AsyncGPUReadbackMesh_NewMeshAPI Same as above but using the new Mesh API
๐Ÿ”ท 04_Indirect ๐Ÿ”ท
04_1_IndirectCompute Simple indirect compute (indirect dispatch) and CopyCount
04_2_ComputeParticlesIndirect GPU Particle, drawing dynamic no. of particles, no need to read back to CPU!
04_3_ComputeParticlesIndirect_VFX Implementation of above scene with VFX graph
04_4_IndirectReflectedStar Draw stars on the screen only if the pixels are bright enough
๐Ÿ”ท 05_Shader_to_CPU ๐Ÿ”ท
05_1_UAVInShader Read some data back to CPU from fragment shader
๐Ÿ”ท 06_Compute_Mesh ๐Ÿ”ท
06_1_ComputeVertex Replace vertex buffer with StructuredBuffer and drive vertex displacement by compute
06_2_ComputeVertexLit A usecase of above, with different shader passes share the same vertex data
06_3_SkinnedMeshBuffer_SameMesh Blend the vertex data from 2 SkinnedMeshRenderer vertex buffer and render it with MeshRenderer
06_4_SkinnedMeshBuffer_DiffMesh Similar to above but blending 2 different SkinnedMeshes. The blended triangles are drawn with DrawMeshInstancedIndirect()
06_5_VFXGraphMeshDeform Using VFX Graph to deforming mesh (particle as vertex)

Disclaimer: The stuff here might not be the best practice / optimized :'(. But at least they works. Play them for fun.

minimalcompute's People

Contributors

cinight avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.