-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terrain random flashs #469
Comments
Sorry but I don't know how to investigate that. I would need a minimal test project that shows this happening (and therefore allowing to change things confirming whether or not it fixes it). I haven't experienced this lately. Is that black dot present all the time or is it flickering or moving? Does this happen with a specific shader? With specific things present? How big and how bright are the flashes? The only supposition I have is that maybe, in your particular setup, something causes a value in shader to become NaN or very high, outputting that black pixel and then cause a "flash" if you have a post-processing effect such as bloom or glow enabled because that tends to spread the bogus pixel around (but why every 5 minutes, mystery; and that's assuming Godot features you're using are bug-free). But without any way of reproducing this I can't investigate. |
The black dot and glow around appears in a frame then the next one if the camera moves it is not there anymore. The glow is particularly noticeable because it flashes strongly, with an approximate radius of 50 pixels. I'm using the Classic4 shader, but the issue persists when switching to Classic4Lite. I have the glow effect enabled, and it seems related to the issue. Disabling the glow prevents the problem, while adjusting the glow parameters increases or decreases the intensity of the effect. Side note, turning on fog makes the issue disappear, though I'm not sure if this applies to all situations or fog distances. The 5 minutes I mentioned was just to illustrate how rare the event is. It doesn’t mean it happens every 5 minutes. I might notice it 3 times in 10 minutes or not at all. At the moment, I don’t have a minimal test project to share, and I haven’t tested the issue on a different computer. I can probably test it later. Not sure if is related, but sometimes I got white or black dots, even sometimes are small lines. Like this: Thank you. |
Hmm I haven't seen lines like this either. I opened a few test scenes I had around and could not find anything. So I'm not going to be able to do further investigation without a way to confirm this, or you have to try changing things in the shader in your project. If you have detail layers, try turning them off just in case. An example of tests you could do, at the end of the terrain's fragment shader: // Attempts at sanitizing outputs to prevent NaNs/Infs/Illegal values
ALBEDO = clamp(ALBEDO, vec3(0.0), vec3(1.0));
ROUGHNESS = clamp(ROUGHNESS, 0.0, 1.0);
NORMAL = clamp(NORMAL, vec3(-1.0), vec3(1.0));
if (length(NORMAL) < 0.2) {
NORMAL = vec3(0.0, 1.0, 0.0);
} else {
NORMAL = normalize(NORMAL);
} You could also try adding this one at the end of the vertex shader: NORMAL = clamp(NORMAL, vec3(-1.0), vec3(1.0));
if (length(NORMAL) < 0.2) {
NORMAL = vec3(0.0, 1.0, 0.0);
} else {
NORMAL = normalize(NORMAL);
} If that fixes it, remove them until you can identify which one causes it. |
ALBEDO = clamp(ALBEDO, vec3(0.0), vec3(1.0) At least in the quick test I’ve done, this line seems to fix the issue of the white dots. Not sure about the glows, I have not tested yet. I’ve attached a very basic project if you want to test it. There’s a small white dot in the top middle, and commenting out that line in the shader makes it disappear. My screen is Full HD (1920 x 1080), the bug probably requires the same resolution to occur. I’ve only added the terrain, no textures, no light, etc.. just enough to reproduce the bug. |
That’s the bug I encountered. When the glow is active, those dots sometimes cause a glow effect there. I manually cleaned the splatmap, I didn’t notice that it wasn’t the correct color. I was in a bit of a hurry and I thought it might be enough without textures, but I can try again later when I have the opportunity to provide some example with textures. Thank you for looking into it. |
Here is the same scene. I have added a texture, and also a Environment light. You can probably apply any texture, and the bug persists. At least with the two I tried, it was still present. |
See my last notes from above. I wonder if the fact that tint is sampled per vertex has something to do with this. If I move all sampling to the fragment part, the problem seems to go away. It's like whatever interpolates the It's annoying because moving it all to fragment brings a different problem: 2 more texture samples and extra calculations done per pixel, for something that varies only per vertex, so it may be more expensive. Also there are already a lot of other samples in terrain fragment shaders (which some low-end graphics cards just nope at) so I don't know what else to do about it, or how I could keep it per-vertex while avoiding this frustrating issue (which, oddly enough, hasn't been noticed in years of existence of this shader). |
I don’t know much about shaders (it’s something I want to learn later), so unfortunately, I can’t be of much help with this. I just wanted to report the issue in the hope that it can be found and fixed. |
If you need a quick fix for now, you may keep the clamp, or move this part to the beginning of godot_heightmap_plugin/addons/zylann.hterrain/shaders/simple4.gdshader Lines 180 to 190 in dd14984
For now I only suspect the issue comes from how the graphics driver is interpolating So unfortunately the "fix" for now will be to move these samplings to the fragment shader, because it seems to just work, despite the small extra cost... If someone wants the shader to do it per-vertex again, or wants to investigate this, I'll do it using |
This is to workaround an unexpected blow-up of interpolated values when they were sampled in the vertex shader and used in the fragment shader. The assumption is that interpolation somehow runs out of precision or incorrectly calculates varying values, causing them to become higher than 1, which in turn causes flashes to occur when bloom is enabled. I think this is still unexpected and needs more investigation, but I'm not sure what else to try (that I know how to do) and I don't have much time. See #469
Workaround in 659da22 |
When moving the camera around the terrain, I occasionally see random flashes. They occur on average about every five minutes during gameplay. The flashes of light usually appear around a black dot.
Environment
The text was updated successfully, but these errors were encountered: