Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Is there anyway to turn off smoothing for a model in AGK

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 00:34
In the attached example i have created a box in my 3D proggy and deleted any smoothing.
When i load it into AppGameKit it tries to smooth the model rather then render it unsmoothed.
Is there anyway i can get it to render the model unsmoothed?

This is a very simple example of my problem. Setting smoothing groups in my 3D proggy is NOT an option.
The model in question is very complex and it would take AGES to smooth every poly.

Thanks in advance for any help

Attachments

Login to view attachments
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 10th Apr 2019 01:34
To get hard edges/faces I use Blender > edge split modifier
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 01:50
Even if i unweld/split all edges is still tries to smooth by group
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 10th Apr 2019 10:27
Well, an easier solution would be to know what 3D Modelling Application you're using ... as it's likely in-experience in either how the Vertex Normals are set, or alternatively you're setting an option in the Exporter to Automatically set the Normal Angle to 90° and calculate on export.

Now... beyond this there are two optional routes to take here.
You can either:

1 • Use a Vertex / Pixel Shader that ignores the Object (Vertex) Normals and instead sets the Light Normalisation based upon a Normal and/or Tangent Map.
2 • Use Memblocks to Manually Recalculate the Vertex Normal Angles.

With Memblocks, it's actually quite a simple task to set the Vertex Normals to produce Facet (i.e. Uniform Lighting Per Triangle / Polygon) Shading... note that this is oft used interchangably with Flat Shading., but that's an incorrect as such is Uniform Lighting Per Object.
The mistake with this was made with 3D Studio Max terminology and just kind of got picked up by it's Clones.

If you do chose to get into Shaders, actually knowing the difference between these can be quite important.

Still, the basic premise of how to Calculate these is pretty simple.
Here's a Function for Calculating the Face Normal for a Triangle (AGK)



This can also be done with the Vector3 Commands., but the above approach means we don't have to think about cleaning up Vector3 Declarations afterwards.
It is however much easier.
Remember it's a simple case of
Edge 1 = VertexPos1 - VertexPos2
Edge 2 = VertexPos3 - VertexPos1

Normal = CrossProduct(Edge1, Edge2)

But seeing how this is actually calculates via Arrays is easier to understand what is actually going on.
Now bare in mind we're completely rewriting (or that's the intention) the existing Normal Data., so just Calculating the Normal for each Individual Triangle might not strictly be "Ideal"

We can of course take this further with Surface Normal Groups... which is a little more involved.
What we ideally want to do with this create a Custom Type and Array for Storage of the Data... as we want to Calculate the Face Normal, Edge Normal in order to ultimately figure out the Vertex Normal.

In the above example, we're basically limiting ourselves to a Face Normal; meaning the 3 Vertex are always going to Share this.
When we expand to have 2+ Triangles in a Group., then Shared Edge = Cross Product( Face 1 Normal , Face 2 Normal ) ... but when we have Shared Vertex (i.e. 3 Faces)., then we want to use the Shared Edge Normal then we're still performing a single Cross Product., but now: Shared Vertex = CrossProduct( Face 3 Normal, Shared Edge Normal ).

If we want to get "Super Fancy" about this., then we can set a 'Smooth Angle' (0 .. 90 Degrees); and in said case essentially as you're calculating said Angles you want to check if the Result is > Smooth Angle ... if so., you basically don't Store the Calculated Result. This is best done in the Shared Edge Calculations., thus we have Soft and Hard edges.
This isn't that difficult; it's just a case of SOHCAHTOA to find the Delta Angle between the two Normals.

Remember we're checking to ensure that the Delta Angle between the two Face Normals (not the Faces themselves) is < the Smoothing Angle; if it is... then Store Result, else ignore it and move on.

< • >

Now as for how we actually Store this Data... well that's fairly straight forward as well., as noted we'll be using Memblocks.
However keep in mind that if the Number of Indices is > 0 ... you WILL have to create a new MemblockMesh in order to switch it to a Non-Indexed Version that Declares all of the Vertex for each Face... it's not that difficult to then "Optimise" with Fewer Vertex via Generating an Index List., but to do this we MUST have a Raw (Unoptimised) Approach.
And remember it isn't just different Normals that require a dedicated Vertex but UV Texture Coordinate (for UV Shells) as well.

Still I'm sure with some tinkering you can figure out how Memblock Mesh work.
The Command Help is concise, but omits explaining a few elements and for some reason doesn't use Paragraphs or any other Formatting making it a LITERAL Wall-of-Text, which can be difficult to read.

By Default though you'll always have Position, Normal, Colour, UV ... as the set Attributes., and most programs won't export otherwise.
Still the lack of more in-depth explanation on how to manually set these up is certainly not ideal.
There should be a Guide and Example that can help though.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 11:32 Edited at: 10th Apr 2019 11:34
This is a cog shape exported from my 3Dproggy (swift3d). This object has No smoothing set in my 3d proggy.
When i load it in AppGameKit it looks like this (Check the attached project to see for yourself)


When i load it in blender it looks like this


Attachments

Login to view attachments
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 10th Apr 2019 12:32
Well after some searching... I couldn't find a version of Swift3D from anywhere that looked 'safe' to download it from.
It appears it was Discontinued in 2012, and hasn't been updated since 2010.

