What exactly is static mesh component in Unreal Engine? - unreal-engine4

I have recently started learning Unreal Engine as a complete beginner, and I got stuck on this thing called static mesh component.
Is it ok to assume that this components decides the shape of the actor that the component is on?

A mesh is a collection of vertices, edges, and faces that describe the shape of a 3D object.
In Unreal Engine you have static and skeletal meshes.
Static meshes are the simpler, for example you would use a static mesh for a chair or any other inanimate object.
Skeletal meshes are intended for more complex objects, for example for characters. They have a set of interconnected bones (skeleton) that you can use to animate the model.

As a dumb way of putting this:
Static Mesh Component is the actual figure of a thing. It also cannot be animated. Skeletal Mesh Components can be animated.
As an extension, there are Geometry Brushes which can be created before even using static meshes for level design. They should not be in the final design tho, you can upgrade them to static meshes.
"Geometry Brushes are the most basic tool for level construction in Unreal. Conceptually, it is best to think of a Geometry Brush as filling in and carving out volumes of space in your level. Previously, Geometry Brushes were used as the primary building block in level design. Now, however, that role has been passed on to Static Meshes, which are far more efficient. "
https://docs.unrealengine.com/4.27/en-US/Basics/Actors/Brushes/

Related

Is there a scalable way to use mesh volumes in Unity such that fragments drawn within them use a different shader path?

I want to include invisible geometry in my scene which, for all portions of a mesh within the geometry, one texture/shading path on their shader/material is used, blending to portions of the geometry NOT within the invisible volume using a different texture/shading path.
Concretely, what I'm trying to build is an environment where certain regions are "normal colored" and anything outside those regions uses a drab/gray/cracked appearance.
I know I could add (especially algorithmic) volumes as parameters to a shader (treated similarly to lights, I suppose), but that could get fairly intensive fairly quickly if I end up with many volumes hitting any given mesh, not to mention the overhead of checking objects for intersection with each volume.
Currently I'm using URP forward rendering in Unity 2020.3.28f1.

Why in 3D game we need to separate a material into so many textures for a static object?

