I think people might enjoy this.

I think people might enjoy this.

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

I think people might enjoy this.

Post by Argh »

So... Kloot fixed the shadows for Units using alpha trans. It's marvelous. So I'm working on a few things I abandoned awhile ago.

One of those things was that I got that vertex shader for trees / foliage done.

A short video showing the addition of random periodicity and some vertex shader tricks.

A video with some commentary about constructing a scene in realtime.

A very short video, but it shows the detail and the feel you can get with a forest scene.

This first test isn't as cool, but it gives you the general idea, and it's on YouTube.


It's not perfect, but it's fairly adequate for the task. It can be scaled, on a per-Unit basis, so that a thin sapling, for example, can move considerably vs. a full-grown oak, a nearly-static cactus, whatever. You can use it on ground foliage, including my "one unit is many apparent ground objects" stuff (see first video to get a good idea), and it will work well, I think. It makes me want to build slightly higher polycount groundcover, though, the tri-quads are a little too simplistic.

If such a vertex shader was allowed in the shadow pass, then we could come fairly close to scenes like these:

http://www.youtube.com/watch?v=iY0xeCYF ... re=channel

...assuming that we wanted that much polycount in the scene, somebody makes a God Ray shader, and we, uh, have a game using that perspective ofc ;)

Anyhow, thanks to Kloot for pointing out a couple of things about why the first go was borked. I think this is probably adequate for now.
Last edited by Argh on 10 Mar 2010, 03:54, edited 1 time in total.
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: I think people might enjoy this.

Post by manolo_ »

wow, thats really awesome, i wont believe that this is the spring-engine :). cant wait till i get my new pc ;) :mrgreen: :mrgreen:
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: I think people might enjoy this.

Post by Beherith »

Nice! You beat me to the punch :)
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: I think people might enjoy this.

Post by Das Bruce »

That is cool, works on vlc but for some reason mpc poops itself when trying to play.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

That's strange, but hey, it's YouTube, I don't have any control over what it does after it's uploaded.

Anyhow, glad you enjoyed it. It's not perfect, but I don't think I have time to figure out perfect atm, I need to get back to other things. The difference in perceptual quality is pretty amazing- the videos lose a fair amount of the feel. Mainly though, people need to give Kloot some props for finally fixing this pet peeve of mine. It makes a lot of things possible that I wouldn't have been willing to mess with before. This is just minor icing on that cake.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: I think people might enjoy this.

Post by AF »

Nice, but I cant use it here and now, please fix!
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: I think people might enjoy this.

Post by Beherith »

Yeah, kloot has been doing some amazing work. He also doing a great deal for SMF.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

Yeah, I know. I really can't wait to test the SSMF stuff with your modification allowing different detail maps, I think that's going to make some really nice stuff possible, finally.

I'm also thinking writing a particle system for grass-like stuff that uses Units to control instancing, since the current grass leaves a lot to be desired, and can't be edited in realtime, or use mixes of color / texturemaps for a really professional feel. But I should probably be honest and admit that I'm not sure if I'll be able to find the time to get that done.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: I think people might enjoy this.

Post by Beherith »

Right, that reminds me, I wanted to expose the colormap of the grassmap to mappers... Since its generated from the minimap during runtime anyway.

Also, I would be perfectly happy with just a vertex shader on the grass to wave it as well.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

Grass needs re-thinking (imo). Ideally, it needs multiple textures (that mappers can configure) so that you can convey actual variety... and it should be billboards with vertex animation to make them "wave" (that's actually the easiest part), be able to accept shadows and map lighting. And it really needs to LOD better than it does.

But my big pet peeve is that it's utterly static. It's really awful when you have an explosion, everything's black, but the grass is all still perfectly green and still around, or you build a building, and its still around. Those are some of the major reasons I never use Spring's grass.

I don't have solutions for all of that; as an interim idea, I was thinking that the grass map should be exposed to Lua, so that it can be manipulated in realtime. If nothing else, that and exposing the grass color (especially if that's a bitmap, or treated on a per-sector basis, which I assume it is) and adding a gentle cyclic vertex animation would make it a *lot* prettier, allow for realtime editing (place an invisible Unit that does nothing but randomly turn on grass around itself via a Lua procedure, allow Buildings and explosions to remove grass, etc.).
Last edited by Argh on 09 Mar 2010, 11:28, edited 1 time in total.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: I think people might enjoy this.

