[SOLVED] Possible animation bug?


27-11-2007 17:46:52


I have not delved deep into the code right now, but I notice this:

1) enter scene, enable animation and grass waves nicely..
2) exit scene (destroying scenemanager etc) and re-enter. This is done without exiting the application.
3) now the grass is not waving smoothly as b4.

I am not sure this is a problem with my code or forest addon, but I just want to let you know. Maybe others had encountered the same problem, so this thread will be useful. I will do more investigation in a week or so (this is not a critical bug) and will let you know of any outcome :)


28-11-2007 00:19:22

Ok, I'll test this next time I get a chance and see if I can reproduce.

BTW, sorry about the delay on evaluating all these bug/issue reports - I've been sick since last Friday so I haven't been able to get much work done on this project.


28-11-2007 11:05:23

No problem JohnJ, your support is already awesome.

Get well soon. :)


28-11-2007 23:47:17

I've encountered another animation bug (probably not related to this but still under the same topic) while I was playing around with the GrassLoader example.

I added a new layer of grass:
GrassLayer *l2 = grassLoader->addLayer("grass");
l2->setMinimumSize(1.5f, 0.5f);
l2->setMaximumSize(2.0f, 1.0f);
l2->setDensity(5.5f); //Relatively dense grass
l2->setFadeTechnique(FADETECH_GROW); //Distant grass should slowly raise out of the ground when coming in range
l2->setMapBounds(TBounds(0, 0, 1500, 1500)); //(0,0)-(1500,1500) is the full boundaries of the terrain

As you see I disable animation for this second, denser, layer of grass. The problem arises (I think) when Ogre tries to animate for the first time. One frame is rendered before an error-dialogue appears and stops everything. The following is dumped into the Ogre.log:
00:23:42: OGRE EXCEPTION(2:InvalidParametersException): Parameter called time does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 868)
Since the grass-layer "l2" isn't supposed to animate it shouldn't have a "time"-variable at all in the shader code as far as I could see.

Instead of turning off animations I tried lower values on the three animation-parameters, which worked fine. Except that now the first grass layer also seemed to use these new, lower, values in "l2" (effectively slowing down it's animation aswell).

Probably I've just misunderstood the concept of grass layers or missed a declaration somewhere, but I though I might aswell share my discovery in case it could help.


29-11-2007 03:34:53

Thanks for reporting that planders, that's definitely a bug. Try the CVS, it should be fixed now.

syedhs: I'm almost over my cold now, so I spent some time tonight solving these problems, but before I did I finished up the "camera facing grass billboard" feature (GRASSTECH_SPRITE). The latest GrassLoader version is up in CVS, so you can try it out now without waiting for v1.1 :)

The grass problems mentioned by planders were due to the fact that the GrassLoader shader manager only replaced the specified material's shader with the appropriate one, it didn't clone the material first. This caused conflicts when you had two layers with the same material; the differing animation / rendering properties resulted in two shaders "fighting" over the same material.

This fix probably won't fix the unsmooth grass animations though, since I haven't started reproducing/debugging that yet, but I probably will next.

P.S. GrassLayer::updateAnimation() no longer exists in the latest version of the grass system, so you don't have to bother calling it anymore. I removed it in favor of PageLoader::frameUpdate() (which is called now by PagedGeometry every frame), when an early implementation of the camera-aligned grass required the shaders to be updated just like animations. The current camera-aligned grass doesn't require special shader parameters any more, but I decided to keep updateAnimation() out anyway; it's a little more convenient when you can call grassPagedGeometry->update() and not have to worry about anything else.


29-11-2007 08:30:43

syedhs: I'm almost over my cold now, so I spent some time tonight solving these problems, but before I did I finished up the "camera facing grass billboard" feature (GRASSTECH_SPRITE). The latest GrassLoader version is up in CVS, so you can try it out now without waiting for v1.1 :)

Wohoo.. i just downloaded CVS but when I tried GRASSTECH_SPRITE, all the grasses dissappear - I have no idea why. I just add this to my grass loader initialization:-


Is there any other code needed to add?

Edit: I found that GRASSTECH_CROSSQUADS looks good too - why I didn't notice this :?


29-11-2007 15:33:09

"grassLayer->setRenderTechnique(GRASSTECH_SPRITE);" should be all you need to enable it. I'm not sure why it doesn't work for you, it works fine in Example 4. I'll do some more testing and try to find what's wrong.


29-11-2007 15:45:32

Thanks for the quick reply!

I'll try out the CVS version now, great work! :)

Edit: Works great!


29-11-2007 17:23:06

syedhs: Try the CVS again, it should work now :)

One thing I like about GRASSTECH_SPRITE grass is that it seems to look surprisingly good even with extremely low grass density. It often looks even better than GRASSTECH_CROSSQUADS (which uses twice the polygons GRASSTECH_SPRITE or GRASSTECH_QUAD does, although sprite mode does use a more complex vertex shader).


01-12-2007 00:08:55

syedhs: Try the CVS now, your original grass animation bug should now be fixed :)

I also found and fixed a fairly important bug in the grass system where recreating wouldn't delete the old grass scene nodes, which resulted in slower and slower performance each time the scene was reloaded.

All the examples now let you press "R" to reload the whole scene, so I was able to extensively test that everything now works fine when deleting and recreating PagedGeometry.


01-12-2007 04:54:03

Sorry for being late, it turns out that the developer is faster than me, the reporter :wink:


Happy to report that it now works great! Re-entering the scene doesn't exhibit the non-smooth wavy grass as before. :)