Blender and VCol baking artifacts

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Blender and VCol baking artifacts

Postby Sirius » Wed Jul 22, 2015 3:00 pm

Hey everyone,

So, this is about a small issue with Blender's baking, which occurs whenever trying to bake ambient occlusion or shadowing to vertex color, which is the main way to bake light in Plasma.
This is something that's been bugging me for a while, and I wanted to find a solution I could use in my automated light baking script. I thought it might be worth bringing this up in case Korman devs are interested in it too.
Have a look at this:
Show Spoiler

As you can see, there are some nasty artifacts causing non smooth shadowing where I added the arrows. It's really annoying on the lower part of the mesh, which is supposed to be a completely smooth cylinder. It looks like Blender somehow doesn't understand that some faces are linked and using smoothing, and should therefore use the same vertex color. I'm not sure what causes this, maybe some error with one of the faces considered above the other, or something alike. Either way, it's quite ugly.

There aren't many topics speaking about the issue, but I found one which had a working solution:
http://blenderartists.org/forum/showthr ... -in-Python
The code one of these guys posted gets rid of most of these artifacts. Here is the previous mesh with this algorithm applied:
Show Spoiler

Much better !
There are still some unusual stains on the building (near some edges split by an edge split modifier, and some near the lower part of the mesh), but most of it is gone (what remains really doesn't stand out).

The only issue is for meshes which don't use an edge split modifier, because this will automatically smooth the whole mesh... Personally I always use edge splitting anyway, since that's how vertices are stored and rendered in Uru.

Here is a snipped of my version of the algorithm - I tweaked it a bit to suit my tastes (the original smoothed edges by taking the average color for each vertex - this one uses the brightest instead)
Show Spoiler


Well, I don't know if this will be useful to anyone, but I thought it's worth sharing, at least.
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Blender and VCol baking artifacts

Postby Tsar Hoikas » Wed Jul 22, 2015 4:32 pm

Interesting! I didn't actually know that this was an issue. I notice in that thread that they mention a C operator is supposed to do the same thing -- bpy.ops.paint.vertex_color_smooth. Have you tried that? I prefer using code that executes in C as much as we can because it's so much faster than Python.
Image
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Blender and VCol baking artifacts

Postby Deledrius » Wed Jul 22, 2015 5:06 pm

I wonder, do you have the appropriate edges Marked Sharp and have smoothing on the proper faces? In the past I've seen some of this artefacting occur when the edges aren't marked as sharp in the correct places.
User avatar
Deledrius
Gehn Shard Admin
 
Posts: 1377
Joined: Mon Oct 01, 2007 1:21 pm

Re: Blender and VCol baking artifacts

Postby Sirius » Thu Jul 23, 2015 1:19 am

Tsar Hoikas wrote:I notice in that thread that they mention a C operator is supposed to do the same thing -- bpy.ops.paint.vertex_color_smooth. Have you tried that?
Me and my habit of not reading until thread's end... Yeah, it does work too !
Well, obviously it's context-dependent, so you need to set the object as active, and force Blender to switch to vertex pain mode for it to work.
Edit: just tested, as you said this operator is a lot faster than its Python equivalent.

Deledrius wrote:I wonder, do you have the appropriate edges Marked Sharp and have smoothing on the proper faces? In the past I've seen some of this artefacting occur when the edges aren't marked as sharp in the correct places.
Well, smoothing and sharp edges are okay, as far as I can tell... Here is the object without any light baked.
Show Spoiler
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Blender and VCol baking artifacts

Postby Deledrius » Thu Jul 23, 2015 5:26 am

Sirius wrote:
Deledrius wrote:I wonder, do you have the appropriate edges Marked Sharp and have smoothing on the proper faces? In the past I've seen some of this artefacting occur when the edges aren't marked as sharp in the correct places.
Well, smoothing and sharp edges are okay, as far as I can tell... Here is the object without any light baked.
Show Spoiler

That all looks correct. I just wanted to rule that out as a cause. You're probably right that something in their algorithm is glitching out. It's a pretty major difference!
User avatar
Deledrius
Gehn Shard Admin
 
Posts: 1377
Joined: Mon Oct 01, 2007 1:21 pm


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron