Flickering graphics with some camera positions

This is a problem that’s been affecting me again and again.

See here:

and here:

An most lately here:
https://www.mediafire.com/convkey/8bd3/amt75oxy15kaaxu6g.jpg

Could you please help me find out if it’s a bug with my computer?
Download my project here, then use num pad 4 or 6 to turn the camera to look at the character from the left or right.
Does it flicker like in the above gif?

If I avoid placing the camera at that exact orientation I can avoid the effect, but I want to know what is causing it cos it’s driving me nuts!

This is so weird. Seems all I can do it point at UPBGE. For whatever reason it works fine over there.
Slick demo btw.

Hi! Does this still happen when you play with lamp shadow options?

Weird. I’ve never hit that problem before. I had some changes playing with the bias value, but none that fixed it completely.

It’s something to do with the shadow incorrectly clipping. Sometimes you can see it stop flickering and it intersects with the geometry.

I still don’t know what the problem is, but it has something to do with setting an object’s orentation by using a Quaternion. Specifically the Vector.to_track_quat() method.

I don’t usually use AlignAxisToVect() since it often gives buggy results if you use the Y axis, so I usually use something like the following:

lerp_speed = 0.02
target_vector = target.worldPosition.copy() - own.worldPosition.copy()

own.worldOrientation =  own.getAxisVect([0.0,1.0,0.0]).lerp(target_vector,lerp_speed).to_track_quat("Y","Z") 

Usually this isn’t a problem, since Zeno’s paradox ensures I never reach the target angle. Lerping with a set number like 0.02 will never reach the destination, though it gives a pleasing smooth action getting slower as it gets nearer.

However today I was trying out lerping with a timer which allows full traversal of the range from start to finish. so I re-discovered this problem. In the past I disabled lerping during testing and saw it too.

The solution is to use a safe transformation:

Either use matrix math:

mat_loc = own.worldTransform
mat_rot = mathutils.Matrix.Rotation(math.radians(-90.0), 4, 'Z')
mat_out = mat_loc * mat_rot 
        
start = own.worldTransform
end = mat_out

or convert the Quaternion to a 4x4 matrix before using it to set the transform:

camera_directions = [(0,1,0),(1,0,0),(0,-1,0),(-1,0,0)]        
start = mathutils.Vector(camera_directions[2]).to_track_quat("Y","Z").to_matrix().to_4x4()
end = mathutils.Vector(camera_directions[3]).to_track_quat("Y","Z").to_matrix().to_4x4()

I don’t know why this happens, but I think it could also be the source of the problems with AlignAxisToVect() which cause flipping on the y axis.

That looks like a graphics card problem. I have this problem when I have a lot of textures:

I don’t think it’s a graphics card issue. I’ve got a good card and the most up to date drivers.
Anyway, I’ve marked it as solved and reported a bug.
https://developer.blender.org/T48374

Try downloading the simple problem file there and see if you get the same problem.

EDIT:
Not solved. The demos I made for reporting the bug are OK, but my project still has trouble whether I use matrix transform or anything.

@Smoking_mirror: I cannot reproduce your both bug (from the bug report and the game) in UPBGE, i don’t know which commit solve this, if i have time maybe i will bisect it.

PS: Very nice game :slight_smile:

Thanks, I’m not keen on switching to a fork of the BGE. There are a couple of such projects at the moment, but I think it just divides developer time. I’d rather everyone focus on BGE, or if that’s not possible to all decide on one version to move forward with and all focus on that. For myself I’d rather see a nice clean modern engine without all the baggage, rather than loads of new features bolted on to an already creaky structure.

The test I put on the bug report has one 256x256 texture. I don’t think it’s related to graphics, but I could be wrong.

I think they have done quite a bit of infrastructure work, and bug fixing,

I don’t see any evidence that upbge is less stable then bge, but it’s definitely different enough to warrent not starting a project in BGE and moving it to UPBGE

probably best to start a new project in UPBGE,

