Howdy all, this is an extension of an old thread, but my query has evolved enough that i thinks its best to just start a new one that can cover all the nescecary ground.
My goal is to create a system of dynamic 2D shaft lighting. Where based on a given texture and angle, a a shader is used to draw a texture buffer to a second texture containing detail of where to start/end light shafts in the r/g/b/a channels. This second texture is then drawn to a light surface using a second shader to specify where light shall be drawn.
Currently i have the two shaders made. The first, i believe, behaves as desired (first attachment: shd_lightShaftScan.txt) but the second shader does not (second attachment: shd_lightShaftDraw.txt).
Figure 1: The texture initially passed to the first shader, it is a blank square with the width and height of the diagonal cross section of the original occlusion map. the occlusion map is then drawn to it at a certain angle, in this case 300deg (approx. 5 radians). Black signifies where a shaft can start, white indicates where a shaft can end. grey is neutral.
[ATTACH=CONFIG]1683[/ATTACH]
Figure 2: The 1D shaft-scan texture. Alpha set to one to increase readability (so yes data for the second endpoint is missing) and dilated vertically for easy reading. r = startpoint1, g = endpoint1, b = startpoint2 and (usually) a = endpoint2.
[ATTACH=CONFIG]1684[/ATTACH]
Figure 3: The drawn light Texture.
[ATTACH=CONFIG]1685[/ATTACH]
As you can see the final light surface (3) is not what it should be. however, to me atleast, the 1D shaft Scan (2) looks about as it should.
Background information for the above case would be that the resolution of the shaft scan is 1024, the step resolution is also 1024 and the angle is 300deg (approx. 5 radians). This was done in opengl ES 2.0 using GMS2. I believe all data has been parsed from the environment to opengl as intended, though i will continue to test this.
Any help would be great, i can also give more information if needed
frag shader1: [ATTACH=CONFIG]1687[/ATTACH]
takes the initial texture and scans horizontally in a while statement. storing values in the rgba channels of a 1D texture. it recognizes black as a location to start, and white as a location to end.
frag shader2: [ATTACH=CONFIG]1686[/ATTACH]
after some coordinate math, pairs pixels in the destination texture to a specific pixel in the 1D texture. based on this and its distance, draws based on whether or not it lies in a shaft-approved region.