u/Fireonline15

I'm losing my mind. Please help me debug this.

I'm losing my mind. Please help me debug this.

I've been bug hunting this and tearing my code to absolute shreds for hours now, so forgive me if the code looks like absolute crap. It's also over 800 lines now, so I only plan to paste what's relevant, if that's not enough, please let me know. What I want to do is make it so that 2 overlapping drops of water aren't being refracted in the areas that they're overlapping. I want it to be ignored and just want to continue the ray. So I create a new ray, nudge it along, and send it on its way.

When the ray enters the drop works as far as I can tell. It increases the drop depth and allows the second if statement to fire. If I force a color for certain rays, I get a color where the second drop is during the entrance check and exit check. I'm not getting any indication that the ray isn't being saved back into the arrays. But I see a black circle where the second drop is, and when I check the rays at the top of the loop;

I see yellow in the middle, indicating that directly after I set debug color to yellow, somehow, the rest of the arrays have lost the changes to their data. I've checked the debug flag too, and same issue. Originally the data was stored in an array of Ray structs and that wasn't working either. I tried changing the flags from bools to ints, and no dice. I've been running through this code for hours and now its a complete mess and I still can't seem to make the ray pass through the second drop without interacting with it in some way.

I am not particularly seasoned with HLSL and working with shaders. No one really taught me much. I just brute forced a shader to build a galaxy and that's how I learned what I know. So it's very possible that I'm missing a fundamental rule or 6 when it comes to writing shaders, and if its an obvious issue, then I do apologize. It doesn't feel like a logic issue, it feels like data is getting lost somewhere and I don't know how. The continue at the end of both if statements should kick the code back to the top of the loop, so the debug color check should immediately be checked after setting the data, and yet I can't find any indication that I successfully set anything anywhere in the array. I also can't find anywhere where I failed to set the data, which is fun. Is there an issue with arrays of loops that can cause data loss like this?

Edit: I scrapped the code that was in the post and instead uploaded the file to github. The lines in particular that are being trouble are line 719 - 751.

https://github.com/PerrinPeterson/WindowRenderShader/blob/main/WindowRenderer.compute

u/Fireonline15 — 6 days ago