Perhaps the question is not that correct, the textures should be say a kind of channel? although I know they will be mixed in the shader finally.
I know the knowledge of the various textures is very important, but also a bit hard to understand completely.
From my understanding:
diffuse - the 'real' color of an object without light involved.
light - for static objects. render light effections into texture beforehand.
specular - the area where has direct reflection.
ao - to absorb indirect light for the different area of an object.
alpha - to 'shape' the object.
emissive - self illuminance.
normal - pixel normal vector to deal with the light ray.
bump - (dont' know the exact differences between normalmap).
height - stores Z range values, to generate terrain, modify vertex etc.
And the items below should be related to PBR material which I'm not familiar with:
translucency / cavity / metalness / roughness etc...
Please correct me if some misunderstandings there.
But whatever, my question is why we need to separate these textures apart for a material but not only render them together into the diffusemap directly for a static object?
It'll be appreciated if some examples (especially for PBR) , and thank you very much.
I can beforehand bake all things into the diffuse map and apply to my
mesh, why I need to apply so many different textures?
Re-usability:
Most games re-use textures to reduce the size of the game. You can't if you combine them together. For example, when you two similar objects but you want to randomize the looks of them(aging effect), you can make them share the-same color(albedo) map but use different ao map. This becomes important when there hundreds of objects, you can use different combination of texture maps on similar objects to create unique Objects. If you have combined this into one, it would be impossible to share it with other similar objects but you to slightly make to look different.
Customize-able:
If you separate them, you'll be able to change the amount of effect each texture will apply to the Object. For example, the slider on the metallic slot for the Standard shader. There are more of this sliders on other map slots but they only appear once you plug a texture into the slot. You can't do this when you combine the textures into one.
Shader:
The standard shader can't do this so you have to learn how to write shader since you can't use one image to get the effects you would with all those texture maps with the standard shader. A custom shader is required and you need a way to read the information about the maps in the combined shader.
This seems like a reasonable place to start:
https://en.wikipedia.org/wiki/Texture_mapping
A texture map is an image applied (mapped) to the surface of a shape or polygon. This may be a bitmap image or a procedural texture. They may be stored in common image file formats, referenced by 3d model formats or material definitions, and assembled into resource bundles.
I would add to this that the shape or a polygon don't have to belong to 3d objects as one may imagine it. If you render two triangles as a rectangle, you can run all sorts of computations and store it in a "live" texture.
Texture mapping is a method for defining high frequency detail, surface texture, or color information on a computer-generated graphic or 3D model. Its application to 3D graphics was pioneered by Edwin Catmull in 1974.
What this detail represents is either some agreed upon format to represent some property, (say "roughness" within some BRDF model) which you would encounter if you are using some kind of an engine.
Or whatever you decide that detail to be, if you are writing your own engine. You can decide to store whatever you want, however you want it.
You'll notice on the link that different "mapping" techniques are mentioned, each with their own page. This is the result of some person, or people who did some research and came up with a paper detailing the technique. Other people adopt it, and that's how they find their way into engines.
There is no rule saying these can't be combined.

Paint on mesh for makeover

I'm now struggling for weeks on a part of the game I'm making.
As a beginner in Unity and programming, I need your experience and advice to understand how can I paint on skinned mesh like this (from 1:10):
https://www.youtube.com/watch?v=grVEK1Bb6ZM
I spend a lot of time to find a solution with no result. (Decal shader to separate texture, paint on mesh with alpha, project texture, merge texture .. ). But these solutions look bad for mobile or not exactly what I need.
So If someone know a way to do that, even a little info or anything, that will drive my research, it's very welcome.
Thank you !
The example you provide limits the range of the painting with a bitmap mask (ie on the eyebrows, or on the lips), so the painting is only meant for a more enjoyable UX. If this is what you need, you should probably do something like this:
You need to know where the mouse is interacting with the model. Raycasting is expensive and requires to update the colliders every frame, since you character is skinned. If you use the masking trick of your example, this dramatically reduces the amount of computation, since you could pass a subset of the mesh containing only that specific area (maybe just the face for ex)
see https://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer.BakeMesh.html
and https://answers.unity.com/questions/39490/collider-on-skinned-mesh.html
(if you can't, there could be other tricks, like rendering the character's UV into a separate float buffer/texture, and sample that buffer using the mouse position)
Once you can raycast the mesh you can fetch the UV position of the hit
https://docs.unity3d.com/ScriptReference/RaycastHit-textureCoord.html
Using those UVs you can write to a texture, or instance particles/objects on a render target etc (there are many options here).
You then need to combine that texture with the bitmap mask in the shader of the character.

How to bake static Unit scene into one big mesh and texture

I have a big complex unity scene including terrain, trees, grass, flowers and many other objects.
I'm having performance problems and i was wondering if its possible to bake all static objects that never move or change like terrain trees, houses, and other props etc, into one big static object to increase performance?
Thanks
Check out the Unity documentation on Static Objects here.
Many optimisations need to know if an object can move during gameplay. Information about a Static (ie, non-moving) object can often be precomputed in the editor in the knowledge that it will not be invalidated by a change in the object’s position. For example, rendering can be optimised by combining several static objects into a single, large object known as a batch.
To mark a GameObject as static, you simply need to check the Static box in the inspector window with the desired GameObject selected.
That wouldn't be a good idea. Having separate meshes is much more beneficial and efficient than combining them all into one huge mesh. This will allow you to set different LOD systems for the objects, billboarding of trees and detail objects, and will allow for finer control over your scene without having to rebuild that huge object again and again.
For large scenes, it is important that you set up a Level Of Detail (LOD) system. What it essentially means is that based on the distance of the object from the camera, a higher or lower quality model of that object will be rendered. At close distances, the highest polygon model will be rendered. At huge distances where detail is not required, lower polygon count models can be used. Consult the Unity Manual for more details. You can also look for scripts and tutorials on the internet.
Also, make sure that your terrain settings are reasonable. Setting the Pixel Error of the terrain to 1 is overkill, something like 4-5 is more than enough. Detail Density, Billboard Start, Detail and Tree Distance all these can be toned down.
Or just check for an unoptimized script or shader gone awry, that's usually the problem. Unoptimized 3d models are hell too. You'll have to do more than just pick up a model from Sketchup's 3D warehouse (speaking from personal experience). You will have to pay an artist to get high quality, optimized models with their LOD meshes also unless you have the skills yourself.

Tile Grid Data storage for 3D Space in Unity

This question is (mostly) game engine independent but I have been unable to find a good answer.
I'm creating a turn-based tile game in 3D space using Unity. The levels will have slopes, occasional non-planar geometry, depressions, tunnels, stairs etc. Each level is static/handcrafted so tiles should never move. I need a good way to keep track of tile-specific variables for static levels and i'd like to verify if my approaches make sense.
My ideas are:
Create 2 Meshes - 1 is the complex game world, the second is a reference mesh overlay that will have minimal geometry; it will not be rendered and will only be used for the tiles. I would then Overlay the two and use the 2nd mesh as a grid reference.
Hard-code the tiles for each level. While tedious it will work as a brute force approach. I would, however, like to avoid this since it's not very easy to deal with visually.
Workaround approach - Convert the 3d to 2D textures and only use 1 mesh.
"Project" a plane down onto the level and record height/slope to minimize complexity. Also not ideal.
Create individual tile objects for each tile manually (non-rendered). Easiest solution i could think of.
Now for the Unity3D specific question:
Does unity allow selecting and assigning individual Verts/Triangles/Squares of a mesh and adding componenets, scripts, or variables to those selections; for example, selecting 1 square in the 10x10 unity plane and telling unity the square of that plane now has a new boolean attached to it? This question mostly refers to idea #1 above, where i would use a reference mesh for positional and variable information that were directly assigned to the mesh. I have a feeling that if i do choose to have a reference mesh, i'd need to have the tiles be individual objects, snap them in place using the reference, then attach relevant scripts to those tiles.
I have found a ton of excellent resources (like http://www-cs-students.stanford.edu/~amitp/gameprog.html) on tile generation (mostly procedural), i'm a bit stuck on the basics due to being new to unity and im not looking for procedural design.