Search Unity

How to enable TEXCOORD4-5 in vetex shader?

Discussion in 'Shaders' started by dreamerflyer, Jul 27, 2016.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Code (CSharp):
    1.  struct Vertex
    2. {
    3.      half4 pos : POSITION;
    4.     half2  tc_Control : TEXCOORD0;    // Not prefixing '_Contorl' with 'uv' allows a tighter packing of interpolators, which is necessary to support directional lightmap.
    5.      
    6.     half2 uv_Splat0 : TEXCOORD2;
    7.     half2 uv_Splat1 : TEXCOORD3;
    8.     half2 uv_Splat2 : TEXCOORD4;
    9.     half2 texcoord3 : TEXCOORD5;
    10.  
    11.   //  #ifdef LIGHMAP_ON
    12.    half2 uv_lightmap : TEXCOORD1;
    13.   //  #endif
    14.  
    15. };
    ,hi all ,TEXCOORD4 and TEXCOORD5 not work,what's wrong?
     
  2. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Nobody met this problem?
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Not sure what problem you're seeing. Some of my shaders have used TEXCOORD0 through TEXCOORD10 without an issue. Is this a surface shader or a vertex fragment shader? If it's a surface shader it won't work because those are the TEXCOORD# from the mesh data itself, in which case Unity only has up to TEXCOORD3 as valid data. If it's a vertex fragment shader you have to fill out that data in the vertex shader.
     
  4. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    thanks a lot ! I use vertex fragment ,and fill out all the data in the vertex shader,and have no error show....and using shader model 3.0.
     
    Last edited: Jul 28, 2016
  5. Aruto613

    Aruto613

    Joined:
    Dec 5, 2012
    Posts:
    1
    I have the same question. But I don't figure out the "fill out" mean.
    Could you explain how to fill out that data ?
    Thank you !
     
  6. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    fill out means assign value.
     
  7. paulorenan

    paulorenan

    Joined:
    Aug 31, 2017
    Posts:
    2
    Unity 2018.1.6 did not have uv channels 5, 6, 7 and 8
    I updated to 2018.2.2 and all works great.

    Shader side:
    Code (CSharp):
    1. struct appdata
    2.         {
    3.             float4 vertex    : POSITION;  // The vertex position in model space.
    4.             float3 normal    : NORMAL;    // The vertex normal in model space.
    5.             float4 texcoord  : TEXCOORD0; // The first UV coordinate.
    6.             float4 texcoord1 : TEXCOORD1; // The second UV coordinate.
    7.             float4 texcoord2 : TEXCOORD2; // The third UV coordinate.
    8.             float4 texcoord3 : TEXCOORD3; // The fourfth UV coordinate.
    9.             float4 texcoord4 : TEXCOORD4; // The fifth UV coordinate. // requires Unity 2018.2+
    10.             float4 texcoord5 : TEXCOORD5; // The sixth UV coordinate. // requires Unity 2018.2+
    11.             //float4 texcoord6 : TEXCOORD6; // The seventh UV coordinate. // requires Unity 2018.2+
    12.             //float4 texcoord7 : TEXCOORD7; // The eigthieth UV coordinate. // requires Unity 2018.2+ // maximum amount of channels supported
    13.             float4 tangent   : TANGENT;   // The tangent vector in Model Space (used for normal mapping).
    14.             float4 color     : COLOR;     // Per-vertex color
    15.         };
    Code (CSharp):
    1. void vert(inout appdata v, out Input o) {
    2.             UNITY_INITIALIZE_OUTPUT(Input, o);
    3.            
    4.             o.uv_MainTex = v.texcoord.xy;
    5.  
    6.             o.MyCustomThing1 = v.texcoord3.x - frac(v.texcoord3.x);
    7.             o.MyCustomThing2 = frac(v.texcoord3.x);
    8.         }
    Code (CSharp):
    1. struct Input {
    2.             float2 uv_MainTex;
    3.             float MyCustomThing1;
    4.             float MyCustomThing2;
    5. }
    Code (CSharp):
    1. void surf(Input IN, inout SurfaceOutputStandard o) {
    2.            
    3.             float x1 = IN.MyCustomThing1;
    4.             float x2 = IN.MyCustomThing2;
    5. }
     
  8. canyon_gyh

    canyon_gyh

    Joined:
    Aug 15, 2018
    Posts:
    48
    thanks,,i think:
    textcoord = uv = mesh
    so,textcoord1 == submesh0???