Relatively realistic Grass
Community Forums/Showcase/Relatively realistic Grass
| ||
Hi! I played a bit with Grass Textures. This wannabe Grass is not perfect, but I think it's looking pretty good. It is using Copyentity, so it isn't that slow. Using a single Mesh would probably be better, but accessing the Vertices for the Wind Animation would be a bit of work that I didn't do yet :) However, feel free to use these Files, including Textures, in your Projects.![]() http://www.melog.ch/dl/mygrass_nu.zip Surprisingly I didn't have Z-Order Problems in Alpha Mode. I suspect this is up to the usage of explicitly masked TGAs (?)... |
| ||
That looks good, but you are right in thinking that it really needs single-surface. And, that is where the problems arise because you will suffer z-order problems in that case. Nice texturing. |
| ||
Correct me if I am wrong: I think it IS single surface because it is using CopyEntity. Because when you paint something on the original Texture, then all Textures will chanche. So it must be a single Surface, isn't it? Here's an other Example, using the same Media, now with 2600 Grass-Quads. I don't think that these are 2600 Surfaces. But maybe I am wrong. ; Simple, tiny Grass Demo 2 by JFK aka NORC of CSP ;Graphics3D 1024,768,32,1 Graphics3D 800,600,16,1 SetBuffer BackBuffer() Global windwave# Global grasscount camera=CreateCamera() TranslateEntity camera,0,20,0 CameraClsColor camera,80,110,120 CameraFogMode camera,1 CameraFogColor camera,80,110,120 CameraFogRange camera,100,200 CameraRange camera,1,202 light=CreateLight() terrain=LoadTerrain("hmap.jpg") ScaleEntity terrain,5,100,5 TranslateEntity terrain,-320,0,-320 floortex=LoadTexture("floor.jpg") ScaleTexture floortex,32/5,32/5 EntityTexture terrain,floortex quad=LoadMesh("smplquad.3ds") FitMesh quad,-10,0,0,20,20,0 EntityFX quad,16 Or 1 grasstex=LoadBrush("grass5f.tga",2 Or 48) ; also try Mode 4 instead of 2! PaintMesh quad,grasstex Dim grass(100000) Dim grassa#(100000) grasscount=0 For j=-250 To 250 Step 10 For i=-250 To 250 Step 10 grass(grasscount)=CopyEntity(quad) x#=(i+Rnd(-5,5)) z#=(j+Rnd(-5,5)) y#=TerrainY(terrain,x,0,z)-Rnd(2) PositionEntity grass(grasscount),x,y,z grassa(grasscount)=Rand(-90,90) grasscount=grasscount+1 Next Next HideEntity quad ;-------------------------Mainloop----------------------- While KeyDown(1)=0 If KeyDown(200) Then MoveEntity camera,0,0,.5 If KeyDown(208) Then MoveEntity camera,0,0,-.5 mxs#=-MouseXSpeed()/4 mys#=MouseYSpeed()/4 mxa#=mxa#+mxs# mya#=mya#+mys# MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 PositionEntity camera,EntityX(camera),TerrainY(terrain,EntityX(camera),0,EntityZ(camera))+20,EntityZ(camera) RotateEntity camera,mya,mxa,0 wind(15,1.0) UpdateWorld() RenderWorld() Text 0,0,"Quads in Scene: "+(grasscount-1) Text 0,12,"Tris rendered: "+TrisRendered() Flip Wend End Function wind(force#,speed#) For i=0 To grasscount-1 x#=EntityX(grass(i)) z#=EntityZ(grass(i)) RotateEntity grass(i),Sin(windwave+x)*force#,grassa(i),Cos(windwave+z)*(force#/2) ;or maybe better use this: ;RotateEntity grass(i),Sin(windwave+x+grassa(i))*force#,grassa(i),Cos(windwave+z-grassa(i))*(force#/2) Next windwave=(windwave+speed#)Mod 360 End Function |
| ||
That looks brilliant :) |
| ||
Thanks :) BTW: Maybe you should replace RotateEntity grass(i),Sin(windwave+x)*force#,grassa(i),Cos(windwave+z)*(force#/2) by RotateEntity grass(i),Sin(windwave+x+grassa(i))*force#,grassa(i),Cos(windwave+z-grassa(i))*(force#/2) in the wind function, I think it looks better. |
| ||
I'm pretty sure they are seperate surfaces. Just so you know: both demos give me about 10-12 FPS. |
| ||
Both the same fps? Just another trace for that they use the same Surface. BTW - did you turn off Debugging? |
| ||
i dunno about that jfk. I'm doing some stuff invovling that and my single surface particles run about 5 times quicker than my stuff that uses copyentity. |
| ||
Mind you, i'm using sprites for one of them. There's probably a big difference between copying a sprite and copying a quad :) |
| ||
They both run with no slowdown on my system, I have an AMD 2600XP and a Geforce4 Ti4200. My monitor is locked at 60fps, so the demos run at a smooth 60fps :) |
| ||
impressive work here jfk! just like your fps game! |
| ||
I'm running both demos in Release mode. They both run at approximately 10-12 FPS. Maybe 2-4 FPS difference between each demo. |
| ||
Hmm - I got 26 to 27 FPS on a crappy Radeon 9200 for 65$. (26 is strange anyway, as if the monitor was synced at 52 or 78 Hz (maybe 80) - it's an LCD Monitor and the Ati Setting say "Optimal" - whatever that means) However. I will try to implement this (or almost the same) as a single Surface Solution (or maybe make some Groups instead of one huge mesh that cannot be culled partially!). Or maybe someone could help me with this, I am not a single-surface Specialist. Especially since I had problems with a lost alpha-mode when I tried to add all quads to one mesh this afternoon. BTW. there are 2600 quads in the scene, in FXMode 16, so theoreticly it's 10400 Tris plus Terrain (although the camerarange occludes about 75%) We'll see. |
| ||
FX 16 doesn't double your tris, leaves it the same. I have a good bit of code for dynamically sorting single-surface alpha'd meshes. If you get the single-surf stuff up and running I'll give it a go. |
| ||
Ok, thanks, I'll let you know. |
| ||
It will be seperate surfaces regardless. This isn't close to the speed of single surface, but nice demo :) |
| ||
Hoya, kewl demo D. Here is the same demo using single surface particles: http://telias.free.fr/temp/grass_ssps.zip I get 4-5 times more fps but apparently there is a z-order problem. |
| ||
Hey nice work here jfk, Another cool implementation would be set up "zones" so when the player walk into this grass, you have a movement. Pretty a nice feeling :) Yes, true I see zordering problem here too using you ssps Elias |
| ||
Wow, thanks Elias! Now let's see what MasterBeaker is gonna come up with. (see his comment above) |
| ||
Man, this is wonderful!.. I'm getting smooth Framerates (>60) in all of my resolutions! Pretty nice FX. Looks Great jfk & Elias. |
| ||
link doesn't work for Elias single surface stuff :( |
| ||
Here it works well. Maybe try this: http://anonymouse.ws/cgi-bin/anon-www.cgi/http://telias.free.fr/temp/grass_ssps.zip |
| ||
Here is the z-ordered alpha'd grass version: ORDERED GRASS DEMO Please credit me if you use the "alpha z-order" code. You would get slightly better results with the grass broken up into a few chunks. Maybe 4 or 9. My include can handle any number of chunks. I get 20 FPS on my crappy old rig and it looks great. Enjoy! |
| ||
I forgot to mention that running it in debug mode might be a bad idea. |
| ||
Wow, Master Beaker. The alpha z-order fix is ultra cool man ! Thanks a lot for this. I will try to clean the code more and make it more simple to use. |
| ||
Just tried it, yeah it's fantastic! Elias, I had strange white Lines in masked Mode(4), so I set it to Alpha, with EntityAlpha 1.0. Togehter with MasterBeakers Z-Order Code it's perfect. The Wind is still looking a bit too unifom to me, but I think I can modify this easily. Thanks a lot for your Work, both of you! You'll be in the Credits, that's for shure! |
| ||
Blimey! I didn't notice that mask was on (instead of alpha). I think it might run a bit faster with alpha as well. |
| ||
And it looks much smoother ! And :) this was the reason why you put in the Z-Order. |
| ||
Yeah sorry for that. I had flag 4 put on for some tests and forgot to change it. About the wind yeah. But it's easy to customize it. You could also use a "stiffness" parameter for each plant. As I said above I will post propably tomorrow a more user friendly version of this. Bye. |
| ||
OK, no prob. Stiffness Parameter sounds good. This little Thing became a very nice resource for a cool outdoor ambience IMHO. Credits also go to the real Grass that was used on the picture :) If you want me to then I can make a little Tutorial about how I made the TGA Grass Texture using Photoshop 6. Guess The Gimp should work as well. |
| ||
Ok, what about TreeMagic for free with bundled: MagnificGrassCreator ? :D ( J/k) |
| ||
Just to make this clear: Am I right when I say CopyEntity is using multiple Surfaces, but the surfaces are all using the same Brush?!? |
| ||
Here is the grass system - plug'n play ready. http://telias.free.fr/temp/grass_zorder_b.zip I have added the ability to varie the size of each plant. You only need to load the terrain,make the new grass type and call the "GRASS_MAKE" function to construct it. In the main loop you call then the update_wind and update_zorder functions. Destructors are included so everything is cleaned up on exit. Some more ideas are to use a "grass-map" along with the heightmap. Also you can add some more fields to use different images for not having the same image repeating itself etc... Bye. |
| ||
strange that z order problems only seem to occur when viewing through another alpha texture. so yeah jfk,I wonder is the copy entity reusing the same texture at no additonal memory cost. or just the brush. |
| ||
jfk - I would say that CopyEntity is using multiple surfaces, and not the same brush. They do use brushes that look the same tho. :) Brushes are really just a convenience for the programmer. You can delete a brush when it is in use without any loss. |
| ||
It's just I saw when I paint something on the original texture then it shows up on all Entities when they were made with copyEntity. Elias - great! Variable Height and/or Size is real handy since the Demo still suffers of a too much uniform look. The Stiffness Idea is still there and I'd love to implement a kind of random wind Vector, so the Wind-vortices built by the rough surface of the Terrain and Grass will play with the grass and bend it in diffrent directions, say plus minus 45 Degrees. Seems like this thing soon gonna be ready to be used as an open source vegetation system for the BB Community that rocks. I'll make some more Plant Textures when I find some time next weekend. |
| ||
It's just I saw when I paint something on the original texture then it shows up on all Entities when they were made with copyEntity. That's because all the meshes use the same texture. You could apply the texture to a sphere/ character and the changes would still show up. If the meshes were all on a single surface then you wouldn't be able to scale and rotate them individually. To move them around/ animate them you would need to loop through all the vertices in the surface and adjust them accordingly. |
| ||
To solve the z alpha problem, could you not position the grass each frame with regards to distance. The lowest indexs closer to the player and the higher one further away? |
| ||
BinaryMoon - that isn't the issue that jfk is pointing out. He is merely noticing the behavior of CopyEntity'd objects. We already have single surface systems that allow you to scale and rotate individual particles etc. In fact this grass system uses one. Joker - The z-alpha problem is already fixed. Take a look for yourself. |
| ||
elias - im not entirely convinced that using a single tri per particle is the most efficient method, you get a lot of overdraw with it. Did you ever do a like for like speed comparison? |
| ||
Hi Beaker. Yes I have done tests with quads and quads are almost 2 times slower then tris. ;----------------------------------------------------------- Also here is a new version: http://telias.free.fr/temp/grass_zorder_c.zip In this one a border around the terrain is kept,the plants are aligned to the terrain slopes and better random placement is used. I was also thinking that you could save the z-order banks to a file and load them next time,so you don't have to wait for the z-order calculations when you start the demo. |
| ||
would someone mind taking elias's code and compiling it into a .ese please? im going to be at uni all day and have no access to b3d here.. thanks in advance :) |
| ||
elias - is that true on graphics cards that don't chew through fill rate? and I presume the quads had the same (usable) texture area as the tris? |
| ||
Hey Elias - cool Thing, the Slope Correcture. Do you think it's possible to precalc the Z-Order Info? That would be useful since it takes a remarkable Time to compute. But I also love it already the way it is now. |
| ||
Sorry MasterBeaker :S. Didn't read the entire thread. How did you solve the Z-order problem? |
| ||
@Beaker. Yes you are right the fill rate might have a role in this. But I made the same demo with quads and it was running alomst in the half fps compared to the tris particles. @jfk. I have made a version with precompiled z-order files. I will post it tomorrow along with an implemetation of using grass-map images to place the plants on a terrain. Bye. |
| ||
My own single surface particle system lost speed when using triangles once the triangles were 1:1 witht the quad to make the same sized texture on the screen. You need to scale the triangles rather large to compensate for lack of texture coordinate space. On my card, the fillrate became a bad issue once I made a real-world example. However, if you ever needed sparks, or untextured triangles then a triangle based single surface system is preferred! |
| ||
wasn't sure if anyone had seen this benchmark tool called "CodeCreatures" (www.codecult.com):![]() Think this kind of grass looks good, and everything in this scene we can do (even the cube mapped water). Hopefully someone can figure out how we can handle grass-map's so we can control where the grass goes.... |
| ||
actually here's a better one : ![]() |
| ||
Dave, with the right textures and models im sure this could be achived (also nice Donnie Darko quote!). This grass system is great, I use a quad based single surface vegitation system in Island Storm, but this is much faster and has more flexability. I do grass maps by marking coloured areas on the hightmap and then reading each pixel and translating the coloured ones to 3d coards. Here are a few shots, I just changed ssps_g.bb to work on mesh based terrains, added another grass type and put it on my island. The jpg`s are a little fuzzy. ![]() ![]() |
| ||
Looks great coppercircle! Keep up the good work. -matt |
| ||
Indeed, looks amazing, CopperCircle! |
| ||
CopperCirle: Looks totally amazing! btw i have been meaning to email you recently, but keep getting held up bugfixing dam DX/DXi problems! We should consider a grass system like this for our "other" game. btw have you restarted work on island storm? Email me regarding this. |
| ||
Thanks all, and thanks to jfk, elias_t and MasterBeaker for creating this system, I will post any additions/changes iv make to the code when iv finished. Dave, im working hard again on Island Storm, but still would like to complete our project. |
| ||
Elias - just saw your last post - looking forward to that download! Joker - The Z-Order Sorting Trick is in the Code, just download it. |
| ||
elias_t and MasterBeaker have you had any z order problems when using multiple grass types? |
| ||
If you use multiple grass types then you need to store them on the same texture and surface to make it work. |
| ||
Hiya. Nice shots Coppercircle. About the multiple grass-types z-order problem I am working on something to fix this also... Here is version d of the system: http://telias.free.fr/temp/grass_zorder_d.zip ; version d [14/10/03] ; ; In this version a *.ord file is saved after the first run so there is no ; need to recalculate the z-order banks if the *.ord file is detected. ; If you change the no. of particles the banks will be recalculated. ; ; Also I have added support for grassmaps.If a grassmap is declared ; the function will add grass only on green painted areas of the grassmap. ; You should paint the grassmap with greencolor on a copy of the original ; heightmap and keep the same imagesize. ; ; I added back in vertex coloring of the particles. ; A future use of this could be: If you use a lightmapped terrain ; use the shadowmap values to light accordingly the particles... Bye. |
| ||
Great work, Elias! Thanks a lot! Wow, now I really have to start some kind of Operation Flashpoint clone or something :) |
| ||
I started work on a grass system about a year ago.. They are alot of fun, but very addicitve to make - all the constant tweaking and enhancing that goes in :) Anyways, this system turned out well, it uses a grid - portal lock and an optimized table-lookup routine. It supports animation, elevation smudging, shade/shadow tenting, color deformation and type-chking. I got some of my best FPS results in Blitz using this system, ability to place litterally 100,000+ grass entites on a single map with little slowdown ( not all shown of course ) on a very slow test comp with a 12Mb v-card lol. Anyways the secret is in keeping the surface count down. By using only a handful of entities and taking advantage of the lookup-tables such a system becomes possible. This grass system was to be released in a game we were making that is now been cancelled... i'll chk into releasing it as blitz public domain... ![]() |
| ||
Sabata Rh. Kewl ! I am looking forward to it :) How did you resolved the z-order problem ? Using the same method as Master Beaker ? |
| ||
elias_t, nice update the saved zorder is cool and Sabata I hope your system is released. |
| ||
wow! Nice one sabata. Glad i emailed you now mate, and glad i orginally posted about grass on the general forum. This is what i call community teamwork! |
| ||
Very nice Sabata! Looks very good, and it would be a great asset for the community! John-Robin |
| ||
It's nice to see you're engaged, but it's slightly off topic to post screenshots of "CodeCreatures" or other planed Releases. I'd rather see a new Thread for such things. Just think of the users with 56 kBits, cause this Page is already loading slowly with my 700kBits. Not a big Problem, but remember this next time. |
| ||
Sabatha how did the checking go? |
| ||
Can't you use w-buffer to fix the zorder problem? -Matt |
| ||
Nice trees. Is that TreeMajik work? |
| ||
No. He said earlier that he used 3ds Max. I think I might give tree-making a go. -Matt |
| ||
Thanks for the awsome grass engine.. heres a shot of what i am doing with it. ![]() |
| ||
Wow, that's cool! I know, this Grasstexture I made looks best when you standin the middle of the Grass, if it is watched from the distance it looks a bit repetive. Maybe this can be solved when the "Grass-Pieces" have a randomly set individual (negative) Ground offset. Hope you know what I mean :) When this is normal Grass: ___¦¦¦___ then the following would be a negative Ground offset: ---¦¦¦--- |
| ||
Does anyone know how I might take a texture with several grass types on it. And then stretch only 1 of the several areas of the texture onto each triangle of grass.. Meaning use 1 texture for several grass types. Thanks |
| ||
Easiest way would be to have the grass images in a grid on the texture: 2x2 say. And then just randomly calculate UV coordinates like this:u# = Rand(0,1)*0.5 v# = Rand(0,1)*0.5 u2# = u+0.5 v2# = v+0.5 |
| ||
The problem is: ATM it is using a 512*512 Texture. Next possible Size is 1024*1024 which will eat about 4 MB of Videoram. If it's worth then ok. Using smaller Textures for one Plant will result in blocky, pixelish Contours. But of course, these days most People have 32 Megs or more. An other Aspect is: when you already use more than 16MB, say 18MB, then there is no reason for not to use 31 MB or something. |
| ||
. |