Hello Guest

Author Topic: about uv animation  (Read 8488 times)

Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
about uv animation
« on: June 26, 2013, 02:08:42 pm »
dear any~
why i use tk2d/BlendVertexColor, but the uv animation is invalid ?
and the tk2d/LitBlendVertexColor is valid, but the image to be darken...
 :(

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: about uv animation
« Reply #1 on: June 26, 2013, 02:21:49 pm »
How is it invalid? Need more info, please.

Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: about uv animation
« Reply #2 on: June 26, 2013, 03:10:51 pm »
i try modify the Main Tex.offset.x,  is invalid...

Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: about uv animation
« Reply #3 on: June 26, 2013, 03:33:03 pm »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: about uv animation
« Reply #4 on: June 26, 2013, 06:03:39 pm »
You cant modify the material offset values in the default shaders, as that code is optimised out. Your textures may appear anywhere in the atlas, and may even be rotated and/or scaled, and as such its not very useful to offset/scale UVs. If you really need to do this, I suggest modifying the shader to add the one line required to enable this.

Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: about uv animation
« Reply #5 on: June 27, 2013, 04:12:38 am »
thank you ~
if i need, use another shader is ok ! like the Unlit/Texture.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: about uv animation
« Reply #6 on: June 27, 2013, 11:40:42 am »
Thats fine. You shouldn't use a lit shader, unless you also turn on normals on the sprite collection.

Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: about uv animation
« Reply #7 on: June 28, 2013, 03:58:38 am »
i see~ thank you

semiessessi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: about uv animation
« Reply #8 on: July 09, 2013, 04:20:09 pm »
You cant modify the material offset values in the default shaders, as that code is optimised out. Your textures may appear anywhere in the atlas, and may even be rotated and/or scaled, and as such its not very useful to offset/scale UVs. If you really need to do this, I suggest modifying the shader to add the one line required to enable this.

Can you share what this one line is?

I am interested in animating UVs in general... having done this from scratch and in several other contexts I find it surprising that there seems to be no 'easy' way to do this, nor any sort of functionality supporting this within Unity.

I am curious why the optimised shaders lock the texture offsets... unless you are using an atlas AND animating UVs or doing something else needing weird and wonderful tiling then I don't see any benefit to that since you can do all the work on CPU/VS/GS etc. depending on your target hardware, and prevent the overhead in the fragment shader from the parameter dependent operations.

Still... I'd still like to try and measure the performance when changing the offset - if it works it will work.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: about uv animation
« Reply #9 on: July 09, 2013, 04:42:32 pm »
Its just that TRANSFORM_TEX thing that needs to be put in the VS.
            o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
instead of:
                                o.texcoord = v.texcoord;

Its just not gonna work when the texture is atlased, and its not in the default shaders, as its 1 extra instruction on VS (multiply-add) and its easy to type some random numbers in there and all of a sudden all atlases don't work any more. tk2d fits textures in any way it can, and requires geometry changes most of the time.


Companella

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: about uv animation
« Reply #10 on: July 10, 2013, 03:49:47 am »
So, at this situation, use another shader is the best way.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: about uv animation
« Reply #11 on: July 10, 2013, 11:13:16 am »
Yes, if you need to animate UVs, use another shader or modify the built in one.