From 58501f44cb9a590b0000eb8cdbf175ce4ae355f5 Mon Sep 17 00:00:00 2001 From: Stedd Date: Sun, 8 Oct 2023 00:02:17 +0200 Subject: [PATCH] Added ComputeShader and ComputeController --- .idea/.idea.ComputeShader/.idea/.gitignore | 13 +++++++++++++ .../.idea.ComputeShader/.idea/indexLayout.xml | 8 ++++++++ .idea/.idea.ComputeShader/.idea/vcs.xml | 6 ++++++ Assets/Scripts.meta | 8 ++++++++ Assets/Scripts/ComputeController.cs | 18 ++++++++++++++++++ Assets/Scripts/ComputeController.cs.meta | 11 +++++++++++ Assets/Shaders.meta | 8 ++++++++ Assets/Shaders/ColorInverter.compute | 14 ++++++++++++++ Assets/Shaders/ColorInverter.compute.meta | 7 +++++++ 9 files changed, 93 insertions(+) create mode 100644 .idea/.idea.ComputeShader/.idea/.gitignore create mode 100644 .idea/.idea.ComputeShader/.idea/indexLayout.xml create mode 100644 .idea/.idea.ComputeShader/.idea/vcs.xml create mode 100644 Assets/Scripts.meta create mode 100644 Assets/Scripts/ComputeController.cs create mode 100644 Assets/Scripts/ComputeController.cs.meta create mode 100644 Assets/Shaders.meta create mode 100644 Assets/Shaders/ColorInverter.compute create mode 100644 Assets/Shaders/ColorInverter.compute.meta diff --git a/.idea/.idea.ComputeShader/.idea/.gitignore b/.idea/.idea.ComputeShader/.idea/.gitignore new file mode 100644 index 0000000..f06ff23 --- /dev/null +++ b/.idea/.idea.ComputeShader/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/.idea.ComputeShader.iml +/projectSettingsUpdater.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.ComputeShader/.idea/indexLayout.xml b/.idea/.idea.ComputeShader/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.ComputeShader/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.ComputeShader/.idea/vcs.xml b/.idea/.idea.ComputeShader/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.ComputeShader/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta new file mode 100644 index 0000000..0fee55e --- /dev/null +++ b/Assets/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8a6217063b7ebd046b2c4e2775cf8e6b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ComputeController.cs b/Assets/Scripts/ComputeController.cs new file mode 100644 index 0000000..0524655 --- /dev/null +++ b/Assets/Scripts/ComputeController.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ComputeController : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/ComputeController.cs.meta b/Assets/Scripts/ComputeController.cs.meta new file mode 100644 index 0000000..b2711e0 --- /dev/null +++ b/Assets/Scripts/ComputeController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a453b492952575646aa79f717aa4c52a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders.meta b/Assets/Shaders.meta new file mode 100644 index 0000000..d4cbaf9 --- /dev/null +++ b/Assets/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 917058756798c6a499d590a02b810580 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/ColorInverter.compute b/Assets/Shaders/ColorInverter.compute new file mode 100644 index 0000000..ad8fcb5 --- /dev/null +++ b/Assets/Shaders/ColorInverter.compute @@ -0,0 +1,14 @@ +// Each #kernel tells which function to compile; you can have many kernels +#pragma kernel CSMain + +// Create a RenderTexture with enableRandomWrite flag and set it +// with cs.SetTexture +RWTexture2D Result; + +[numthreads(8,8,1)] +void CSMain (uint3 id : SV_DispatchThreadID) +{ + // TODO: insert actual code here! + + Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0); +} diff --git a/Assets/Shaders/ColorInverter.compute.meta b/Assets/Shaders/ColorInverter.compute.meta new file mode 100644 index 0000000..a38ddd3 --- /dev/null +++ b/Assets/Shaders/ColorInverter.compute.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3df3413c2fff3cc41a2eb5505b4c260c +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: