Jump to content

Flickering shadows!


gameboy
 Share

Recommended Posts

Well, so much the better.  Change one file is what I meant.  That way it's easy to revert.

I give you a shader to try.

If we don't like it, we go back.

 

What's the ptol cc material called?  How many users does it have?

 

Edited by DanW58
Link to comment
Share on other sites

47 minutes ago, DanW58 said:

But it would be better to get them all done at once, really.  Having disagreeing assets is not nice.

But in any case, you can zip the whole thing as a backup, should something really go wrong.

Using a vcs there is no need for zip backups, but using a vcs is probably also the reason why this hack got introduced ...

 

36 minutes ago, Stan` said:

Fourth Option: I make a patch and we merge it along with some other improvements in A25. This way it gets done, no risk for now :)

As long a releases are not years apart everyone is patient enough to wait for the next release. ;)

 

Edit: something went wrong when submitting the post

 

Edited by hyperion
Link to comment
Share on other sites

Actually, I was just looking at the ptol_civic_centre ao texture, and the brightest spot on it is (0.63,0.63,0.63),  which is quite dark, and out of the norm.  If all the ao's are non-standard, then I would understand the need to tweak.  I just don't understand how this is possible.  SOME piece of the structure should get a good 90%...

 

Link to comment
Share on other sites

1 minute ago, DanW58 said:

Actually, I was just looking at the ptol_civic_centre ao texture, and the brightest spot on it is (0.63,0.63,0.63),  which is quite dark, and out of the norm.  If all the ao's are non-standard, then I would understand the need to tweak.  I just don't understand how this is possible.  SOME piece of the structure should get a good 90%...

 

Well if you see the tutorial I linked earlier,  blender ao's generation was always a bit grey. Which I why I have to cap Cycles with my emissive thing.

Link to comment
Share on other sites

Well, my choice would be to report the bug to the Blender devs, rather than work around it.  I don't remember the Blender ao being so dysfunctional.  They did not modulate the rays by vlight dot normal like they should have;  it was an all rays are born equal type ao, but it did work reasonalby well.  The sky-facing ledge on the top terrace should get pretty close to 100%.  If it doesn't, it's a BUG.

Nothing to test yet, Gameboy.  We are just trying to agree what to do, and failing at it.

Link to comment
Share on other sites

6 minutes ago, DanW58 said:

Well, my choice would be to report the bug to the Blender devs, rather than work around it.  I don't remember the Blender ao being so dysfunctional.  They did not modulate the rays by vlight dot normal like they should have;  it was an all rays are born equal type ao, but it did work reasonalby well.  The sky-facing ledge on the top terrace should get pretty close to 100%.  If it doesn't, it's a BUG.

Nothing to test yet, Gameboy.  We are just trying to agree what to do, and failing at it.

Well it's pointless now since they removed the internal renderer of Blender in 2.8. But if we have to rebake every single AO in existence of the game, it's definitely A25+

Link to comment
Share on other sites

Actually, I looked to a few other ao's and I find the brightest parts are consistently 0.6 to 0.65, so I put back the multiplier in the shader, except at 1.6, rather than 2.0;  and I adjusted the non-ao option down from 1.0 to 0.8, so that objects not using ao don't look too much brighter than those that do.  This is the updated relevant section:

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

So, the shader to replace (the only one, since terrains have no ao) is model_common.fs, and is attached.  NOTE that this also contains the ambient sky-bias hack, and so it goes together with model_common.fs that I attached to a post yesterday.  Ok, here it is again, the whole set:

 

model_common.fs

model_common.vs terrain_common.fs

Edited by DanW58
Link to comment
Share on other sites

Now I'm wondering what sets the USE_INSTANCING and the USE_GPU_SKINNING defines, which seem to be required in the condition above.

I have the hidden gpu skinning option enabled, but it's very likely you don't

; Experimental probably-non-working GPU skinning support; requires preferglsl; use at own risk
gpuskinning = false

 

8 minutes ago, DanW58 said:

So, the shader to replace (the only one, since terrains have no ao) is model_common.fs, and is attached:

Thanks only @vladislavbelov can review this one.

Link to comment
Share on other sites

Actually, I WILL advocate a redoing of all ao's for A25.

For two reasons:

1) The type of ao that Blender does is not realistic.  There are other tools that provide incident angle modulated ao, which looks a lot more realistic.

2) We will probably have worked out a new texture set and texture packing by then, and we'll need to revisit the art with automated tool to check for non-conforming features, perhaps auto-fixing in some cases.  Just speculating...

Link to comment
Share on other sites

Just now, Stan` said:

Now I'm wondering what sets the USE_INSTANCING and the USE_GPU_SKINNING defines, which seem to be required in the condition above.

I have the hidden gpu skinning option enabled, but it's very likely you don't

I haven't THE FOGGIEST IDEA what these conditionals are about and why they threaten to mess with my ao.  Hoping to learn.

It's likely nobody but devs have that option enabled.  So, thousands of hours of ao baking have yet to make it to a single eye-ball out there...

 

Link to comment
Share on other sites

