Jump to content

Flickering shadows!


Recommended Posts

  • Replies 160
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I'm working on a new algorithm;  a much more "benevolent hack" than this one.  However, I was just playing a game in this marvelous new map, oceanside I think it's called, and upon attacking a cc I no

This kind of problem is typical of games using the method whereby the scene is rendered to a depth texture from a light source, and then the depth info is transformed and compared with when rendering

Thanks for the encouragement. This version now works better.  Pretty good with Ptolemaic, but the problem with the Athenians was that the texturing there makes so little sense it's nearly impossi

Posted Images

I'm guessing in a month or two, but I don't know;  I'm actually quite new around here.

Anyways, the problem seems to be that there's a minimum shadow distance set somewhere, probably to avoid surfaces shadowing themselves, but that is not short enough for the existing art.

I know I said this is probably a precision problem, but I'm changing my mind now...  If it was a precision problem it would show at any distance from the shadow casters, not only at the shortest distances --the way it seems to occur.

@Stan`Does this building have an ao?  I'm not sure how to tell in Blender.

Edited by DanW58
Link to post
Share on other sites
1 hour ago, wowgetoffyourcellphone said:

The bevel is okay, but the UV mapping should probably be adjusted.

Very true.  I can't sleep, so I'll tackle it right now. Probably just a matter of moving the edge on the UV map.

By the way, I just notice the same shadow flickering problem on the terraces of guard towers.  The strange thing is that it changes as you rotate around the tower.  Going back to thinking this is algorithmic.

Edited by DanW58
  • Like 1
Link to post
Share on other sites

No, exactly, this is a software problem.  We should make sure all models have AO, though;  I'm not sure this does;  if it does it's kind of weak.  The space behind the columns should already be pretty dark from the AO, then even the flickering of the direct shadow wouldn't be so noticeable.

Done.

 

done.jpg

ptol_civic_centre.dae

Link to post
Share on other sites

It has an AO texture. See https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/art/actors/structures/ptolemies/civic_centre.xml

The material xml tag + “aoTex” tells you it does. If you want to see whether it does in Blender rather than in the game look whether a mesh has too UV sets (that's usually it) Just in case it could make it easier for you, I wrote a blender plugin to import actors directly it doesn't import AO maps yet but I suppose it could.

Most people play without AO specular and normal maps and parallax normal maps of for performance reasons. (Using the shader quality slider in the options)

  • Thanks 1
Link to post
Share on other sites

Stan, I found the ao png, and it looks good;  but I wanted to see it on the model, so I loaded it into Blender in the UV editor,  and went back to the 3D view to look at it on the model, but the building appears very dark, with two small slivers of light.  I'm used to the old Blender of XP days;  I'm really struggling to get used to the new Blender interface.  Anyways, I used to just load a texture in the UV screen and look at it in 3D in object mode, but it's not working for me.

In-game, I strain my eyes trying to see AO and can't see any;  even though all my graphics options are maxed out, including the Shader Effects.  Could it be that my tweaking with the model removed the texture linkage somehow?

Link to post
Share on other sites
3 minutes ago, DanW58 said:

In-game, I strain my eyes trying to see AO and can't see any;  even though all my graphics options are maxed out, including the Shader Effects.  Could it be that my tweaking with the model removed the texture linkage somehow?

It's hard to tell. Maybe vladislav would tell you, he seemed to be interested in you uploading the patch to Phab. I never took the time to learn GLSL :/

4 minutes ago, DanW58 said:

Stan, I found the ao png, and it looks good;  but I wanted to see it on the model, so I loaded it into Blender in the UV editor,  and went back to the 3D view to look at it on the model, but the building appears very dark, with two small slivers of light.  I'm used to the old Blender of XP days;  I'm really struggling to get used to the new Blender interface.  Anyways, I used to just load a texture in the UV screen and look at it in 3D in object mode, but it's not working for me.

Can you take a screenshot? I could send you a blend file with the ao applied if that helps :)

Here is my plugin btw

https://github.com/StanleySweet/blender_pyrogenesis_importer/releases/tag/1.3.6

Link to post
Share on other sites

Well, my Blender interface is now completely messed up;  it became divided into four sub-screens, with the top left full of icons for folders;  I don't even know what I touched;  and can't seem to get out of it.

Maybe you can look at the file and, yes, maybe apply the texture to it for me;  I've had so much Blender frustration today I almost need medication. 

GLSL is much easier than it looks.  First of all, it's much like C.

But the main types of variables you use are float, vec3 and vec4 (3 and 4 floats, respectively).

So, for a fragment shader example,

uniform vec3 sunray;   //uniform means that it's like a per-frame constant
uniform vec3 suncolor; //ditto
uniform sampler2D baseTex; //this is a data structure to read a texture
varying vec2 v_tex;    //texture coordinates, interpolated by vertex shader
varying vec3 vnormal;  //interpolated vertex normal, varying means from the vertex shader

main() //this executes per pixel, or per pixel-fragment in antialiased mode
{
  //calculate the diffuse component of final color:
  vec3 difftexture = texture2D(baseTex, v_tex.xy); //fetch diffuse color from texture
  float diffuse_intensity = dot(sunray, vnormal);  //dot = cosine of angle; 1 for face-on
  vec3 diffuse = difftexture * suncolor * diffuse_intensity;
  //similar thing for ambient light with ao
  //similar thing for specular
  //add it all together and output.
} //next pixel...

What is that plug-in?  For what?

EDIT:  File attached;  no change since last attached.

ptol_civic_centre.dae

Edited by DanW58
Link to post
Share on other sites
20 minutes ago, DanW58 said:

Well, my Blender interface is now completely messed up;  it became divided into four sub-screens, with the top left full of icons for folders;  I don't even know what I touched;  and can't seem to get out of it.

Maybe you can look at the file and, yes, maybe apply the texture to it for me;  I've had so much Blender frustration today I almost need medication. 

Happens sometimes, here is a little video, and the blend ptol-cc-ao.blend

21 minutes ago, DanW58 said:

What is that plug-in?  For what?

Link to post
Share on other sites
22 minutes ago, DanW58 said:

uniform means that it's like a per-frame constant

Per draw call constant. But some constant might be per frame.

22 minutes ago, DanW58 said:

texture coordinates, interpolated by vertex shader

It's not interpolated by vertex shader, because vertex shader knows nothing about fragments. It will be interpolated on or or after rasterization step.

22 minutes ago, DanW58 said:

//this executes per pixel, or per pixel-fragment in antialiased mode

Usually it's called per-pixel in both modes. Only some driver implementations allow you to force per-sample executing.

22 minutes ago, DanW58 said:

dot(sunray, vnormal); //dot = cosine of angle; 1 for face-on

Mostly, but not in that case. vnormal isn't normalized, so it'd be near but not always cosine.

 

Link to post
Share on other sites

Stan, I can't follow;  too fast.  Maybe tomorrow after coffee.  I mean today.

So, the ao looks perfect;  I just don't see it in-game, for some mysterious reason.

 

10 minutes ago, vladislavbelov said:

Mostly, but not in that case. vnormal isn't normalized, so it'd be near but not always cosine.

Yeah, now I remember it had to be normalized...

 

EDIT:

Speaking of cosines, which type of ao are you guys using?

The ao by Blender is unmodulated, last time I looked into it.

That means, all rays are counted equally.

There's a type of ao where rays are multiplied by light dot normal before accumulating.

That type of ao gives noticeably more realistic results.

Edited by DanW58
Link to post
Share on other sites

Nice!

Why is it called "ao_as_emissive"?  AO modulates reflected ambient.

I hope you guys are not ADDING the ao... It should multiply the ambient component.  It should darken, not brighten...  Is this why I can't see it?

(Going to bed now.)

Link to post
Share on other sites

 

I'm looking at ao code in model_common.fs...

  #if (USE_INSTANCING || USE_GPU_SKINNING) && USE_AO
    vec3 ao = texture2D(aoTex, v_tex2).rrr;
    ao = mix(vec3(1.0), ao * 2.0, effectSettings.w);
    ambColor *= ao;
  #endif

The first line is informative.

The last line is reassuring.

But the middle-line makes me reach for the gyn bottle ...  ao * 2.0 ?!?!?!?

 

Link to post
Share on other sites
22 minutes ago, DanW58 said:

It should multiply the ambient component.

I suppose it contradicts to your patch for the current game. Because you decrease ambient from skies for vertical surfaces. But AO is used for any kind of indirect light, including sun direct light reflected from some surfaces, which is more powerful than skies ambient.

Link to post
Share on other sites
2 minutes ago, DanW58 said:

But the middle-line makes me reach for the gyn bottle ...  ao * 2.0 ?!?!?!?

It happens in our code, and usually it's just a workaround to make it look better. You haven't seen the water one before I've done a cleanup for it.

Link to post
Share on other sites

There are no other sources for ao to modulate;  ambient is it;  ambient accounts for all sources except direct.  Given the entire luminous surroundings, environment mapping returns the specular portion of it, and reflected ambient returns the diffuse portion of it.  And just like reflections should get some self-occultation but that's really difficult to do, reflected ambient can get occultation by modulating it by the ao.  It just has to be multiplied by the ao.

13 minutes ago, vladislavbelov said:

But AO is used for any kind of indirect light, including sun direct light reflected from some surfaces, which is more powerful than skies ambient.

You're talking about second reflections;  that's a whole other subject;  it cannot be handled by ao nor by anything except a HUGE hack;  I tried to tackle that one...

11 minutes ago, vladislavbelov said:

It happens in our code, and usually it's just a workaround to make it look better. You haven't seen the water one before I've done a cleanup for it.

Thing is, not only is it incorrect, but it is likely to cause saturation.

The good news is I took out that "* 2.0" and nothing changed...

Maybe it's something with my videocard?  Can't seem to see the ao in-game.

Edited by DanW58
Link to post
Share on other sites
1 hour ago, DanW58 said:

Nice!

Why is it called "ao_as_emissive"?  AO modulates reflected ambient.

 

(Going to bed now.)

I don't know why it added your images to my post, and won't let me delete them.

Because I use blender emissive channel to bake it without interference from other stuff. This way I'm sure whatever I bake is pure AO, not stuff with reflections and whatnot.

EDIT: Goodnight

Quote

I hope you guys are not ADDING the ao... It should multiply the ambient component.  It should darken, not brighten...  Is this why I can't see it?

It's multiplied in the game. https://trac.wildfiregames.com/wiki/MaterialSystem & https://trac.wildfiregames.com/wiki/MaterialFormat

EDIT: Just saw your above post.

15 minutes ago, DanW58 said:

I've just tried removing any graphical features not necessary to ao, to see if my videocard was overwhelmed, but it makes no difference;  still no ao.

 

One thing you can try is to replace the ptol struct by a white texture

https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/art/textures/skins/structural/ptol_struct.png

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...