thanatos247 Posted May 7, 2015 Share Posted May 7, 2015 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. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 7, 2015 Share Posted May 7, 2015 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? Quote Link to comment Share on other sites More sharing options...
thanatos247 Posted May 14, 2015 Author Share Posted May 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 14, 2015 Share Posted May 14, 2015 I guess what I am not sure about is why you need to modify UVs in the CPU code and you can't just do this in a shader? Quote Link to comment Share on other sites More sharing options...
thanatos247 Posted May 14, 2015 Author Share Posted May 14, 2015 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.Hope that makes sense. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 14, 2015 Share Posted May 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.