Page 1 of 2

Smoothing Issue

PostPosted: Wed Aug 06, 2008 6:04 pm
by Tyion
So I exported my first Age into blender today /cheers! and big thanks to Kato for the help he gave! :) But now I am faced with an issue, I linked into my Age of white and black and found that URU had well (smoothed all of my mesh's, this in turn made everything look (Icky) shall we say. So my question is, how do I stop this from happening?

Thanks much

Tyion

Re: Smoothing Issue

PostPosted: Wed Aug 06, 2008 10:27 pm
by Jojon
You kind of don't... Smooth meshes is what we have by default (I don't believe flat shading is an option at all) and furthermore, Plasma shading uses not the face normals, but the vertex normals. I.e. at a 90 degree corner, both adjacent faces point the same way, 45 degrees from their actual normal.

To "fix" this, you can break the mesh apart. I.e. if you have a cube that comes out "overshaded", you separate its six faces, so that each have private copies of their four respective vertices, rather than them all sharing eight. You can do this by selecting a face (or a group of faces, for more complex flattish shapes) and pressing the "Y" key.

A better way, is to set edges, where you have sharp angles, to "hard edges" and apply the "EdgeSplit" modifier just before export. This way you can keep the object whole in Blender. The downside is that you must remember to do this for all objects using it and that you must not save the project after applying, or the latest save will have the objects broken apart. Save first, then apply and export, then reload the saved project before further work is done. Cristian Walther write a bit of python that automagically applies modifiers at time of export -- I don't know whether that has been made "official" part of pyPRP, but I don't think so.

EDIT: (It is, of course also possible to use three vertices for a corner, rather than a single one -- then you'll have vertex normals that match the face ones. That however means you get lots of extra faces.)

Re: Smoothing Issue

PostPosted: Wed Aug 06, 2008 11:48 pm
by Tyion
Hey Jojo thanks for the info! I am pleased to report I tested the Y methed and I think it worked! Now I just have to do it to all my mesh's lol here it comes the long hours. :D

Re: Smoothing Issue

PostPosted: Sat Aug 09, 2008 1:17 am
by Christian Walther
Jojon wrote:Cristian Walther write a bit of python that automagically applies modifiers at time of export -- I don't know whether that has been made "official" part of pyPRP, but I don't think so.

Nope, not thus far - and likely not in the next few releases either, since I haven't ruled out that it may have unintended side effects. But if enough people test it and find that it's useful and doesn't break anything, it might eventually.

As a reminder, it's available from http://svn.guildofwriters.com/pyprp/contrib/CWalther/experimental/ using any Subversion client. (Perhaps I should make a separate branch for it that doesn't contain any of the post-release trunk changes or my other experimental changes.)

Re: Smoothing Issue

PostPosted: Fri Jan 09, 2009 12:37 am
by tikibear
This info is very useful. I have applied it to the Sprite Gallery.

I made all the faces on objects "soft" so they look the way they will in the game. I used the "set sharp" feature in the GUI to set all the edges sharp that I want to not be lit softly. I saved these settings.
I wrote a script to add the edge split modifier to all the objects with sharp edges. These are hard-coded in the script for now. The modifier is set to only apply to edges flagged sharp, not to edges with angular criteria
I save before running the script. I run the script. The appearance of the modded objects changes in the window. I open the Outliner. All the modified objects have a symbol next to them so I can go down the list applying the modifier to each, manually.
Once the modifiers are all applied I can export and reload the blender file to discard the modifications.

I can find no way for a script to actually apply the modifiers. Please let us know if there's a way.

I can probably modify the script to look at all objects in a scene and add the modifier automatically in some way.

Re: Smoothing Issue

PostPosted: Fri Jan 09, 2009 12:53 am
by tikibear
I created a new group called "sharp". I modified the script to apply the modifier to objects in that group.

Re: Smoothing Issue

PostPosted: Fri Jan 09, 2009 1:40 pm
by Christian Walther
tikibear wrote:I can find no way for a script to actually apply the modifiers. Please let us know if there's a way.

I'm not sure if that's what you want, but the way to get the modified mesh of an object o is
Code: Select all
m = Mesh.New()
m.getFromObject(o)

(while
Code: Select all
m = o.getData(mesh=True)

gets you the original mesh).

I don't know if there's a programmatic equivalent of the "Apply" button of a modifier, if that's what you're looking for.

By the way, I consider the current state of my PyPRP modification refined enough for a beta-quality release now.

Re: Smoothing Issue

PostPosted: Fri Jan 09, 2009 2:00 pm
by Grogyan
Tyion wrote:So I exported my first Age into blender today /cheers! and big thanks to Kato for the help he gave! :) But now I am faced with an issue, I linked into my Age of white and black and found that URU had well (smoothed all of my mesh's, this in turn made everything look (Icky) shall we say. So my question is, how do I stop this from happening?

Thanks much

Tyion


Have you tried the setSmooth and SetSolid buttons, they are usually what cause objects to appear smooth or not in game

Re: Smoothing Issue

PostPosted: Fri Jan 09, 2009 6:19 pm
by Aloys
setSmooth and SetSolid buttons, they are usually what cause objects to appear smooth or not in game

Unfortunately Plasma doesn't work that way. The only way to get sharp edges is to actually split the vertexes. And to do that the EdgeSplit modifier is the best solution; although applying the modifier before the export is less than optimal.
There was a more indepth technical discution going on in this thread.
I also seem to remember a discussion somewhere about how it was possible to get PyPRP to apply modifiers during the export process.. I just can't find it right now.. It would really be a great thing, as right now it can be a serious time waster.

Re: Smoothing Issue

PostPosted: Sat Jan 10, 2009 12:11 pm
by Christian Walther
Aloys wrote:I also seem to remember a discussion somewhere about how it was possible to get PyPRP to apply modifiers during the export process.. I just can't find it right now.. It would really be a great thing, as right now it can be a serious time waster.

I actually talk about it two and five post above you. :)

The original thread is here and the software is available at http://svn.guildofwriters.com/pyprp/contrib/CWalther/experimental/.