Uv Mapping Unity

Active1 year, 9 months ago

I want to map a 2D Texture onto a procedurally generated plane, using vertex local position, in Unity. This is the code:

I don't understand why, but this makes the plane's color uniform.The only option I can use is _Offset, that changes the color of the entire plane. I think (IN.uv_MainTex.x * _Scale.x, IN.uv_MainTex.y * _Scale.y) it's always zero, but I don't understand why.

UV Mapping in Blender for Unity 01 Jul 2017. Just learned how to do UV mapping in Blender, and thought I should write it down before I forget. Currently, I’m doing the Learn 3D Modelling course at Udemy. Building a Blocky Procedural Mesh in Unity 5 Part 2: UV Mapping of Textures - Duration: 34:18. Holistic3d 22,432 views. 5 Steps To Start Making Games - Duration: 24:09.

Please help me understanding what I'm doing wrong

GuguGugu

1 Answer

Check https://docs.unity3d.com/Manual/SL-SurfaceShaders.html under 'Surface Shader input structure'

uv_MainTex is automatically generated, so setting it manually might create some problems. You might want to use another custom name in your input struct.

Side note: you should do all your arithmetic in the vertex shader, since they are all linear transformations anyway.

Brice V.Brice V.

Not the answer you're looking for? Browse other questions tagged unity3dtexturesshaderprocedural-generationuv-mapping or ask your own question.

Active1 year, 6 months ago
$begingroup$

I want to create a game with a Minecraft style world. Now I need uv mapping for some cubes in my game. But I could not find any good tutorial in the internet. I want to use the following texture with an uv map:

Each side of the cube has a texture with 64x64 pixels. The dirt texture on the right side has to be the top of the cube.Can anyone tell me how to use uv mapping in my case?

Maya Uv Mapping Tutorial

David RotertDavid Rotert
$endgroup$Blender uv mapping unity

1 Answer

Unity overlapping uvs$begingroup$

You can specify UV coordinates in Unity: https://docs.unity3d.com/ScriptReference/Mesh-uv.html

The UV coordinates go from 0 to 1, and the index in the uv array corresponds the the vertex with the matching index in the vertices array. This Unity Answers post may prove useful. It lists the vertices in Unity's cube primitive. The top face is first in the vertices, so you would map the uvs of the top face in the first four indices of the uv array like this:

I'll leave it to you to figure out the rest of the faces. Of course, assigning the uvs in a script would be more ideal only if you are generating content at runtime, so making your own mesh in a program like blender would be more ideal ... or you could make a script that runs in the Editor to create a new mesh for you based on the cube primitive. You can do this using the AssetDatabase interface.

Uv Mapping Unity System

tyjkenntyjkenn

Unity Mesh Uv

$endgroup$

Blender Uv Mapping Unity

Not the answer you're looking for? Browse other questions tagged unityuv-mapping or ask your own question.

Comments are closed.