Jump to content

Texture UV Coordinates


thanatos247
 Share

Recommended Posts

Hi all,

 

I'm trying to create a lava flow effect, and I found a pretty simple way of doing this by using UV coordinates and shaders (http://gamedevelopment.tutsplus.com/tutorials/create-a-glowing-flowing-lava-river-using-bezier-curves-and-shaders--gamedev-919).

 

However, I cant work out if I can access / change UV coordinates in PIXI. I think by default they are set at the [0,0],[0,1],[1,1],[0,1] by TextureUvs(). I've created a shader that can manipulate the texture coordinates after they are passed into the shader, but I want to be able to set the texture UV coordinates on a sprite or similar.

 

I had a look in the forums and couldn't see anything.

 

Any help is really appreciated.

 

 

 
Link to comment
Share on other sites

We don't expose the UVs for modification really, they are setup based on the basetexture and frame. Usually what you want to do is just change the frame and let use deal with the UVs.

 

What are you trying to do that doesn't make sense to do in the frame or the shader?

Link to comment
Share on other sites

Hi. Thanks for the reply xerver - apologies for the late response, my router died!

 

I wanted to draw a series of sprites and have a lava texture "flow" across them by using UV coordinates to select a smaller part of the texture, then stitch these together like a quilt. By modifying the UV offset, you can get a moving animation with hardly any cost in game footprint (you just need one texture).

 

Looking into this a bit more, I'm not sure its possible in PIXI - I will have a rethink on how to do this.

Link to comment
Share on other sites

Hopefully the topic linked to above explains more succinctly that me (http://gamedevelopment.tutsplus.com/tutorials/create-a-glowing-flowing-lava-river-using-bezier-curves-and-shaders--gamedev-919)

 

By drawing sprites that point to subsections of a texture using UV coordinates (see image below), you can then use a shader to offset the UV coordinates to get a moving effect.

Figure%207%20-%20Texture%20Animation.jpg

Hope that makes sense.

Link to comment
Share on other sites

That article never mentions changing the UV in the CPU, and in fact says specifically that you should use the shader to do it all (specifically the vertext shader):
 

An easy way to implement this is to change the texture coordinates on the CPU and send the results to the GPU every frame. That's usually a good way to start an implementation this kind of technique, since debugging is much easier. However, we are going to dive straight into the best way we can accomplish this: animating texture coordinates using vertex shaders.


I'm like 99.999% sure you can just do this in a vertex shader and be done (which is what the article recommends anyway). The default UVs that are generated for you will contain the entire texture, then just use the vertex shader to offset and/or constrain.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...