- Home /
Adding texture to vertex ,I don't want to apply texture each vertex
I am using exactly the same code from this website https://catlikecoding.com/unity/tutorials/rounded-cube/ and I don't want to apply texture to EACH vertex I want to apply texture that covers the ENTRIE cube, not each vertex. Right now a grid image is applied to each vertex. I don't know how to fix the shader...
this is the code for shader
Shader "Custom/Rounded Cube Grid" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
[KeywordEnum(X, Y, Z)] _Faces ("Faces", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
//#pragma shader_feature _FACES_X _FACES_Y _FACES_Z
#pragma surface surf Standard fullforwardshadows vertex:vert
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 cubeUV;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
void vert (inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
o.cubeUV = v.color.xyz;
#if defined(_FACES_X)
o.cubeUV = v.color.yz * 255;
#elif defined(_FACES_Y)
o.cubeUV = v.color.xz * 255;
#elif defined(_FACES_Z)
o.cubeUV = v.color.xy * 255;
#endif
}
void surf (Input IN, inout SurfaceOutputStandard o) {
*fixed4 c = tex2D (_MainTex, IN.cubeUV) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
screen-shot-2018-12-02-at-55232-pm.png
(147.2 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612183213im_/https://answers.unity.com/themes/thub/images/avi.jpg)