Author Topic: Eye Advanced Multi lattice IrisColorTex  (Read 2632 times)

jaleco

  • Newbie
  • *
  • Posts: 2
    • View Profile
Eye Advanced Multi lattice IrisColorTex
« on: May 06, 2018, 08:33:38 AM »
Hello Chingwa:
        I have purchase Eye Advanced in Unity Asset Store,It is Very useful。
But when I use it in ours game develop, Artist need change _IrisColorTex by _irisIndex,So I only change IrisColorTex to 4X4 16IrisMap In RGB and Alpha,

   //CALCULATE IRIS TEXTURE
   half iSize = _irisSize * 0.6;
   float2 irUVc = IN.uv_MainTex;
   irUVc = float2((IN.uv_MainTex.x*iSize) - ((iSize - 1.0) / 2.0), ((IN.uv_MainTex.y)*iSize) - ((iSize - 1.0) / 2.0));
   uint _eyeIndex = uint(_irisIndex);
   float2 iris_16_uv;
   iris_16_uv.x = (irUV.x + uint(_eyeIndex % 4)) * 0.25;
   iris_16_uv.y = (irUV.y + uint(_eyeIndex / 4)) * 0.25;
   //It seam correct at here

   _pupilSize = lerp(lerp(0.5, 0.2, iSize / 5), lerp(1.2, 0.75, iSize / 5), _pupilSize);
   irUVc = (irUVc*((-1.0 + (uvMask*_pupilSize))) - (0.5*(uvMask*_pupilSize)));//It need preserve for other tex coordinate

   //I donot know how to adjust this
   iris_16_uv = (iris_16_uv *((-1.0 + (uvMask*_pupilSize))) - (0.5*(uvMask*_pupilSize)));
   
        //get iris and pupil texture
   half4 irisColTex = tex2D(_IrisColorTex, iris_16_uv -offset);
        .................................................
   irisoffsettex = tex2D(_IrisColorTex, iris_16_uv -offset2).a;
       

please help.

                                                                                                               

thanks/
« Last Edit: May 07, 2018, 02:33:39 AM by jaleco »

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1704
    • View Profile
    • Tanuki Digital
Re: Eye Advanced Multi lattice IrisColorTex
« Reply #1 on: May 06, 2018, 09:31:29 AM »
I'm not sure I understand what you are trying to do... do you mean you are trying to use a custom texture that has 16 iris options in a 4x4 grid?  IF that is the case you would need to divide and offset the UV coordinates based on the part of the texture you are trying to read from.  I'm not sure I can help you with that, unfortunately.

What might be easier is to pass the shader a TextureArray that includes all of your iris textures, then you can sample the texture array using the normal UV coordinates and offset, and would only need to adjust the 'z' index of the uvs in order to sample different textures.

jaleco

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Eye Advanced Multi lattice IrisColorTex
« Reply #2 on: May 07, 2018, 02:41:19 AM »
Thanks Chingwa,It does work, And later try use one texture calculate UV when I have free time.

thanks again