Fast way to push textures around?[Making nice looking water]

Hey everyone! I’ve got another issue that needs fixing!

I’ve been trying to find a way to do a cheap and easy water effect for my game. I discovered that you could create a rather nice effect simply by placing two watery textures over one another and moving the top one in a particular direction.

I used the code, found on this page… … d_Textures …to do it…

smiley = loader.loadModel('smiley.egg')
lerper = NodePath('lerper')
smiley.setTexProjector(TextureStage.getDefault(), NodePath(), lerper)
i = lerper.posInterval(5, VBase3(0, 1, 0))

It looks great! But…

My problem is that it’s really slow. My frame rate drops from 60(I have vsync on) to 30 when I do that. So I get an incredible lost of performance. My PC is built to be a gaming PC with a quad core processor and a ATI Radeon HD 5750.

I don’t know a lot about messing with textures in Panda3D so if anyone could help me out here that’d be great! I’d be willing to go with a different water effect too if anyone knows of any that is relatively easy to implement.

Thanks for the help!

It doesn’t cost me any lost.

from direct.interval.LerpInterval import LerpTexOffsetInterval
smi = loader.loadModel('smiley')
newTS = TextureStage('1')

LerpTexOffsetInterval(smi, 10, (1,0),(0,0), textureStage=newTS).loop()

Try enabling the shader generator on it.

The only way is to not use shadergenerator and/or use your own shader for per pixel lightning.

It is a known issue and unfortunately wont be fixed anytime soon, sorry

I think you mean, disabling the shader generator?

It’s true that running a task that changes the state every frame is very expensive when used in conjunction with the shader generator, because it means a new shader must be compiled and generated every frame. If you have a custom shader, or if you use the fixed-function pipeline (shader generator off) on your particular node, you should have no problems.


I was talking to ynjh_jo



EDIT: i had a look at your game from your sig, Chompy. I would just disable shader generator and lightning and use water.setColorScale() instead.

I don’t mean to change the subject, but I think that was unnecessarily rude.

I didn’t mean to be rude. Maybe there is a misunderstanding? :open_mouth:

David thought I was suggesting this to Chompy, but I was suggesting this to ynjh_jo, because he said he didnt have a performance issue. And that was the reason he didn’t. Where am I rude?

Oh, I understand now. Yes, Anon, I think your meaning was unclear, and it was misperceived as curtness and therefore rudeness. Glad that’s cleared up now. :slight_smile:


Ah yes I was just about to mention that I was shining a light on the water. That really makes more sense since I already knew the lighting/shader effects were expensive.

Thanks again guys, I’ll give it a try when I get home for work!

And… I’m glad you guys cleared up your little misunderstanding. :stuck_out_tongue:

I have no idea how it was interpreted but I’m glad that I didnt get banned for such a silly thing… again :laughing:

Don’t be afraid to use shaders, this is a known “issue”.

Ah yeah indeed it was the shaders. Also what I thought was moving the textures over one another was actually the shaders making the water effect I liked! …I’m sort of not very good at being able to tell the difference apparently! :X

Though after tweaking with it some more I was able to get it to look pretty good doing the method I originally described.

With Shaders:

Without Shaders:

What? You said you moved their UVs, right? You can do that without shaders and you will get the same effect (if you didnt enable lightning, of course).
Or were you using a custom shader file?

i cant tell much difference. Only less bright.

Correct I was only moving the UV. I originally was being kind of stupid and thought I was getting the effect I was because I was moving the UV of the top texture over a lower texture but didn’t realize it was actually the shaders I was seeing making the effect.

The screenshots show it after I did some tweaking. There isn’t a huge difference now, so my original idea did work.

There isn’t a huge difference. I think you kind of see that the shaders give it more of a wavy appearance when it’s moving but other then that I think it looks pretty good either way.

So your were using your own Cg file?
Then performance shoudn’t have been an issue.

Nope I sure wasn’t. I’m not sure I’m interested in learning how to write my own shaders at the moments. I’m sure I could get some snazzy looking water effects doing that though.

Im confused, you said

What effect are we talking about here? You should have the same effect without the shader generator. Are you talking about the texture animation? I cant tell much from your images, looks like one just isnt so bright because you disabled lightning.

The shader generator changed the surface of the water somewhat, and that is all that has been disabled.

There is still a light shining on the water surface, that has not been disabled.

All I have disabled is this…


Disabling that is all I needed to get my frame rates back up. But I do see a pretty big difference and I some what liked what I saw with that on.

I have a video here that shows the difference. Maybe the you guys won’t think much of the difference I don’t know. The first part shows it without the shaders and the second part shows it with the shaders.

Oh, I could make guesses, but if you would post a sample we could guess it easier.

Possibly the texture combine mode is different? Are you moving only one texture? Try to also move the other in a different angle. Ends up nicer.

Thats all I can think of without a sample snippet.