Gamestudio Links
Zorro Links
Newest Posts
Trouble getting data with IB Gateway
by richs. 07/16/20 13:04
Futures with IB
by jbhunter. 07/16/20 01:08
A9
by 3run. 07/15/20 19:07
Maximum Value
by AndrewAMD. 07/15/20 12:50
What are you working on?
by NeoDumont. 07/14/20 23:06
Engine window and DPI scaling
by Dooley. 07/14/20 20:27
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
8 registered members (3run, AndrewAMD, Quad, richs, kvm, onoff, Michael_Schwarz, 20BN), 382 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Estripa, nowater, dasanc, DavidFdez, TraderKevin
18478 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Realistic tree/grass weaving shader #480214
05/26/20 20:07
05/26/20 20:07
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Does anyone know how to make moving grass and trees more realistic? I use animTree.fx from GS folder, but it looks more like a shader for underwater plants for moving plants in water than as for grass/tree shader which should simulate wind blowing. Did is possible put some wind effect in this shader?

Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480215
05/26/20 20:19
05/26/20 20:19
Joined: May 2009
Posts: 5,276
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,276
Caucasus
Hey!

I'm afraid it's the only vegetation shader out there (as far as I know)... Maybe tweaking it might help?
Other than that, I remember in AUM (can't remember the number) there was an example of how to animate bushes and grass via bones.
It's not the fastest solution (since bones + their rotation for lots of grass can be slow), but it might be useful too.

Greets!

Edit: I was able to find the grass from AUM, take a look here:
AUM 76 -> Hot at the forum -> Plant effect by Mocosgames

Last edited by 3run; 05/26/20 20:41.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480218
05/26/20 20:47
05/26/20 20:47
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Hey!

I'm afraid any other solution than shaders is too slow.

I try tweaking this shader but the big problem is random() function did not work in shader fx file. I do not know how I can make some more random movements of grass.

Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480219
05/26/20 20:54
05/26/20 20:54
Joined: May 2009
Posts: 5,276
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,276
Caucasus
What exactly you mean by 'random movements of grass', maybe I could help with that. Please, explain a little bit more in detail.
As for the vegetation shader, as far as I understood, it simply 'waves' the upper vertexes of the model in a given X, Y direction with a given speed and that's all it can do.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480221
05/26/20 21:34
05/26/20 21:34
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
This A8 game is great example, I found it on 3dgs page:

https://www.youtube.com/watch?v=_u-Av18XJ-c&t=2s

The animTree shader currently has a constant weaving rhythm. The rhythm is the same all the time.

Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480223
05/26/20 23:41
05/26/20 23:41
Joined: May 2009
Posts: 5,276
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,276
Caucasus
This is what I came up with after playing with animTree for a while.
I was able to get proper wind direction for the grass, but it's not yet perfect.
http://www.filedropper.com/grass_1

Greets!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480232
05/27/20 10:28
05/27/20 10:28
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Wow thanks! It looks fantastic, almost like in the video. Now I will try how it works on trees.

Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480233
05/27/20 10:47
05/27/20 10:47
Joined: May 2009
Posts: 5,276
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,276
Caucasus
Glad that you liked it laugh
For trees I think it won't look that great, cause (as I think) for trees it's more important to move leaves on the wind, not the whole mesh.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480234
05/27/20 11:25
05/27/20 11:25
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Yes for tress maybe we need use separate model of tree and leaves.

The only problem too many grass with while loop function killing fps in game frown. It is not clear to me how the people who made the game above solved that problem.

Re: Realistic tree/grass weaving shader [Re: IDontLikeSoccer] #480235
05/27/20 11:34
05/27/20 11:34
Joined: May 2009
Posts: 5,276
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,276
Caucasus
Originally Posted by IDontLikeSoccer
The only problem too many grass with while loop function killing fps in game frown
You mean while loop for each grass? It can be solved easily, just use ENABLE_FRAME and event with EVENT_FRAME.
Code
void grass_event_function()
{
	if(event_type == EVENT_FRAME)
	{
		my->skill41 = floatv(wind_x + my->skill1);
		my->skill41 = my->skill41 - 0.1 * sinv(16 * total_ticks);
		
		my->skill42 = floatv(wind_y + my->skill2);
		my->skill42 = my->skill42 - 0.1 * sinv(16 * total_ticks);
		
		my->skill43 = floatv(wind_force);
		my->skill43 = my->skill43 - 0.1 * sinv(16 * total_ticks);
		
		my->skill44 = floatv(wind_amplitude);
		my->skill44 = my->skill44 - 0.1 * sinv(16 * total_ticks);
	}
}

action fx_animTree()
{
	set(my, PASSABLE);
	my->material = mtl_animTree;
	
	// randomness for each grass
	my->skill1 = 1 + random(2);
	my->skill2 = 1 + random(2);
	
	my->emask |= ENABLE_FRAME;
	my->event = grass_event_function;
}
As for the trees, yes. It needs some solutions. Maybe we could find some shaders from unity or other engines and try to convert them.

Edit: f.e. this one
[Shader - Open Source] Polygon Wind - for Low Poly Tree Assets


Edit2: I tried to convert it, but failed... due to not being able to get vertex color (without that it looks like default animTree.fx), I tried float4 inColor : COLOR0, but that didn't work.

Last edited by 3run; 05/27/20 12:48.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1