Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cryham opened this issue Feb 18, 2024 · 13 comments
Open

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

cryham opened this issue Feb 18, 2024 · 13 comments

Comments

@cryham
Copy link
Contributor

cryham commented Feb 18, 2024

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](https://github.com/RigsOfRods/rigs-of-rods/assets/720641/7c404dfb-5c66-43ee-a900-e3005bef675a) ![0456e
0457e`

@cryham
Copy link
Contributor Author

cryham commented Feb 19, 2024

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
Copy link
Member

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
Copy link
Contributor Author

cryham commented Feb 19, 2024

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
Copy link
Member

ohlidalp commented Feb 19, 2024

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
Copy link
Contributor Author

cryham commented Feb 19, 2024

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
Copy link
Member

ohlidalp commented Feb 20, 2024

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
Copy link
Member

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

@cryham
Copy link
Contributor Author

cryham commented Feb 20, 2024

Ah good. Where is it?

@AnotherFoxGuy
Copy link
Member

Ah good. Where is it?

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

@cryham
Copy link
Contributor Author

cryham commented Feb 24, 2024

Ok made a PR
RigsOfRods/ogre-pagedgeometry#15

@ohlidalp
Copy link
Member

ohlidalp commented Mar 1, 2024

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

@cryham
Copy link
Contributor Author

cryham commented Mar 1, 2024

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
Copy link
Member

I will update the package soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants