[QUOTE=Crian]Acht Nachbarn heißt vermutlich, links oben, oben, rechts oben, rechts, rechts unten, unten, links unten und links? Dann machst du alle vorher exakt geteilten Bereiche des zu berechnenden Feldes um einen Pixel breiter und brauchst keine Informationen von anderen Teilen, mit denen du dich austauschen musst.
Aber vielleicht reden wir auch schlicht aneinander vorbei, von OpenGL habe ich keine Ahnung.[/QUOTE]
Ahja ich verstehe. In einem Fragment Shader jetzt nicht direkt, aber in einem Compute Shader sollte das tatsächlich in etwa umsetzbar sein, aber nicht komplett parallel soweit ich weiß.
Würde auch nicht der wissenschaftlichen Arbeit von Repenning (2006) ganz gerecht werden, aber vielleicht wird das Ergebnis sogar besser* 
*Gerade getestet noch vor dem Abschicken der Antwort, das Ergebnis bleibt ungefähr gleich. 
@Marco13
Ich hab mich da mal eurem Conway Shader bedient, nur etwas umgeschrieben.
/*
* Copyright 2012, Michael Schorn (me@mschorn.net). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* 'Modified
* Copyright 2016, TMGroup©
*/
#version 310
precision mediump float;
uniform sampler2D texture;
uniform sampler2D collision_map;
void main() {
float c = texelFetch(collision_map, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0).r;
if( c == 0 ) {
float n = texelFetch(texture, ivec2(gl_FragCoord.x - 1, gl_FragCoord.y - 1), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x - 0, gl_FragCoord.y - 1), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x + 1, gl_FragCoord.y - 1), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x - 1, gl_FragCoord.y - 0), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x + 1, gl_FragCoord.y - 0), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x - 1, gl_FragCoord.y + 1), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x - 0, gl_FragCoord.y + 1), 0).r;
n += texelFetch(texture, ivec2(gl_FragCoord.x + 1, gl_FragCoord.y + 1), 0).r;
gl_FragColor = vec4( n * 0.125, 0, 0, 0 );
}
else {
gl_FragColor = vec4( 0, 0, 0, 0 );
}
}
Die Textur des Framebuffers wird dann per glGetTexImage zurück zur CPU beordert und „texture“ wird mit „framebufferTexture“ vertauscht und wieder gestartet.
- Fehlt nur noch das vorher über eine 1D Textur gearbeitet wird mit den Positionen der Aktoren die dann in den Framebuffer geschrieben werden.
texelFetch(texture, ivec2(positionX, positionY), 0).r = 0;
- Dann wird der Code oben ausgeführt über die gesamte 2D Textur.
- Und im letzten Schritt wird dann wieder über die 1D Textur im ersten Schritt gelaufen und in einen 1D Framebuffer die Ergebnisse geschrieben und an die CPU zurückgegeben.
ivec2 neighbourIndex = getHighestNeighbour(x, y);
vec2 direction = calcDirection( x, y, neighbourIndex.x, neighbourIndex.y );
gl_FragColor.xy = direction;
- Und im allerletzten Schritt wird dann framebuffer mit texture auf der GPU (und nicht auf der CPU) vertauscht