Flatten 3D object to create a template for a 2D texture map - unity3d

I would like to create a texture map for a 3D car model I have. I am not sure where to start. I thought maybe I could unwrap the 3D object to a 2D image and then use this as an outline to draw my texture. Is this possible, or is there a simpler solution?
Thank you in advance!

I would like to create a texture map for a 3D car model I have. I am not sure where to start
What you are asking about is called UV mapping.
"UV mapping is the 3D modeling process of projecting a 2D image to a 3D model's surface for texture mapping."
Source: https://en.wikipedia.org/wiki/UV_mapping
UV mapping is normally done when creating the model in 3d modelling software, although there may be assets in Unity able to do the same. To my knowledge Unity is not able to directly UV map.
You can however, change the texture of an object inside Unity as well as assign objects various colours and materials.
maybe I could unwrap the 3D object to a 2D image and then use this as an outline to draw my texture
To my knowledge you need 3d modelling software to do so, but yes, it is possible.
You can try to change it through scripting, but I'd recommend looking into 3d modelling software instead as I believe that if it is possible it will be bothersome.
3D modelling software I know of:
Blender - Free
Maya - Licensed
3DS Max - Licensed

Related

Unity Point-cloud to mesh with texture/color

I have a point-cloud and a rgb texture that fit together from a depth camera. I procedurally created a mesh from a selected part of the point-cloud implementing the quickhull 3D algorithm for mesh creation.
Now, somehow I need to apply the texture that I have to that mesh. Note that there can be multiple selected parts of the point-cloud thus making multiple objects that need the texture. The texture is just a basic 720p file that should be applied to the mesh material.
Basically I have to do this: https://www.andreasjakl.com/capturing-3d-point-cloud-intel-realsense-converting-mesh-meshlab/ but inside Unity. (I'm also using a RealSense camera)
I tried with a decal shader but the result is not precise. The UV map is completely twisted from the creation process, and I'm not sure how to generate a correct one.
UV and the mesh
I only have two ideas but don't really know if they'll work/how to do them.
Try to create a correct UV and then wrap the texture around somehow
Somehow bake colors to vertices and then use vertex colors to create the desired effect.
What other things could I try?
I'm working on quite a similar problem. But in my case I just want to create a complete mesh from the point cloud. Not just a quickhull, because I don't want to lose any depth information.
I'm nearly done with the mesh algorithm (just need to do some optimizations). Quite challenging now is to match the RGB camera's texture with the depth camera sensor's point cloud, because they of course have a different viewport.
Intel RealSense provides an interesting whitepaper about this problem and as far as I know the SDK corrects these different perspectives with uv mapping and provides a red/green uv map stream for your shader.
Maybe the short report can help you out. Here's the link. I'm also very interested in what you are doing. Please keep us up to date.
Regards

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.

Multiple materials or texture on low poly meshes?

I'm creating low poly environment in blender and importing it to unity. In blender I just have mesh with few materials assigned to different faces. I know two approaches to export it into unity: just export it with materials or render texture and then assign it to the object. My question is: Which option is better in case of performance?
From what I read using multiple materials is worse in case of performance(correct me if I'm wrong), but when i add texture to imported object it still shows that it uses few materials in mesh renderer. Am I importing it wrong or it should be like these?
There are screenshots of mesh renderer before and after I add texture:
Multiple materials are performance killing. But if your game is very tiny, these are not much on an issue. Not suggested anyways.
When exporting with single texture, remember deleting additional materials in blender. Or you can set the value of Size under Materials to 1. That case it will remove the materials keeping the first one or you can set the textured one there and remove others as well.

Shader-coding: nonlinear projection models

As I understand it, the standard projection model places an imaginary grid in front of the camera, and for each triangle in the scene, determines which 3 pixels its 3 corners project onto. The color is determined for each of these points, and the fragment shader fills in the rest using interpolation.
My question is this: is it possible to gain control over this projection model? For example, create my own custom distorted uv-grid? Or even just supply my own algorithm:
xyPixelPos_for_Vector3( Vector3 v ) {...}
I'm working in Unity3D, so I think that limits me to cG or openGL.
I did once write a GLES2 shader, but I don't remember ever performing any kind of "ray hits quad" type test to resolve the pixel position of a particular 3D point in space.
I'm going to assume that you want to render 3d images based upon 3d primitives that are defined by vertices. This is not the only way to render images with OpenGL but it is the most common. The technique that you describe sounds much more like Ray-Tracing.
How OpenGL Typically Works:
I wouldn't say that OpenGL creates an imaginary grid. Instead, what it does is take the positions of each of your vertices, and converts them into a different space using linear algebra (Matrices).
If you want to start playing around with this, it would be best to do some reading on Matrices, to understand what the graphics card is doing.
You can easily start warping the positions of Vertices by making a vertex shader. However, there is some setup involved. See the Lighthouse tutorials (http://www.lighthouse3d.com/tutorials/glsl-tutorial/hello-world-in-glsl/) to get started with that! You will also want to read their tutorials on lighting (http://www.lighthouse3d.com/tutorials/glsl-tutorial/lighting/), to create a fully functioning vertex shader which includes a lighting model.
Thankfully, once the shader is set up, you can distort your entire scene to your hearts content. Just remember to do your distortions in the right 'space'. World coordinates are much different than eye coordinates!

Put a Cinema 4D model and Texture into an iPhone App

Im an iPhone developer and i'm trying to get a 3D model that I create in Cinema 4D into an app im making. I have actually found a way to get the model in (by exporting it as a .dae or obj and using a python script) which works really well however I can't get the textures to come with it. My script actually can only handle 1 texture as well.
Basically I need to ether create and export a UV map in c4d (but I have no idea how to do this) or I figure out a way to read multiple textures into my Open Gl - ES app with a script or PowerVR. (this is probably better)
Sorry for the noob questions but im very new at the 3D world.
Cheers
I would recommend that you use Blender. Export your Cinema-4D model for Blender and use Blender to create UVMaps.
You need to make seams and unwrap the model. After that save a targa template for your texture, apply your texture on that targa. Save it as png or jpg. Apply that texture image to your model in Blender. Now you can export Wavefront OBJ file.
Use OpenGLOBJLoader class to render your model in iPhone.
And one more thing: you should invert (subtract from 1) texture coordinates on y axis in order to get your texture rendered properly.
For example, if you have texture coordinates like this:
vt 0.800008 0.400000
vt 0.800008 0.150000
...
make sure that you have them inverted like this:
vt 0.800008 0.600000
vt 0.800008 0.850000
...