if you have lots of things like grass or leaves, upbge should in theory by quite a bit faster, anything that you use over and over (like map tiles), that use dupligroups should be instanced*

I don’t see flickering, my low spec card 750ti drivers(359.06) has not been updated for a long time, I heard the newer drivers are unstable and causes an uproar recently, might that be the cause?

Edit: saw flickering when and after Zooming in

This same thing happens to me with 2.77. The whole screen flashes black, but only when my movement is in a straight line, and only in perspective mode.

Then in 2.77a the shadows were the only thing that started flickering! And if I remember right, Smoking Mirror has the same graphics card as me(gtx 960).

Does anyone see my shadow flickering? You have to go back or forward(S,W keys), and then when you move the mouse the flickering goes away. Very strange!.

Attachments

Shadow_Problem.blend (546 KB)

I confirmed this on a computer at work rocking a crappy Intel graphics card. It’s not related to drivers or graphics cards.

My guess would be something to do with the camera transform during rendering. I’ve tried several solutions, sucb as decomposing the camera world matrix to loc and rot components and setting them individually, unparenting the camera and copying location… nothing can solve the problem. The only thing I can do is to avoid it by not using right angle rotations. If I rotate the camera to 88 degrees instead of 90 degrees it doesn’t show up.

it is your card or direct x.

to test your card download an artifact test program (Warning! if you card is dieing and you test it, your card can die for sure with the test)

also update directx 9 and 11 drivers and or use older version of your graphic card driver.

i am using amd 7850 1gb (old card) version, i dont have problems with your blends.
the flickering is related to you drivers/card for sure.

@cotax, Blender isn’t using DirectX, it is using OpenGL.

Thanks, I’m not keen on switching to a fork of the BGE. There are a couple of such projects at the moment, but I think it just divides developer time. I’d rather everyone focus on BGE, or if that’s not possible to all decide on one version to move forward with and all focus on that. For myself I’d rather see a nice clean modern engine without all the baggage, rather than loads of new features bolted on to an already creaky structure.

Tristan (alias Panzergame) proposed to find the commit that solved your problem in upbge so you can complete the bug report with useful infos to solve it in the bge…

(Parenthesis: Since no one knows about the future of the bge, bge development has been “paused”… Panzergame and few others decided to work on a separate branch because it’s more easy to make the game engine progress and refactor (the upbge code is now very different from official bge code). But there are many other projects: BDX, Godot, Kupoman and Moguri’s Project, Panda?, and Cycles Game engine and maybe others. We don’t know if any of this project (or another one) will replace the bge in Blender official sources. Everyone can choose what’s the best for his needs. And we’ll see what will be decided concerning a game engine in 2.8. Waiting for this decision, upbge will continue to be developped and I guess this is the same for all other projects.)

I am grateful for the offer to find the problem, and I know that the future of the bge is in doubt. Sorry if I sounded dismissive of upbge but hearing “if you have a problem with bge you should switch to upbge” sounds a lot like “if you have a problem with bge you should switch to unity”.

I probably will switch to a new game engine when we get to blender 2.8, I just hope that there’s something to come out of this community that has what I need. For example I’d prefer to continue using python and for me stability, bug fixes and continuity with the current bge are much more important than lots of new features and a short development cycle.

From reading the upbge website that’s what it sounds like the focus is, modernizing the bge by adding new features quickly. Honestly I can’t think of a single feature I’d like to see added to BGE right now, but there’s always at least one bug that never seems to get fixed and new ones which crop up every time a new feature is added.

Meanwhile the “cycles” game engine seem to be making the classic mistake and deciding that they need a “more powerful” scripting language than python. Because the developer is a programmer they feel that fast is better than user friendly. There are several reasons why python is one of the preferred languages among scientists and technicians.

Anyway, this thread is about a bug in bge. So far I’ve tested the bug on two different computers with different graphics cards and different drivers and got the same result. That suggests to me that the problem is in blender, not in my graphics card or drivers.