If I might make a suggestion, but you should probably think about getting something a little more "Modern"
Blender is obviously a bit of an Industry Standard today for "Developer on a Budget" ... given it's Free and Multi-Platform.

Alternatives are Modo, Lightwave3D, Maya, 3D Studio Max and Silo.
While most would likely recommend Blender (being that it's £Free) ... personally I'd argue that it isn't actually very Friendly for New / Low-Skill Individuals.
Personally I've always found it quite an awkward product to use, similar to how Softimage|XSI was also similarly awkward.

Like you can tell both Blender and Softimage were created by Programmers., as while they're technically capable ... they're an absolute pig to learn and use.
Silo on the other hand, while it's not free ($99) ... was created expressly as an an Affordable Alternative for Independant Game Developer Artists.
It's exceptionally High-Performance., Intuitive and more like using Photoshop than other 3D Application (that feel more like Adapted CAD Programs).
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Apr 2019 13:06
is it an export option, I think in blender applymodifiers causes that but not sure
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 10th Apr 2019 15:03 Edited at: 10th Apr 2019 15:07
Hey blink0k,

When I export out of blender to fbx it looks like this:


Make sure your geometry tab looks like this when you export. I believe the Use Modified Render settings is selected by default, and it smooths normals.



edit: The main tab should looks like this or you will get an enormous object

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Apr 2019 21:10 Edited at: 10th Apr 2019 21:11
Hey,

Thats why I made this shader once.
And I think I also have some memblock code for that in my shaderpack but i'm not sure if it's working ...just sitting there for you to discover
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 21:54
Thanks janbo. That worked a treat.

Quote: "Silo on the other hand, while it's not free ($99)"

Yeah i'm looking at that, it's the second time someone has mentioned it

Quote: "When I export out of blender to fbx it looks like this:"

Yeah matey. That looks cool, i have to animate it as well so that may be the way to go. I'll have to see if it will import 3ds animations as well

Thanks everyone for the help. I really appreciate it
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Apr 2019 22:44 Edited at: 10th Apr 2019 22:47
Just to add to what others have said.....Its really the 3d modelling application that decides if the model is smoothed or not and you control it in the that application. Some software calls it welded vertices, some call it hard edges, some call it smoothed faces/smoothing groups. None of them seem to agree on naming it.


Just as an example...this is a single model file loaded as one object into AppGameKit (both left and right are in the same file). So you can mix hard edges and smoothed surfaces in one object (and you should do too for good looking models....sharp sword blades and smooth curves on a car etc..).

You could have a model file with a sphere flat shaded and one file with it smooth shaded and control if thats the case in the modeling app. AppGameKit just displays it for you really. Applying a shader is an option but id fix the file if it was me.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Apr 2019 22:50
agrees

I think there is a modifier in blender but if you don't use the flat shaded modifier
I thought there was a way to export without it being a problem
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 22:51
Quote: "Its really the 3d modelling application that decides if the model is smoothed or not"

That is incorrect. If you look at the models i have posted there is no smoothing.

In your example you can clearly see there is smoothing applied to the model on the left.
If there was no smoothing you would see every poly along the stem of the object.

The fact is AppGameKit will attempt to smooth unsmoothed groups. Simple as that
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Apr 2019 22:58 Edited at: 10th Apr 2019 23:14
Quote: "In your example you can clearly see there is smoothing applied to the model on the left.
If there was no smoothing you would see every poly along the stem of the object."


Sorry your wrong :-|....if you make each triangle non-coplanar in the modelling app, then load it into agk, then AppGameKit can show every triangle as a seperately shaded triangle..... Its about knowing how to use the modelling app and ensuring that a saved model is as you want it.



Its not attempting to smooth my model and I have intentionally smoothed the right one

You could try another file format to see if its related to the file type that is causing it to be smoothed?

but... anyway good luck.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Apr 2019 23:13
Just tested
Its mainly a problem with 3DS export as the object exports perfectly as an obj and there is more options with fbx export
blender automatically flat shades unless there is a modifier when viewed in blender

its also a problem with unity there is a solution here using the edge splitter modifier to get it to work with 3DS
https://answers.unity.com/questions/294558/blender-normal-smoothing-import-problem.html

and theres a tutorial here how to export cartoon style smoothing with blender
https://blender.stackexchange.com/questions/10925/how-to-render-cartoon-style-with-completely-flat-colors

not meaning to argue but as unity has the same issues there is plenty of workarounds and shaders aren't always needed

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Apr 2019 23:27
It's definitely a .3ds issue. Clearly i have to find another modelling proggy
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Apr 2019 02:50
Check out Blender.

I came in with zero experience. It was hell to begin with - mainly because I knew nothing about modeling, animating or programming. But there are tons of resources. And you already know what you're doing, so I am sure it will be a piece of cake for ya. If I can become moderately decent at it, sky is the limit for you.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Apr 2019 06:26
Thanks golelorn. Looks like i have a bit os research to do

Login to post a reply

Server time is: 2024-11-23 01:54:30
Your offset time is: 2024-11-23 01:54:30