Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#2064 closed defect (fixed)

Flickering decals in-game when camera moves

Reported by: Ben Brian Owned by: Ben Brian
Priority: Should Have Milestone: Alpha 18
Component: Core engine Keywords:
Cc: Patch:

Description (last modified by Ben Brian)

This has long been noticeable on the gold mines around player 1's base on Acropolis I. If the camera was moved slightly, the mine would go darker or lighter. I don't notice it in Atlas. Here's a comparison to show the difference, but it's more annoying and visible in motion:

Curiously, r13603 changed the map's PostEffect from "hdr" to "default" and the glitch went away. The only config options needed to reproduce this for me are


(so it seems post processing is affecting rendering even when postproc=false.)

OS             : Win7 SP 1 (6.1.7601)
CPU            : x86,        Intel Core i7-2600K @ 3.40GHz (1x4x2), 3.39 GHz
Memory         : 8192 MiB; 5098 MiB free
Graphics Card  : ATI AMD Radeon HD 6800 Series
OpenGL Drivers : 4.2.12217 Compatibility Profile Context; atioglxx.dll (

Change History (12)

comment:1 Changed 6 years ago by Ben Brian

Description: modified (diff)

Scratch the part about PostEffect, it happens either way.

A similar glitch on field decals:

comment:2 Changed 6 years ago by Ben Brian

Description: modified (diff)

comment:3 Changed 4 years ago by Ben Brian

Very noticeable for me now, everything with decals shows the issue:

Zoom is most obvious, but even panning can trigger these glitches.

comment:5 Changed 4 years ago by Ben Brian

Summary: Flickering on some mines in-game when camera movesFlickering decals in-game when camera moves

comment:6 Changed 4 years ago by stanislas69

I can also reproduce it, did mirages trigger anything ?

comment:7 Changed 4 years ago by Ben Brian

It's caused by the GLSL terrain shaders, particularly when normal or specular mapping are enabled (they are in the above examples, via terrain_norm or terrain_norm_spec materials added around r12508). I don't know why it only affects decals, since terrains also use these materials - still it may be related to #2070. Nor do I know why it's not visible in Atlas and only on some maps in-game: I've tried to make the simplest possible test maps without success.

I've traced it back to the bumplight variable calculated in terrain_common.fs:

vec3 bumplight = max(dot(-sunDir, normal), 0.0) * sunColor;

normal or v_normal seem to be the first variables in the shader that cause the flicker behavior.

comment:8 Changed 4 years ago by Ben Brian

Unfortunately I don't know an easy way to debug the shaders :/ It would be handy to only look at them in the case of decals, and to be able to inspect the variable values.

comment:9 Changed 4 years ago by Ben Brian

Hacky solution: I modified the shader to use v_normal as the fragment color, to make the different behavior more obvious. Notice how drastically the normal vector changes with a small camera tilt, doesn't seem like it should change at all... (this is an XYZ to RGB mapping, so green makes sense, that is "up" and obviously most terrain should have normals in that direction)

Last edited 4 years ago by Ben Brian (previous) (diff)

comment:10 Changed 4 years ago by Ben Brian

Looks like decals aren't even constructing a normal vector to pass into the GLSL shader, so it's just using garbage data... Luckily, the fix isn't too complicated, but this is something that really should throw an error if possible.

comment:11 Changed 4 years ago by Ben Brian

Milestone: BacklogAlpha 18
Owner: set to Ben Brian
Status: newassigned

comment:12 Changed 4 years ago by ben

Resolution: fixed
Status: assignedclosed

In 16349:

Fixes GLSL terrain decal flicker by initializing normal vectors, fixes #2064

comment:13 Changed 4 years ago by Ben Brian

Referenced the wrong ticket in r16394, it should have been this obviously.

Note: See TracTickets for help on using tickets.