Post by Das Bruce »

Argh wrote:But my big pet peeve is that it's utterly static. It's really awful when you have an explosion, everything's black, but the grass is all still perfectly green and still around, or you build a building, and its still around. Those are some of the major reasons I never use Spring's grass.
+1
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

Rats, my stealth edit arrived too late. Anyhow, that's my thought for a short-term solution; if I have any cool ideas for long-term stuff (LOD'ing, texture mapping with more variety, etc.) I'll try and find time to talk about that, if I think they're workable.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: I think people might enjoy this.

Post by Beherith »

While I agree with almost everything, I would think that shadows on grass would be needlessly complicated.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

Not really, presuming that the grass shader's ported over to GLSL.

That's pretty much copy-pasta at this point from the GLSL unit shader code, I'd think. Note: I do not think grass should cast shadows; that was actually in the engine at one point, IIRC, and ran incredibly slowly, because of the polycounts involved. That's total overkill for stuff that is maybe waist-high to my infantry, and again, IIRC, it just made grassy areas look really noisy :P

Anyhow, I'm open-minded about this, but shadows are very important, in terms of visual consistency, and it's probably worth the speed hit. Systems that can't handle grass now won't handle grass with shadows; systems that can handle grass now probably won't notice adding shadows to their shader, tbh. But think about how that groundcover I use would look, if it wasn't receiving shadows. It'd stick out like a sore thumb, tbh, because of the change in contrast.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: I think people might enjoy this.

Post by Gota »

That scene where you place the trees and there is fog...How much FPS did you get?Since I have the feeling it was very slow.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: I think people might enjoy this.

Post by Beherith »

For me, GLSL shaders like fog or snow hardly count as a performance hit (<3% fps drop)
Im guessing fraps caused the stutter.

Also: trunks of trees usually remain stationary in the wind, and its the foliage that moves, see:http://beherith.eat-peet.net/stuff/treewave.avi
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

How much FPS did you get?Since I have the feeling it was very slow.
On anything reasonably new, it's not slow. I.E., on a 9800 or newer video card, there's hardly any slowdown at all.

But for older hardware, I've built a game option in P.U.R.E.'s control panel that can talk to the precipitation and fog Gadgets and shut them off.
trunks of trees usually remain stationary in the wind, and its the foliage that moves
Actually, it varies, with the top of the trunk moving quite a bit:

http://www.youtube.com/watch?v=jztCGj3q0_E

...and as I said, it's something that can be adjusted on a per-Unit basis.

I can't really adjust the "foliage" per se with this approach, nor would it look all that good at the polycounts we're talking about, there aren't enough vertices (the non-pines are 268 triangles, the pines are 64 triangles). IDK, maybe I can add a modulation depending on the absolute distance from the center x,z, but I really doubt it will look good.
Last edited by Argh on 09 Mar 2010, 12:32, edited 1 time in total.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: I think people might enjoy this.

Post by Gota »

Beherith wrote:For me, GLSL shaders like fog or snow hardly count as a performance hit (<3% fps drop)
Im guessing fraps caused the stutter.

Also: trunks of trees usually remain stationary in the wind, and its the foliage that moves, see:http://beherith.eat-peet.net/stuff/treewave.avi
Hm for me fog slows the game down quit noticeably.
The fog on folsom dam delux for example slows my machine a lot.
I am using an ATI 4850,not an old card.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

It's probably a problem with ATi and the GLSL fog shader, then. Even on the 7800GS, it wasn't a big deal. IDK whether I'm using that version, ofc- there have been several variants. I know I stripped all the "const" out, since people have claimed that that's causing problems with GLSL and ATi.

[EDIT]Tried modulation via absolute distance... it looks absolutely awful.[/EDIT]

[EDIT2]A vertical modulation that takes absolute distance from the center into account, though, works pretty well, and should produce a similar effect to what you showed in the video for most things. I'll do more tests later.[/EDIT2]
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: I think people might enjoy this.

Post by Argh »

Added some small changes to the code to enhance realism; altering periodicity of the functions + some vertex offset to the Y axis using a little trick enhanced things substantially by removing the "zombie walk" effect of similar periods and allowing foliage to displace at a different rate than trunk geometry.

Short film added above, if you just wanna see it; I apologize to the non-graphics nerds for how dry this post must read.
Post Reply

Return to “Engine”