RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
990 stars 175 forks source link

More grass layers do grass blades in same places. #3128

Closed cryham closed 1 month ago

cryham commented 4 months ago

Having more grass layers in .tobj creates grass blades in same places. Looks odd and due to grass sway they switch between each other. Very long ago we were fixing such issues in PagedGeom, maybe something useful is in our PagedGeom code in old Stunt Rally. I don't remember where, but surely randomness (also grass placing) is bad in PagedGeom, and it needs to not reset seed for each grass layer. Or set seed to random from time.

0451e` 0456e` 0457e`

cryham commented 4 months ago

I found out where I fixed it in PagedGeom. https://github.com/stuntrally/stuntrally/blob/master/source/paged-geom/GrassLoader.cpp#L130 Main part here:

    void GrassLoader::loadPage(PageInfo &page)
    {
        //Generate meshes
        bool first = true;  ///T

        std::list<GrassLayer*>::iterator it;
        for (it = layerList.begin(); it != layerList.end(); ++it)
        {   GrassLayer *layer = *it;

            if (first)  ///T once for all layers
                layer->parent->rTable->resetRandomIndex();
            first = false;

We have PagedGeom sources inside old SR, this is an older fork of it. My changes are marked with ///T, could be useful to check them all.

Probably all those later are needed to fix this too: commenting out: //parent->rTable->resetRandomIndex(); so: https://github.com/stuntrally/stuntrally/blob/master/source/paged-geom/GrassLoader.cpp#L868 https://github.com/stuntrally/stuntrally/blob/master/source/paged-geom/GrassLoader.cpp#L936 https://github.com/stuntrally/stuntrally/blob/master/source/paged-geom/GrassLoader.cpp#L1009

ohlidalp commented 4 months ago

To be honest, I think the PaGeom grass is ugly and unoptimal either way. PaGeom itself is weird: -"trees" really means custom meshes of any kind- but it only makes sense if they use same mat which isn't really emphasized in doc. -"grass" is this ugly hardcoded 2 polys crossed. So 90's. Today even potato chip handles more polys as long as they're one draw call. -recently I coded a scene inspector and noticed PaGeom inserts and shuffles thousands of scene nodes. I haven't investigated further but I got the impression each grass clump is an entity which feels horrific.

Personally I'd rather dump Paged grass altogether and used the #3030 feats to generate more detailed grass in bigger batches, possibly using the shell texturing trick or combined

cryham commented 4 months ago

Sure, I agree PagedGeom is the worst now. But this is a quick fix for current issue. Is the new system for grass something that will happen soon? If so I'll wait. If not then I'd say this is worth fixing. I'm also confused if there is any roadmap or release timeline for all these PRs with improvements etc?

ohlidalp commented 4 months ago

The new system for grass will come as side effect of #3030 that I keep pointing you to :) I'm intensively focusing on that and it will be done at the end of February latest, though probably earlier.

Though yes, a quick fix for the PagedGrass would be good. But we have paged sources outside of our tree: https://github.com/RigsOfRods/rigs-of-rods/blob/master/conanfile.py#L20 and IIRC the Loader system was somewhat modular, so maybe the way to go is to create custom loader with these updates.

I'm sure the community would appreciate a roadmap but I was never able to follow one, I get incredibly frustrated fixing the minor glitches that bother players and I escape to more fundamental things that the community hardly cares about. But most importantly, I'm the only dev around who's able to look at the codebase hollisitically, others just do narrow (though major in gameplay/quality-of-life gain) features.

cryham commented 4 months ago

Ah okay. Yeah there is so much stuff in #3030 that I didn't expect grass there too :) Okay I'll wait for that, will be easier. I'm not keen with dependencies. It seems like I'd need to submit patch for official paged-geom and then AnotherFoxGuy would need to update script etc. Not needed, if you'll just ditch paged-geom so soon.

ohlidalp commented 4 months ago

Well thats my wishful thinking anyway. I'll create a prototype grass generator soon, but I can't predict how the community will react, the paged grass isnt ugly 100% of the time.

@AnotherFoxGuy how would you approach this? Create a patched Conan package or try to override GrassLoader in game source?

AnotherFoxGuy commented 4 months ago

@ohlidalp Why not submit the patch upstream? For the OGRE 1.11 version we still use our own fork of paged-geom

cryham commented 4 months ago

Ah good. Where is it?

AnotherFoxGuy commented 4 months ago

Ah good. Where is it?

We use this repo: https://github.com/RigsOfRods/ogre-pagedgeometry

cryham commented 4 months ago

Ok made a PR https://github.com/RigsOfRods/ogre-pagedgeometry/pull/15

ohlidalp commented 4 months ago

Merged in good faith - I didn't find time to build it.

cryham commented 4 months ago

Okay. @AnotherFoxGuy this probably needs updating deps right, could you do it? I checked last dev build and it still looks the same with grass.

AnotherFoxGuy commented 4 months ago

I will update the package soon