Unity Compute Shader添加到结构化缓冲区

时间:2018-11-04 22:40:04

标签: unity3d shader

我正在尝试使用统一的计算着色器来实现Hough line transform。我已在CPU上成功完成此操作,并将其传输到GPU。 我正在使用<div class="nav"> <div class="container"> <ul> <a href="index.html" class="button4" style="background-color:#4e9af1">Introduction</a> <a href="privacy.html" class="button4" style="background-color:#4e9af1">Privacy Policy & Cookies/Security</a> <a href="security.html" class="button4" style="background-color:#4e9af1">Device Optimisation & Navigation</a> <a href="relevant-tech.html" class="button4" style="background-color:#4e9af1">Relevant Technologies</a> <a href="test-page.html" class="button4" style="background-color:#4e9af1">Web technologies</a> <a href="bibliography.html" class="button4" style="background-color:#4e9af1">Bibliography</a> </ul> </div> </div>作为累加器。

RWStructuredBuffer<uint>

我用RWStructuredBuffer<uint> accumulator; [numthreads (8, 8, 1)] void AngleCalculator (uint3 id : SV_DispatchThreadID) { if (textureIn[id.xy].r > 0) { // Check if the pixel is not black for (uint angle = 180; angle < 360; angle++) { accumulator[(angle - 180) + ((id.x * cos (angle * ((2.0 * 3.1415) / 360.0))) - (id.y * sin (angle * ((2.0 * 3.1415) / 360.0))) + offset) * 180]++; } } 调度了内核,宽度和高度是2的幂(64)。

应该将结果存储在累加器中,但产生的结果与CPU上的结果不同

0 个答案:

没有答案