Showing a model with vertex painted colours in unity - unity3d

I'm trying to get a model imported into unity from blender showing the vertex colours. I have a shader(shows vertex colours) which I've applied to the model but still just plain white.
I know the shader works because I managed to get it working on another blender model, however I just don't know what the settings were used in the blender file.
Here's how I'm currently doing it:
I create a model in MagicaVoxel and is coloured. I then exported it as a .obj file.
I then import this into blender. If I switch into "texture" mode, I can see all the vertex colours on the model.
I save this blender file as just "xxx.blend".
Then in Unity, I drag the .blend file over, and it imports the model. I apply a material and the vertex paint shader to the model on the stage.
Model should start showing the vertex paint colours, but it does not. Just remains white.
Does anyone have any ideas?
Cheers

I managed to find a way to get vertex colours showing in Unity.
I needed to bake the texture into the vertex colours, to do this, with the object selected in blender, check the "vertex color paint" box under materials. (Shadeless can be checked if you don't want any shadows on the final bake)
Then switch into "vertex paint" mode (from object mode) and then in the properties under bake, check "bake to vertex colour", bake mode is "textures", then click bake.
Import blend file into Unity and apply vertex shader to see.

For other users searching a way of using vertex colors in Blender and importing into Unity WITHOUT ANY BAKING:
select a face (or vertex or all the faces) on edit mode
switch to vertex paint mode (ctrl+tab)
Click on the white square icon
next to "Vertex paint" dropdown menu on top left of the window
("PaintMak")
ctrl + K to color all its vertices, or simply select
a color with the picker available in multiple locations and paint
vertices ( top of the windows, using N-> active tool, selecting and
on right properties area "screwdriver and English key" icon = Active
tool and workspace settings). IMPORTANT: you have to paint on the vertices, painting on the face won't work.
Object material needs its "Base Color" input to be the output of the Vertex color node, so create this connection into the Shader Editor.
Save the blender file into Unity project folder or export into FBX
To display in object/edit mode colors switch view port shading to vertex (see screenshot)
On Unity create a material with a custom Shader graph with pins the output of the "Vertex color" node to the "Base color" main node.
Note: when using vertex colors Blender creates a "Col" data field into the "Object data properties" (teen triangle icon).

Related

How to apply textures to 3d models

I downloaded the 3d character model. But, the model is not applied textures. Is there a way to apply textures to models in Unity?
Or do I have to create a material myself and attach a texture to it?
I tried this method, but it was difficult when there were multiple textures. Any help would be appreciated.
When you import a 3D model into Unity, it will automatically create a material for the model and apply the textures to it.
If you are having trouble with the textures not being applied to the model, there are a few things you can try to fix the issue:
First make sure that the textures are in the same folder as the 3D model. Unity will automatically look for textures in the same folder as the model, so if the textures are in a different one, they will not be applied.
Also check the texture import settings. When you import a texture into Unity, it will automatically assign certain import settings to the texture. These settings can affect how the texture is applied to the model, so it is important to make sure they are set correctly. To do this, select the texture in the Assets window and then go to the Inspector window. In the Inspector window, you will see the texture import settings, which you can adjust as needed.
Yes, most definitely can you apply textures to models in Unity.
As you have guessed correctly, textures are applied via a Material. If you import a model, by default there will be a standard Material assigned to it. However, you can also create one yourself and assign it to the Material list of the MeshRenderer component.
Depending on the shader you choose for your Material, there will be different shader properties, including the ones for textures. Usually, there is a Albedo property which can be used to set a texture. In the editor, you can simply drag and drop your texture on to it. If you want to apply a texture at runtime, you can set the texture with yourMaterial.SetTexture(shaderTexturePropertyName e.g. _MainTex).
does the model come with the textures? If you are trying to use your own textures, it might now work because it's not properly "UV Mapped". Or it might work but it will look messy.
If the textures came with the model, then you can just drag and drop the textures into a new material then assign it to the proper mesh.
I can help you better if you can elaborate more on how you are importing your models.
You can apply mew material with variable color,
if the downloaded model is already mapped you can make your own texture map with any image editing software, though it is hard to tell whats going where, you can start with using a checkerboard to test it out.
if its not uv mapped, you need softwares that can do it, unity does not have the ability to create uvmap. 3d software like maya,blender,c4d,3dmax has the ability to create uv map, there are also specific softwares that are just for uv ,here or texturing like substance painter

Why does My (FBX) Mesh have holes when exported from blender to Unity?

I'm learning to sculpt my characters now and when I export the FBX file from Blender to Unity the Mesh has a giant hole in the face. How can I prevent/Fix this? It works just fine in mixamo.
enter image description here
enter image description here
enter image description here
Some of your faces have inverted normals. Unity interprets them as backfaces and the default material shaders cull them (don't render them).
The solution is very simple. Select all your models verticies in blender edit mode press alt+n and select recalculate outside. After that you should be able to export it and display everything correctly in Unity.

Unity PBR Shader not showing up on Sphere

I am using HDRP.
I have this PBR Shader Graph:
But the result I get is this:
The Shader is not showing up on the sphere at all.
It seems that the material of the sphere does have a shader, but it's probably one of the build-in ones. You need to assign your shader to the material the sphere is using. There are two ways that you can do that. One is to grab the shader and drop it on the material from the project tab. The second way is to select the material and on the top of the properties tab, there is a dropdown next to some Text saying "Shader". Click it and select your shader. If you want a visual representation of how to do that, you can check this video out at 6:40 (by Brackeys). If you have further question, feel free to ask.

Unity materials appear broken

I've recently imported a Unity project that references .fbx file.
When I imported the project (which was created by another user) all surfaces are pink.
Having looked at all the materials the following is observed
All the materials in the top level materials are present but are shades of grey not as the material should appear
At specific assest level (assets->material_name->material) there are no materials
All textures are present
All objects have a material associated with them which are all from the grey materials.
I can force change a material by selecting the surface and manually changing the material from its default to the one material which isn't grey "teleport" for all three surface materials.
There is a seemingly related error at the bottom "speedtree materials need to be regenerated". I've googled this however, the only solution was to select the prefab option in the assets list which is not an existing option in my project.
Any thoughts would be awesome.
CBusBus
This is a shader problem. Please note that shader is not the-same as material. You plug shader into a material. The circled image below shows a "Standard" Shader that is attached to a material named "CubeMat2".
The imported Object can be pink because:
1.The shader is missing in the Project.
Manually copy the shader into your project and re-attach it to your material.
2.The shader is obsolete or uses a keyword that's not available your current version of Unity.
Make sure you are using the-same version of Unity "another user" used to create the original project.
3.A simple import bugs. This happens somethings.
All you have to do is select the material, change the shader to another Shader then change it back to what it was before. For some reason, this seems to fix the issue.
4.There is an error in the shader. If there an error in the shader, Unity can't compile it and it will be pink when attached to a material. Also, if there is a shader error, you will see that in the Console tab. You will have to fix that error.

I'm having an issue importing textures with a 3d model into Unity

I am performing some research in virtual reality and we were given a 3d model made in Rhino5 with textures and everything (the model is a building). I have tried exporting it as a 3ds and fbx file type, but I am relatively new to both Rhino and Unity. My issue is that when I drag and drop the model into the unity assets of my project, and then drag from the assets to the scene, the model shows up and looks great, however no textures from the model in Rhino are visible.
I'm not sure if I should be exporting from Rhino to a specific format or if I'm exporting those formats incorrectly from Rhino.
I'm using Unity 4 and Rhino5. Thanks for your answers and your time!
The texture is stored in a file separately from your 3D model.
Quick steps:
Import your .obj or other 3D model into your unity3d assets
Import your .1001.png or .mtl or other texture material into your unity3D assets
Drag and drop your 3D model from assets into the unity3d scene
Click to select the object in the scene so it is outlined (mine is in orange)
Drag and drop your texture material from assets directly onto the selected object in the scene to apply the texture material giving the object your desired shading. The object will render the material with a shader. The object now has the qualities of the material and 3D model as one object in the scene.
For example here is a scene of a golf green. I have a 3D .obj file of the green which I select in the scene and then drag and drop my 2D material asset onto, which is a .1001.png file mapping the texture to the 3D surface. See link for image of the scene in my unity3d editor.
Image 1:
Unity3D object in assets. Dragged haddock.obj to get that 3D model.
Image 2: Unity3D materials in assets. Dragged haddock.1001.png onto the orange outlined model to give it that shade.
Normally models doesnt includes the textures, so you will have to import them separately into Unity and add them to the material on your model.
There might be a way to get a extra file when you export to fbx that will specify what shader and texture the materials should have when imported but i cant remember how to do that.