13 public abstract string name {
get; }
20 private int _warningCounter;
23 get => _warningCounter;
24 private set { _warningCounter = value; }
29 private readonly
int kernelHandleAttributeClusters;
30 private readonly
int kernelUpdateClusterCenters;
44 this.kernelHandleAttributeClusters = this.computeShader.FindKernel(
"AttributeClusters");
45 this.kernelUpdateClusterCenters =
computeShader.FindKernel(
"UpdateClusterCenters");
50 this.warningCounter = 0;
59 this.computeShader.SetBool(
"reject_old", rejectOld);
60 this.computeShader.SetInt(
"mip_level", clusteringTextures.
mipLevel);
63 this.computeShader.SetTexture(
64 this.kernelUpdateClusterCenters,
66 clusteringTextures.
rtArr
68 this.computeShader.SetTexture(
69 this.kernelUpdateClusterCenters,
73 this.computeShader.SetBuffer(
74 this.kernelUpdateClusterCenters,
75 "cbuf_cluster_centers",
78 this.computeShader.SetBuffer(
79 this.kernelUpdateClusterCenters,
80 "cbuf_random_positions",
84 this.computeShader.Dispatch(this.kernelUpdateClusterCenters, 1, 1, 1);
89 this.computeShader.SetBool(
"KHM",
false);
92 this.computeShader.SetTexture(
93 this.kernelHandleAttributeClusters,
97 this.computeShader.SetTexture(
98 this.kernelHandleAttributeClusters,
99 "tex_arr_clusters_rw",
100 clusteringTextures.
rtArr
102 this.computeShader.SetBuffer(
103 this.kernelHandleAttributeClusters,
104 "cbuf_cluster_centers",
108 this.computeShader.Dispatch(
109 this.kernelHandleAttributeClusters,
115 clusteringTextures.
rtArr.GenerateMips();
120 this.computeShader.SetBool(
"KHM",
true);
121 this.computeShader.SetFloat(
"p", p);
124 this.computeShader.SetTexture(
125 this.kernelHandleAttributeClusters,
129 this.computeShader.SetTexture(
130 this.kernelHandleAttributeClusters,
131 "tex_arr_clusters_rw",
132 clusteringTextures.
rtArr
134 this.computeShader.SetBuffer(
135 this.kernelHandleAttributeClusters,
136 "cbuf_cluster_centers",
140 this.computeShader.Dispatch(
141 this.kernelHandleAttributeClusters,
147 clusteringTextures.
rtArr.GenerateMips();
165 false => this.clusteringRTsAndBuffers.texturesWorkRes
virtual DispatcherParameters abstractParameters
float? GetVariance()
Computes variance for the current cluster centers. Depending on this.useFullResTexRef uses either wor...
void AttributeClustersKHM(ClusteringTextures clusteringTextures, float p)
abstract bool doesReadback
abstract bool usesStopCondition
ClusteringRTsAndBuffers clusteringRTsAndBuffers
void AttributeClustersKM(ClusteringTextures clusteringTextures)
ADispatcher(ComputeShader computeShader, int numIterations, bool doRandomizeEmptyClusters, bool useFullResTexRef, ClusteringRTsAndBuffers clusteringRTsAndBuffers)
Takes ownership of the clusteringRTsAndBuffers
bool doRandomizeEmptyClusters
abstract void RunClustering(ClusteringTextures clusteringTextures)
void UpdateClusterCenters(ClusteringTextures clusteringTextures, bool rejectOld)
readonly ComputeShader computeShader
Call Dispose after using.
Call Allocate before using and Dispose after using.
ComputeBuffer cbufRandomPositions
ComputeBuffer cbufClusterCenters
void UpdateRandomPositions()
ClusterCenters GetClusterCenters()
Get a pooled instance of ClusterCenters with a copy of the data from ComputeBuffer....
void SetClusterCenters(Vector4[] clusterCentersBufferData)
Reads the cluster centers data from the array and loads it into the ComputeBuffer.
ClusteringTextures texturesFullRes
const int kernelSize
Must match the shader.
Call Dispose after using.
readonly RenderTexture rtArr
readonly RenderTexture rtInput
Call Dispose after using.