Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Creation

Snow system

Shaders, Level design, Sound design, Special effects

Snow system

Postby FF.Fan » 13 May 2012, 00:48

Hi,

I'm trying to reproduce the effect of snow deformation on the ground as seen in this video at second 30" (snow battlefield in Virtua Fighter 4)

I managed to get what i want, I use the mesh api to access each vertex and calculate everything, but the problem is as soon as I increase the size of the terrain (bigger like more than 32*32), of course, everything get's laggy as I go through each pixel, every frame ! lol ...

Question is : have you got some idea or other method to improve the speed ?

I hope I will not have to stick with small area snow in a scene
Here is a screen of the snow implemented in the sample of shadow detection i provided earlier :

Image
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby TRANE23 » 13 May 2012, 09:45

So your problem is the Vertex access on a surface with a lot of Poly. Try using a chunks system(with size < 32*32) by partitioning your space, detect the current chunk(with sensor or collider) and do the job with mesh api only on this one.
TRANE23
Senior Boarder
Senior Boarder
 
Posts: 53
Location: France

Re: Snow system

Postby FF.Fan » 13 May 2012, 10:33

TRANE23 wrote:So your problem is the Vertex access on a surface with a lot of Poly. Try using a chunks system(with size < 32*32) by partitioning your space, detect the current chunk(with sensor or collider) and do the job with mesh api only on this one.


thanks, partitionning in chunk is indeed a good idea ! i'll try it.

When i woke up this morning I got an idea, as my problem is to know which vertex is concerned without going through all vertices of the poly, then, as the snow area doesnt move too, what about precompute in a big hastable all the vertices position and then i just need to pick the one closest on the hashtable and do my thing.

I'll try both method and see what's working.

Thanks again.
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby TRANE23 » 13 May 2012, 12:03

I think it will be slower, you'll have to test all vertices in the hashtable and I'm pretty sure the access via mesh API will be faster than via hashtable(if it's a big one).
A more complex way would be using a space data structure to store the vertex like a BSP or an R-Tree which will allow you to discard vertices for the "closest test" but imo the chunks and the sensor will give you approximately the same FPS result and is much easier to code.
You could also mixing the two methods : bigger chunks with Partition Space Data Structure to discard vertices during the test :D.
TRANE23
Senior Boarder
Senior Boarder
 
Posts: 53
Location: France

Re: Snow system

Postby FF.Fan » 13 May 2012, 12:26

TRANE23 wrote:I think it will be slower, you'll have to test all vertices in the hashtable and I'm pretty sure the access via mesh API will be faster than via hashtable(if it's a big one).
A more complex way would be using a space data structure to store the vertex like a BSP or an R-Tree which will allow you to discard vertices for the "closest test" but imo the chunks and the sensor will give you approximately the same FPS result and is much easier to code.
You could also mixing the two methods : bigger chunks with Partition Space Data Structure to discard vertices during the test :D.


I think you are totally right about that, its indeed the same if I use a big hashtable.
I try the chunks & sensor approach.

I really don't know anything about R-Tree, BSP and other. I looked on Wikipedia but its look kind of tedious to implement ^^

Thanks a lot anyway !
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby FF.Fan » 13 May 2012, 18:49

Yay ! I finally got the chunked system working ! its nice an smooth with big area now ;)
Thanks for the advice.

the only problem with that technique is, as seen in this screenshot, the material.

Image
Indead, as its a separated mesh, it doesnt shade the same. Is there another trick ?
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby TRANE23 » 13 May 2012, 21:45

You have to set the same normal for the common vertices
TRANE23
Senior Boarder
Senior Boarder
 
Posts: 53
Location: France

Re: Snow system

Postby FF.Fan » 14 May 2012, 21:42

i'll try, thank you again !
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby FF.Fan » 16 May 2012, 18:14

Well as each chunk is a separated mesh, i can't really manage to get the overlapped vertices and set them to the same normal :(
any hints ?
thanks
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby NiCoX » 16 May 2012, 21:20

Hi,

There are many solutions, but perhaps the easiest at this point of the development (to not rewrite all) would be a "polish" post pass: for a given "frame", once you have modified the affected chunks using your existing algorithm, you just have to run an average filter on the (modified) borders normals, taking into account, obviously, the adjacent chunks. And the same (and in the same time/pass) for positions, welding vertices to avoid holes. This can be pretty fast as you'll only work on a limited set of points.
User avatar
NiCoX
Platinum Boarder
Platinum Boarder
 
Posts: 5643
Location: France

Re: Snow system

Postby Deivid L. » 17 May 2012, 02:33

wow! thanks brother
This is very useful.
Deivid L.
Fresh Boarder
Fresh Boarder
 
Posts: 14

Re: Snow system

Postby FF.Fan » 17 May 2012, 08:42

Thanks for the tips, unfortunately i can't test right now, maybe tonight, if I manage to do what i want, I'll post the code sample for everyone :)
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby FF.Fan » 18 May 2012, 20:02

I really can't make it, if somebody is kind enough to explain me :
here is the source : https://docs.google.com/open?id=0BzzqHewTzXc-X1I0bnNmdVY2d1E
thanks
User avatar
FF.Fan
Gold Boarder
Gold Boarder
 
Posts: 270
Location: France

Re: Snow system

Postby TRANE23 » 21 May 2012, 10:10

Check your PM
TRANE23
Senior Boarder
Senior Boarder
 
Posts: 53
Location: France

Re: Snow system

Postby juaxix » 23 Oct 2012, 11:32

I have tested the code, it is a nice idea, did you improve this?
User avatar
juaxix
Platinum Boarder
Platinum Boarder
 
Posts: 321
Location: Spain

Next

Return to Creation