Upload
matumit-sombunjaroen
View
291
Download
1
Embed Size (px)
Citation preview
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 1By Matumit Sombunjaroen V1.0 2017/03/06
Historica Fantasia Dev BlogChapter6:
Character Shader Hypothesis
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 2
The Reason this is done before Programming
Historica Fantasia will fieldUp to a Maximum of 100-200 individual Characters at once.
Most Models will be duplicate. But Processing test is still needed to see the Limits.
Depending on the result of this Experiment,Certain Battle Presentations cannot be Use
Best Case Scenario: Full3DJust put everyone on the field like in TotalWars
Worst Case Scenario: Cut-in BattleOnly do full render on Units that are taking part in a Battle
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 3
Rendering Objective
Flesh
Cloth02
Leather01
Metal Faction Color
Leather02
Every Characters will all share the Same Materials.This is done by allocating UV to a color slot in the texture.
Pros:Minimal Resources Needed for RenderingCan field vast amount of Characters with Shared Materials
Cons:Cannot use Normal or Occlusion MapNeed High PolyCount to obtain Hi-Quality Visual
Because there will be no close-up shots of the Characters,The Cons should not be much of an issue.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 4
Toon Ramp Shading
Flesh
Cloth02
Leather01
Faction Color
Leather02
Non Metallic parts will use Toon Ramp ShaderWith Maximum of 3 Ramps forShadow => Base => Highlight
The Shader will also receive Lighting from Environment.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 5
Toon Metallic ShadingGloss
Highlight
Fresnel Light(Not sure if it’s
the correct term)
Rim Light
On top of Toon Ramp Shading,Add Gloss Fresnel and Rim Lights.
Variations for various Metals
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 6
Shader Forge
For various Reasons,Shader Forge, will be use for the Experiment
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 7
Experiment 1Faction Color
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 8
IssuesPlayer and Enemy will have Different Color Clothing.But increasing Materials or SubMesh will increase SetPass.
The Problem is, Adjusting a Material will make a Global EffectAs such, the same Material cannot be use for both Faction
Primary Solutions:Using Script to relocate Cloth’s UV to another Color’s coordinate.
Secondary Solutions: Add another Material per Faction.Add SubMesh to Model.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 9
Experiment – Relocating UVThis Script successfully allocate the 1st 50UVsTo Blue Coordinate (0.5,0.5).
The Problem is, In order for this to work,You need to know which UV Indexes are used for
the Faction Cloth Mesh.
Because there is no effective way of finding it out,Other than Trials & Errors per Model,This is really impractical.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 10
Experiment – Multiple ObjectsBy increasing the exact same objects.Batches & SetPass Calls do not get increase.
Adding another Material to same ObjectIncrease Batches & SetPass.
Adding a different Object with same MaterialIncrease Batches,But do not increase SetPass.
Therefore, it is preferable to Increase Object Count,than to Increase Material.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 11
Experiment – SubMeshThis one is an Object with a SubMesh,And Have 2 Materials assigned to it.
The Result is similar to having 2 of the same Object With different Material.
Because SubMesh is part of the same Object, It also has the issue with UV index
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 12
Conclusion
Make Faction Cloth a separate Mesh,Share the Same Material with Every Factions,
Then use Script to reallocate just the Cloth UVs.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 13
Experiment 2Multiple Shader Material
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 14
IssuesUsing Masking in ShaderForge,
Is it possible to obtain different Shadings in different Color SlotIn a Single Material?
We will try a simple Experiment,Where only Red Slot will have a different Shading.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 15
ShaderForge Test…..IT WORKED…..
This is more simple than I thought.
Basically, all I had to do is Multiply Masking
-----------------------------------------------------
In the case of very Complex Masking,
Pre-Multiply each Shading Scheme to a Mask=> Then Add everything with Add Node.
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 16
Conclusion
By Using ShaderForge Masking,There is no need to separate Metal
to a different Materials
As such, only 1 Material is needed
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 17
Experiment 3Shader Setup
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 18
Toon RampThis part of the Shader will create Toon Ramp
The Color is affected by Environmental Light
Ramp is created by Multiplying a Gradient Texture
-----------
As an alternative,
Light Color can be replace with Colored Ramp.This will reduce needed Processing Power.But the Color will no longer
be affected by Environmental Light
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 19
Metallic Toon
I cannot remember what I did any more,Let just say it worked
Rim Light
Gloss
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 20
Toon Ramp V02A Different Version,
This one Create Ramp Step from Float Value
Compare to Ramp Texture, it is faster to update,But it cannot do Smooth Shadowing on Steps.
-----------
The Process is made by Unity’s Kobayashi-SanYou can reference his shader from herehttps://www.slideshare.net/nyaakobayashi/unity-14-
shader-forge-102-shaderforge
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 21
Experiment 4Try Mass Field Units
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 22
Characters to useI am using Aoi Character Pack, from Asset Store.
It has Multiple Preset Characters with 3 LODs each.
Since each Model are from different Files,We can use each of them to represent a Model
We will try with HiRes Models first, then down to LowRes Models
10 Models were randomly selected as Base
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 23
SetupIn the case of a Single Character,FPS: 124.4Tri: 52kBatches: 22SetPass Calls: 7
After Filling in the Scene with 200 Characters,
FPS: 76.1Tri: 4.8MBatches: 2062SetPass Calls: 8
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 24
…..Try AnimatingUsing Walking Motion from Blendshape & Tails
FPS: 56.7Tri: 4.8MBatches: 2062SetPass Calls: 8
….This turned out way better than I thought…..
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 25
What else can we do?Even if I were to go for a relatively high Polycount for the Final Product,it should be no more than 5k per Model5k*200 = 1M Tri => Nearly 5times lower than what we tested.+ The Models will not be shown all at once on Screen
So, In Conclusion, there should be no Problem
With Method SelectionBut just for the sake of Science, I will try to see how many Models can I fit in to get it down lower than 30FPS
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 26
After several try,600 Characters
FPS: 24.7Tri: 12.8MBatches: 5458SetPass Calls: 8
As a Side note, this is my PC Spec
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 27
Try the OriginalTry Animating 200 Characters
w/10 Different Base Models + Original Materials
FPS: 95.8Tri: 168kBatches: 71SetPass Calls: 71
FPS: 39.6Tri: 3.3MBatches: 1401SetPass Calls: 1401
There’s a really big differenceswhen compared to using a Single Material
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 28
One Final TryOriginally, each Model has Submeshes with 4 MaterialsWe tried using one Material per Model instead
FPS: 92.5Tri: 188.6kBatches: 81SetPass Calls: 23
FPS: 39.3Tri: 3.7MBatches: 1601SetPass Calls: 441
Even if the Models do have Submeshes,Assigning them with the same Material lower it down
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 29
Final Comparison
Single Material
FPS: 56.7Tri: 4.8MBatches: 2062SetPass Calls: 8
10 Materials
FPS: 39.3Tri: 3.7MBatches: 1601SetPass Calls: 441
Original
FPS: 39.6Tri: 3.3MBatches: 1401SetPass Calls: 1401
@OtakuEatMama : @HistoricaFantasiaDevBlog : [email protected] 30
Final Conclusion
Put every character on the field like Total Wars is possible
With this Single Material Method