8 minutes ago, Stan` said:

Will take months to import and rebake everything. Maybe we could just apply a filter on the texture or something using Image Magic.

We can even write our own image manipulation programs;  it's not that difficult.  I'd even prefer to do that.  But baking ao that is angle of incidence modulated is not really convertible from standard Blender ao;  it needs to be redone.  We should get in touch with Blender devs and make a formal request.  I could write it out for you.

So I removed the instancing and skinning conditionals from the ao block in the shader, as it makes absolutely no sense to me that should have to either skin a cat or use instancing if I want to have ao;  that's absurd.  Here's the update:

model_common.fs

Edited by DanW58
Link to comment
Share on other sites

	/**
	 * Renders all non-alpha-blended models with the given context.
	 */
	void CallModelRenderers(const CShaderDefines& context, int cullGroup, int flags)
	{
		CShaderDefines contextSkinned = context;
		if (g_RenderingOptions.GetGPUSkinning())
		{
			contextSkinned.Add(str_USE_INSTANCING, str_1);
			contextSkinned.Add(str_USE_GPU_SKINNING, str_1);
		}
		Model.NormalSkinned->Render(Model.ModShader, contextSkinned, cullGroup, flags);

		if (Model.NormalUnskinned != Model.NormalSkinned)
		{
			CShaderDefines contextUnskinned = context;
			contextUnskinned.Add(str_USE_INSTANCING, str_1);
			Model.NormalUnskinned->Render(Model.ModShader, contextUnskinned, cullGroup, flags);
		}
	}


void CallTranspModelRenderers(const CShaderDefines& context, int cullGroup, int flags)
	{
		CShaderDefines contextSkinned = context;
		if (g_RenderingOptions.GetGPUSkinning())
		{
			contextSkinned.Add(str_USE_INSTANCING, str_1);
			contextSkinned.Add(str_USE_GPU_SKINNING, str_1);
		}
		Model.TranspSkinned->Render(Model.ModShader, contextSkinned, cullGroup, flags);

		if (Model.TranspUnskinned != Model.TranspSkinned)
		{
			CShaderDefines contextUnskinned = context;
			contextUnskinned.Add(str_USE_INSTANCING, str_1);
			Model.TranspUnskinned->Render(Model.ModShader, contextUnskinned, cullGroup, flags);
		}
	}

Renderer.cpp

Seems like INSTANCING is true for everything that's not transparent, or not skinned (read not having animations): buildings fit that criteria.

 

 

 

You guessed it str_1 is = "1" Interned in the memory.

 

Link to comment
Share on other sites

2 minutes ago, DanW58 said:

We can even write our own image manipulation programs;  it's not that difficult.  I'd even prefer to do that.  But baking ao that is angle of incidence modulated is not really convertible from standard Blender ao;  it needs to be redone.  We should get in touch with Blender devs and make a formal request.  I could write it out for you.

Might want to try with Cycles, it's as white as you want it to be.

Link to comment
Share on other sites

I'm afraid Cycles would not work.  Several problems:

1) Cycles's devs are devotees of random;  they solve every problem by adding noise, and then give you decapitating filters to get rid of it.

2) A node network would never be as fast as hand-written code.

3) Neither the Cycles people nor the Blender people have the slightest clue about floating point numerical precision issues, and when you are adding 300 or 1000 rays the accumulator had better be double precision, or you get huge aliasing problems.

My buddy Klauss and I, at Vegastrike, once built a relationship with this Spanish guy that had an ao tool called Xnormal.  We helped him improve quality, such as by using a double for the accumulator, and helped him get rid  of a lot of bugs.  He had the option of vlight dot normal modulation or plain ao.  Not sure if it still exists, though;  that was 20 years ago.

EDIT:  (still there, but still Windows-only)

https://xnormal.net/?lang=en

Edited by DanW58
Link to comment
Share on other sites

5 minutes ago, DanW58 said:

My buddy Klauss and I, at Vegastrike, once built a relationship with this Spanish guy that had an ao tool called Xnormal.  We helped him improve quality, such as by using a double for the accumulator, and helped him get rid  of a lot of bugs.  He had the option of vlight dot normal modulation or plain ao.  Not sure if it still exists, though;  that was 20 years ago.

I have used XNormal for a while, sadly it's not cross platform. Also we still need blender to merge the meshes (cc has a few props such as the statues for instance), generate the UV's export, import as obj in xnormal reexport, split model by materials in blender, and reexport everything.

 

Link to comment
Share on other sites

2 minutes ago, DanW58 said:

Yes, so maybe I should edit a letter to send to Blender, as a feature request in the name of wildfiregames.

I'll have it ready in an hour or so.

I'm not sure that's how it works, they probably only handle tickets on their Phabricator. We might be faster by writing a plugin.

https://www.blendernation.com/2018/01/03/textools-for-blender/ might be interesting

3 minutes ago, DanW58 said:

Stan, did you set the flag for Normalized when you baked ao's in Blender?

That is a flag that should not even be optional;  it MUST be on.

Probably not, since I don't know where it is, and for what renderer it is present.

Link to comment
Share on other sites

I haven't baked anything since 2.74, and back then there was only one renderer for ao.

We could also try and write our own ao baker.

That text tools looks marvelous;  but it doesn't bake, does it?  But it looks it makes much better uv layouts than most tools out there.  I never found a tool good enough;  always did the unwrap by hand.

At least in the old days there was a Normalized check box in the Blender Bake panel.

If you click it, the brightest texel is scaled up to white, and the rest are all scaled by the same factor.

I bet this is the reason the ao's are so dark here.  That thing has to be clicked on, and then this situation where nothing is brighter than 0.63 cannot happen.

And you might ask, "Isn't that tweaking in the tool?".  Well, yes and no.  A fully unoccluded point on the surface of the model SHOULD be white.  If it isn't it's just got something to do with the number of rays that were accumulated;  some non-power-of two number.  So it is a science based tweak to Normalize an ao texture.

Edited by DanW58
Link to comment
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.

 Share

×
×
  • Create New...