Search Unity

A Walk in the Wilderness

Discussion in 'Made With Unity' started by Eric5h5, Oct 29, 2006.

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As I mentioned in the screenshots topic some days ago, I've been working on my Veg-o-tron 3000, which turned out to be a stupid name because it's not just for vegetation. :) Although that's what it started out as. See that topic for more details, but in short, it's still a work in progress and has quite some ways to go, but it's more or less usable for some things. I'd be interested in what sort of performance people get on their machines...on my 2.5GHz G5 + X800, I'm getting typically 50-200fps at 1280x960 in "beautiful" mode, which is 4X FSAA. Normally hovering around 150, with the fps dropping to 50 or so mostly inside pine forests. (All that darn alpha blending...I had a better two-pass shader for the leaves, but the fps get killed enough as it is, sorry.)

    The main issues remaining are:

    1) Although it makes combined meshes, the low detail combined objects need to be further combined, which should enable better speed and/or farther view distance. (The trees in particular should be visible from much farther away than they are now.)

    2) Speaking of trees, they really need a third level of detail between low and high, as the transition right now is pretty awful. It works better for the other objects because they're so much smaller.

    3) The terrain is really really low-detail. Well, it's about 90 square km and one 4000 poly mesh, what do you expect. ;) (Although much of it is "background" and you're not really supposed to go there, though you can.) Eventually I'll have to figure out some sort of geo mipmapping, or something.

    4) Try not to laugh too hard at the shadows...they're just objects, which becomes painfully obvious at times. Although that's one benefit of massive polys for the terrain, because the shadows need flat surfaces to work at all. But stuff looks 10X less fake with shadows, so even lame shadows are better than none. Possibly I can use render-to-texture somehow (when I get Pro) to make a "combined" blob shadow which would look a lot better and leads to...

    5) Day/night cycle. The changing lighting is simple (see below, although it's not activated in this player), but without changing shadows it doesn't really cut it. I could also fade out the sky to have a starry night skybox gradually appear.

    6) Changing weather. The clouds already are set up for that (that's not a scrolling texture; it's a moving object), so it would be a matter of making some variant sky conditions and then having those slide in. Then doing particle effects for rain, and the wind effect for the trees etc. could easily be altered to suit. The breeze needs work anyway because right now it's just based on a simple sine wave and should be more realistic.

    7) The colliders for the rocks are just boxes. Mostly that's OK, but it's pretty silly for the larger rocks. It would actually have been easier to do a mesh collider, but then you get that annoying pause while it's computed. Would sure be nice if you could have mesh colliders computed in the background if you don't need them right that instant (which I don't).

    ...But I don't actually need any of that stuff for my current project, so it will have to wait for another time. If any Windows folks are interested for some reason, I could post a web player, though I seem to have a weird issue when I build one. Namely, if you're standing around in a field or something doing nothing, the fps start out at 200 and then gradually go down over the next 15-30 seconds to 100, then they pop back to 200 and the cycle repeats. Weird...the stand-alone doesn't do that.

    Speaking of fps, use the F key to turn the fps display on/off. Use the standard FPS controls for moving around. If you have a slow machine you can also try the "[" key a few times to turn the view distance down (and "]" to go back up), but that's only partially functional since it only affects areas that you haven't seen yet, so you might have to walk some ways before it has any effect. Also there's a reset function ("R" by default), which you can use if you're silly enough to walk all the way to the edge of the terrain mesh and fall off, but mostly because there are a few "start" locations which are randomly selected when you do the reset.

    --Eric
     

    Attached Files:

  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    This really looks good as a demo, feels a little sterile though. Maybe I'm just starting to get the same feeling from all these tree scenes everyone has been posting lately. It runs at about 10 frames a second on my ATI 9600 which starts to get annoying while trying to walk across such a large space. I like your stone wall textures a lot, they have some real weight to them, but as a cohesive scene this feels a little sparse or incoherent.
     
  3. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    On my Powerbook G4 1.67Ghz with an ATI 9700, it runs nicelly on Beautifull settings at 1024x768. I'm getting between 30-50 fps.
     
  4. yellowlabrador

    yellowlabrador

    Joined:
    Oct 20, 2005
    Posts:
    562
    Walking around trying to see if I can find some buffalo roaming :wink:
    (Watched some indians cowboy movies last nite). Maybe a little more flowers or grass on the ground, dead branches, etc. Other than that I like It,

    It freezes a little bit (maybe about .25 - .50 seconds) when walking around
    Ran it at max resolution windowed and full screen on a G5 2.0 ATI X800xt.

    Ray
     
  5. AGhost

    AGhost

    Joined:
    Apr 13, 2006
    Posts:
    90
    I get a slightly different picture when I run your Program in FullScreen:



    Looks pretty though...
     
  6. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Thats AMAZING! It is a ton better then anything I could code and it even ran on my radeon 7500 with swaying trees and everything.

    I would say the most important thing would be to make the average color of the ground and the average color of the vegitation the same and then make all of the grass and flowers and stuff about 10x more dense but cut down the visible distance to compensate. Also I know this is extremely hard but I would focus on making a lot more trees on screen at once. That would really really add to it.

    I never really noticed any snaps or anything but the overall look wasn't that hot compared to the real world. I think the stuff I mentioned above could help with that.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well thank you, though I can never hope to compete with the real world. ;) My current game doesn't even need this level of detail, just a few trees and rocks, but eventually I'll do something that will be more realistic; this was just a demo to see if my ideas were at all feasible. For sure there needs to be a lot more density...a real forest has a lot of underbrush, saplings, etc. (which I know because I live near one....).

    I was hesitant to add much more right now, because as mentioned there should be more mesh combining, and I didn't want to spend too much time on content creation at this point. The scripting also needs some major optimization, though the mesh interface stuff is at least as fast as OTEE says. Which is to say, real fast! The tree/plant swaying stuff is done using that. The high/low LOD transition is terribly obvious if I just switch from one mesh to the other, so I did a cross-fade instead.

    Good to hear that it runs OK on a Powerbook G4 even in its current state, although 10fps on a 9600 isn't too good. Did you try a lower resolution/quality settings? If it runs on Yoggy's 7500 (yay!) I would have expected better. AGhost, what machine/graphics card are you using? That look is interesting but wasn't quite what I had in mind. ;)

    --Eric
     
  8. AGhost

    AGhost

    Joined:
    Apr 13, 2006
    Posts:
    90
    I've got an eMac G4 1 Ghz. The wierd thing is, it works fine in a window (although really laggy), but gives me that in fullscreen...
    Wierd...
     
  9. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    AGhost: I guess it's running out of video memory. How much VRAM is in your machine?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If it is VRAM, I already reduced the size of the textures. ;) (Although, most of the size of the file is taken up by textures anyway.)

    By the way, I meant to ask, I ended up not bothering to compute tangents for the meshes but I'm getting what seems to be correct bump mapping anyway...huh? I had every intention, but when I first put a bump-mapped texture in there it came out right, so I never did....

    --Eric
     
  11. Mindless_Soul

    Mindless_Soul

    Joined:
    Feb 1, 2006
    Posts:
    128
    1GHz G4-Radeon 9800 128MB Pro

    Quality:
    • 1600x1200 Fantastic
    Framerate:
    • Minimum: 18 FPS (When looking over a hill at a bunch of trees)
      Maximum: 70 FPS (When looking towards the ground on the moutains)
      Average Performance: 25 FPS
    -------------------------------------------------------------------------------------
    Quality:
    • 1280x960 Beautiful
    Framerate:
    • Minimum: 20 FPS (Same instance)
      Maximum: 75 FPS (Same instance)
      Average Performance: 35 FPS
    It's gets a little jumpy at times when you swerve the camera around and things start loading in. That wouldn't be so noticeable if I had a faster processor.

    Everything looks really nice, I like the moving clouds...
    I'm looking forward to that Day/Night cycle. Sounds pretty cool.
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah...a little of that is when new textures load, which I can't do anything about, but some of it is because the area is divided into a number of zones which instantiate a bunch of copies of the main script when you enter them. (The script that controls the low/high LOD stuff for individual areas.) Unfortunately the script started out small but kept getting bigger and bigger (800+ lines, eek), with quite a few variables, and I tracked down the issue to these variables being initiated. If I'd planned this thing out properly instead of just adding stuff on, I would have realized right away that it would be far better to put 95% of that functionality into static functions, instead of having it be duplicated unnecessarily so many times. By the time I realized my stupidity, I just wanted to get it working first, and then get it working properly later. :) So I think I can get rid of most of the jumpiness (although you're right, it's usually not noticeable on my machine), and also reduce the memory consumption a fair bit.

    It'll be a while before I get to that other stuff, unfortunately. But I really appreciate the input, thanks! Seems like this might turn into a workable system with some polishing.

    --Eric
     
  13. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,647
    wow that's a big terrain! yeah i tried to get to the edge ;) ran out of time. but i got to check it out a little bit. only tried fantastic settings.

    733 g4, 256Mb 9800, 1Gb ram... -300 view dist and yeah understandably still brutal in the trees this low ender. but further away i got up towards 200 fps (really far out). in less dense areas i got 30-50 even with trees. it got laggy where you'd expect with my cpu and did better than i thought it would in other spots. i really didn't get a lot of lod pop. only a couple times. as a matter of fact that's some really nice fade in.

    anyway, nice job overall! love all the grass and flower textures and the rocks uhhh... rock! :D
     
  14. guategeek_legacy

    guategeek_legacy

    Joined:
    Jun 22, 2005
    Posts:
    659
    3GHz Xeon-Radeon X1900 XT 512MB

    Quality:
    2560x1600 Fantastic
    Framerate:
    Minimum: 16 FPS (When in the trees)
    Maximum: 35 FPS (When looking towards the ground on the moutains)

    ----------------------------------------------------------------
    Quality:
    1600x1200 Fantastic
    Framerate:
    Minimum: 84 FPS (In the Trees again)
    Maximum: 255 FPS (Out in the areas with no trees)

    Only complaint is that I can see like a refresh rate thing in the bottom section where a detail texture is being applyed to the ground. Nice work though.[/u]
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Wow, that's a high resolution...congrats on the new Mac. :)

    I wonder what that is...I'm not seeing anything like it here. Perhaps something vsync would get rid of? Though I didn't enable that for any of the quality settings.

    --Eric
     
  16. Bampf

    Bampf

    Joined:
    Oct 21, 2005
    Posts:
    369
    I got a hang as I approached the cultivated area (pumpkin patch?.) I was running in 1280x800 (widescreen) at the highest quality setting.
    PowerMac Dual 2 GHz
    Radeon x800 (256 VRAM)

    I restarted in the 2nd-highest quality setting, didn't have any problems though I didn't go near the same area.

    I loved the look of the mountains. Wouldn't it be cool if I could go to them, I thought to myself. Kept expecting to hit a boundary, but no, I got to the first hill.

    The crickets died away- nice I thought, but what he really needs is a windy sound as you go up the hill. 10 seconds later, there it was! And a much stronger wind sound up on the next peak. VERY COOL.

    Perhaps a very faint rustling sound when you walk through vegetation? Just a thought.

    Some of the tree shadows aren't hugging the ground, as you probably know.

    The peaks are very bare- a few small rocks might work wonders.

    I really enjoyed wandering around. I could see a nifty, low-key game arising out of this. You wander, find a small set of ruins with some little thing to do there, maybe see a goat somewhere else. Maybe a larger goal gradually emerges.

    Would have liked a dash mode where you can run for a short ways and then have to rest. At a higher altitude maybe you'd have less dash.

    Sorry if this rambles; I'm just letting my thoughts wander as I type this, seemed apropos to the wandering feeling I got from your scene. I enjoyed it, nice job.
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Ack, that shouldn't happen. I haven't had any hangs here, though as I mentioned my scripting (or at least the method I used) leaves something to be desired at the moment, so I'm not completely surprised. But that will be fixed before I use this in anything important. There is a known issue where a couple of spots can have low LOD objects hanging around when you approach, but that's just due to a wrong setting on a couple of instances.

    One thing I don't much care for in games is artificial barriers. If you've played Lugaru, you'd notice that the "meat" of the levels is pretty small, but you can go off into the wilderness if you want. It's true that you end up running over featureless terrain in short order, but I prefer that sort of thing to something that screams "fake invisible wall! Go back!" As a player, I know what I'm supposed to do, but it's nice to ignore that and explore if you want. Of course, there's a danger in letting things get too diffuse, so you want to keep enough focus so that there's not too much risk of players just getting lost and frustrated.

    My thought too. :) However the sound was just a last-minute addition...I would use a much better sound system in an actual game.

    All too well.... ;) The shadows are just a place-holder until I can do something better.

    Definitely...there needs to be a lot more "stuff" in general. I'll probably end up writing some routines to at least semi-automate the population of areas, so I can concentrate more on the interesting bits. Right now it's fairly simple and fast but even so it eventually gets tedious with huge areas like that.

    Reading my mind, are you? ;) Yeah, something like that....I have a few games I want to complete first before I get to it though.

    Realistically, you're actually running along at a pretty good clip as it is. If anything I'd slow the pace down (although there could still be a dash mode), and probably implement something like Myst's zip mode for areas you've already been to. However, the areas would be denser and more interesting, so there shouldn't be a need for a lot of speed. I can see that there would be with this demo because the interesting bits are few and far between, sorry....

    No problem with the rambling...I also like rambling as you can tell from this post.... :)

    --Eric
     
  18. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    I liked that the clouds and shadows on the ground were moving. It took me quite some time to get on a peak to look down. And this without any snack... ;O)
     
  19. escondar

    escondar

    Joined:
    Dec 20, 2005
    Posts:
    83
    Huge terrain with relatively low poly count still looks good. I have been trying to make huge terrains with higher poly counts and get hit badly on performance with not that much improvement in looks. What are the dimensions of your terrain in poly's exactly? Just curious. I have made a terrain of 100 x 100 polies which I broke up. Your looks as good or better. This is a good lesson for me



    on my old G4 dual 1.4 with an old ATI radeon 9000 pro I got 15fps in the dense pines and 80 - 100 on the open plain.

    thanks for posting
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, this is where geo mipmapping comes in, where you have a high poly count in the immediate area but a low poly count far out. The only thing is, the geo mipmapping I've seen so far has annoying popping or morphing effects as terrain goes from low to high detail, and I'm wondering how you'd avoid or minimize that. Possibly having a lot of vegetation would hide it.

    Hard to say, because the outer parts have really REALLY big polys whereas the inner part just has big polys. :) It's 3,560 polygons total for the mesh though.

    --Eric
     
  21. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    That's were nice ROAM algos come in and/or streaming 3d data engines.
     
  22. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Quote:

    That's were nice ROAM algos come in and/or streaming 3d data engines.


    Been there, done that. In the year 2000 where everyone wrote their own terrain engine. I also wrote a roam renderer. Not going back.

    I think geomipmapping (or quadtree based) with some really good precalculated error metrics is the way to go. Mainly because of the practically non-existing processing time.

    In any case, these days you can just throw more polys at the problem and it's gonna look fine. Thats why geomipmapping is good. It's good at wasting lots of polys without costing a lot of cpu performance.

    What really matters though is foliage, trees, detail objects and texturing of the terrain. This is what adds life to the terrain and makes it look great. Not if that triangle picked the optimal splitting vertex depending on your view direction.
     
  23. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Hmmm i never implemented a ROAM engine on my own, i've just used some and it worked quite well. What are the downsides from your point of view?

    But i've written a realtime 3d fractal terrain engine on the amiga which got trackloaded. :O)
     
  24. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The downside is that it takes a lot of processing power to do the precise-ish lod.
    It doesn't scale very well to modern gpu's. Modern gpu's are good at drawing lots of polys. So instead of spending a lot of time on the cpu making the lod be precise and exact, it's preferable to simply use more polys but spend less time creating them using a simpler and faster method.

    A geomipmapping like technique, was also used by far cry. I have a feeling most game engines with terrain rendering implement geomipmapping like techniques these days.
     
  25. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Hmm i would say it a) depends on what's a modern gpu right now at the moment and b) on the special case. It sounds better to use geomipmapping for fps like games and the current gfx card generation but i also remember a project where we had to deal with a very large surface and certain important points. There i would favor a ROAM implementation.
     
  26. BigPowerfulMedia

    BigPowerfulMedia

    Joined:
    Oct 26, 2006
    Posts:
    20
    I'm new to Unity and just got my first Mac today (just for Unity). I've been watching the boards for a long time though, and this terrain demo was one thing I was itching to see. It looks beautiful, btw, but how in the world do I exit? Esc, alt tab, open apple everything... I think I tried every key and combo I could come up with. I ended up turning the system off... If there is some secret Mac way of exiting that I need to learn, I'd love to know what it is :) Thanks...
     
  27. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    cmd-q the way to quit every mac application.
     
  28. BigPowerfulMedia

    BigPowerfulMedia

    Joined:
    Oct 26, 2006
    Posts:
    20
    Thank you... Where else can you ask an inane question and get a kind response from the "Project Lead"?
     
  29. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Of course one can always come up with cases where one algorithm might potentially perform better.

    Some other problems that are really hard with roam or other precise-ish lod algorithms and the real world:
    If you start placing a lots of objects, grass, detail objects and trees on it and you do lod, they will start floating / go under ground.

    If you are close up, this can be extremely visible and even the way you triangulate a single quad (Split it bottom-left to top-right or top-left to bottom-right) makes a huge difference if you are standing next to it.
    When the tree is further away, you can't even see a tree floating 5 meters in air.

    There are two solutions: Move close up detail objects along with the lod up and down. So you will have trees that move up and down on the terrain as you move along. This means you pay with processing power and it might look slightly weird (as in worse than geometric terrain popping)

    If your trees / foliage are integrated with the terrain this might possible, however in practice you also place a bunch of custom meshes on the terrain. Lets say a house or you have physical objects which you can't really snap with the terrain lod. I presume you could always try solve those somehow. Eg. you could live update the terrain collider so if the lod changes, you change the collider and you hope that rigidbodies will quickly fall to rest along with the terrain change. Of course that means if you play a networked game, those rigidbodies will move up and down on one machine due to different lod than on the other machine. So there needs to be some custom mechanism to synchronize those rigidbody. I presume in theory this can solved.

    Fortunately we are living in the real world though and in practice i would say thats exactly the point where one gives up on precise-ish lod.


    So the simpler solution is to use a method which on closeup chooses the highest lod with always the same triangulation, so you can guarantee that close up everything will be bolted on the terrain perfectly. And for far away things, you just hope for the best. Now that doesn't sound as fancy, but it actually works in practice.

    Also a geomipmapping-ish quadtree based solution can easily handle a 4096*4096 terrain.
     
  30. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    We've used it for medical visualisation so there were no floating objects problems.

    How simple would it be adapting the geomipmapping to different projections like for instance a small planet - Mario Worlds/Spore like?
     
  31. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Should be pretty simple. Certainly easier to adapt than roam.
     
  32. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    I've just read though some directX10 stuff and as far as i've understood it, it then should be possile to get this (regarding roam/subdivision) done on the gpu without hitting the cpu.
     
  33. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Probably not easily though (at least things like ROAM).

    It's very easy to do n-patch tesselation with geometry shaders (whether that will be fast is still an open question). I guess it would be quite easy to do the geomipmapping (but that is easy anywhere without a big CPU cost). More interesting schemes probably can be done with geometry shaders and stream-out, but the performance is again still an open question.
     
  34. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    The other thing about this is: Geometry shaders are a new feature - that means that cards that do support it are fast enough that you don't really need to worry about polys. And for the next 7-8 years, you still need to support cards that doesn't have it. It is, unfortunately, those cards that will define your algorithm. Optimizing for the latest hardware is a luxury few can afford ;-)
     
  35. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    @Aras
    Hmm time or examples will show...

    But they are going a exciting route and if rumours are right about what's coming next this could turn out exciting and helpful.

    @Nicholas
    That's true (although i wouldn't say 7-8 years old) but i just like dynamic generated and recursive stuff... :O)
     
  36. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Very cool! Needs a super-run key for demo purposes :)

    (And I still think Unity's default FPS mouse response is WAY too twitchy, far different from commercial games. I can barely walk a straight line in Unity FPS demos with the default settings.)
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Interesting...something to do with mouse settings in the OS maybe? Because I don't seem to have that issue; the default FPS controls are comfortable and pretty much like other FPS games here. I figure an actual game would have mouse sensitivity settings to hopefully get around stuff like that. And yeah, I had a super-run hack for testing, which I removed in order to make a non-hack version and then forgot to implement...oops, sorry....

    --Eric
     
  38. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Thanks for sharing! Could you share some more detailed information on how you got the sky moving in Unity? I am an artist and not a programmer and so far I haven't seen how to do the animated sky like you accomplished. Thank you for your time.

    Cheers,

    Gary
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sure. It's two really big planes with a different cloud texture on each, which I generated with POV-Ray and then tweaked in Photoshop so they tile seamlessly. The plane object is a square divided into 1024 polygons, because otherwise you get some shading weirdness since they're so big. The lower plane has transparency and the top plane doesn't (it has the blue sky in it). Then I wrote this script:

    Code (csharp):
    1.  
    2. private var offset : float = 0.0;           // X axis offset from player location
    3. private var sidewaysOffset : float = 0.0;   // Z axis offset from player location
    4. var speed : float = 8.9;                        // X axis speed (primary)
    5. var sidewaysSpeed : float = 1;              // Z axis speed (secondary, so the same section doesn't loop over and over)
    6. var resetLimit : float = 5100;              // When offsets reach this, reset to 0
    7. var objectToFollow : Transform;             // Player object to follow
    8. var yDistance : int = 600;                  // Distance overhead from player location
    9.  
    10. function Update () {
    11.     offset += speed * Time.deltaTime;
    12.     if (offset > resetLimit) {offset = 0;}
    13.     sidewaysOffset += sidewaysSpeed * Time.deltaTime;
    14.     if (sidewaysOffset > resetLimit) {sidewaysOffset = 0;}
    15.     transform.position = objectToFollow.position + Vector3(offset, yDistance, sidewaysOffset-2400);
    16. }
    17.  
    And put that script on each plane. Then I just fiddled with the exposed values in the Inspector for each one so they move at different speeds. You'd drag the first person controller for the player onto the objectToFollow slot.

    The important thing is to get resetLimit right so the plane goes back to its original position at exactly the right time so it looks like it's seamless. One nifty possibility is to have two planes, one following the other, so I could put different cloud textures on them as necessary and have changing weather conditions. When this happens I could also have the fog parameters change appropriately and have a particle system for rain when necessary.

    I put the sky not so far overhead (the yDistance value) so it doesn't get lost in the fog, but it follows the player so it looks like it's really far away when it's not. (I can't just use a shader with fog mode off, because it does need to be affected by fog at the horizon.) The only problem with this is that if you go really fast, it becomes obvious, because the cloud shadows zoom along with you. I think I might change it so that it still follows the player, but with a differential, so that it's not so obvious.

    The cloud shadows are done with a blob shadow projector, which uses a shadow texture derived from the main sky texture. This is parented to the top plane so the shadows move along with the clouds. I wasn't sure how to figure the offset to account for the angle of the sun, so I just moved it around until it more or less matches up. (The reason the last line has "sidewaysOffset-2400" is because the way things are set up, that generally keeps the blob shadow projector over the terrain mesh, because otherwise the shadows will suddenly disappear if it scrolls off. This can still happen if you go near the edges.)

    There's also a feature that probably nobody would ever notice, unless you happen to be looking up at the right times. I'll let someone guess what that is and how I did it. ;)

    --Eric
     
  40. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Eric,

    Thank you so much!!! I definitely can see how you did it and what a wonderful 'trick' it is!!! I can't wait to try out a similar effect with my sim.!!!!

    Cheers,

    Gary
     
  41. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Lens flare occlusion with opaque clouds! One of the very first things I noticed. I think that is what you refer to! I thought maybe you offset the cloud plane a little lower and then sandwiched the light between the two planes.

    Maybe that is what you were referring to?

    By the way if you get the clouds to move more independently from the camera so you could fly or move at accelerated speeds please let me know as my simulation will require moving at accelerated velocities.

    Anyway, thank you so much for sharing. I am so new to this application and have much to learn.

    Cheers,

    Gary
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep. ;) The only way to do that as far as I know is to have an object that's not on the TransparentFX layer, so I loaded the main cloud texture into Blender as a background image and roughly traced over the clouds with some polygons, and saved that out as an object, which I then parented to the top cloud plane so it moves with it. It has the renderer turned off so it's invisible (and takes no rendering time, unlike alpha transparency), but even with the renderer off it still blocks lens flares.

    --Eric
     
  43. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Whoa!!!

    Seems like some work, but you then control where you want that to be exactly. Just stinks you need to use polys for that.

    Gary
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Meh, it only takes some minutes or so once you know what to do. Figuring it out took longer. ;)

    --Eric
     
  45. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    ... and you are not forced to use polygons. The flare is blocked by colliders and any collider (in the correct layer) will do as far as I know.
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, it's a mesh collider, which is made out of...polygons. ;) Far easier than trying to group a whole lot of boxes or something, I think....

    --Eric