Search Unity

Tesselation: invalid subscript 'texcoord2' at line

Discussion in 'Shaders' started by Smartwater3D, Nov 28, 2014.

  1. Smartwater3D

    Smartwater3D

    Joined:
    May 16, 2014
    Posts:
    64
    I am playing with the Tesselation and I have a problem when using any of the example with a vertex shader that is using appdata_full

    I need to use appdata_full in my vertex shader, and so I also need to use it for the Tesselation like this:

    Code (Shader):
    1.  
    2. float4 tessEdge (appdata_full v0, appdata_full v1, appdata_full v2)
    3. {
    4.     return UnityEdgeLengthBasedTessCull (v0.vertex, v1.vertex, v2.vertex, _EdgeLength, 0.0);
    5. }
    6.  
    7.  
    But at this stage , the compiler is shooting this error.

    invalid subscript 'texcoord2' at line 416

    The line 416 is the end of the shader. My question is why is there an incompatibility with Tesselation at this stage?
     
    Last edited: Nov 28, 2014
  2. Smartwater3D

    Smartwater3D

    Joined:
    May 16, 2014
    Posts:
    64
    After digging, it seems that it is not possible to transmit the struct "Input" to the vertex shader anymore.

    If I load the DirectX 11 tesselation projects and I try to change

    void disp (inout appdata v)

    with void disp (inout appdata v, out Input o)

    for example (let's say I want to change the normals for the surface shader for example.
    I get a bunch of syntax errors all over the place.

    Also I see that in none of the example there, the vertex shader is changing the Input structure.
    What is wrong here?

    If I want for example do

    Code (Shader):
    1.  
    2. struct Input {
    3.     float2 uv_MainTex;
    4.     float2 uv_BumpMap;
    5.     float4  bumpTexCoord;
    6.     float4  objSpaceNormal;
    7. };
    8. //and
    9. void disp (inout appdata v, out Input o)
    10. {
    11.     // save variables
    12.     o.bumpTexCoord=float4(0,0,0,0);
    13.     o.objSpaceNormal=float4(0,0,0,0);
    14. }
    15.  
    16.  
    it won't compile? Why?
     
  3. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    same problem here
    why it not compile?
     
  4. Plutoman

    Plutoman

    Joined:
    May 24, 2013
    Posts:
    257
    You either have to use the default surface shader parameters, or you have to write a hull/domain shader. A surface shader is not a true shader, it is generated into a shader. The surface shader cannot generate a proper tessellation shader with the generic parameters, so you have to write it yourself.