Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#2064 closed defect (fixed)

Flickering decals in-game when camera moves

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

Description (last modified by historic_bruno)

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 by historic_bruno, 9 years ago

Description: modified (diff)

Scratch the part about PostEffect, it happens either way.

A similar glitch on field decals:

comment:2 by historic_bruno, 9 years ago

Description: modified (diff)

comment:3 by historic_bruno, 8 years ago

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

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

comment:5 by historic_bruno, 8 years ago

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

comment:6 by Stan‘, 8 years ago

I can also reproduce it, did mirages trigger anything ?

comment:7 by historic_bruno, 8 years ago

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 by historic_bruno, 8 years ago

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 by historic_bruno, 8 years ago

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 8 years ago by historic_bruno (previous) (diff)

comment:10 by historic_bruno, 8 years ago

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 by historic_bruno, 8 years ago

Milestone: BacklogAlpha 18
Owner: set to historic_bruno
Status: newassigned

comment:12 by ben, 8 years ago

Resolution: fixed
Status: assignedclosed

In 16349:

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

comment:13 by historic_bruno, 8 years ago

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

Note: See TracTickets for help on using tickets.