basic animated grass

Community Forums/Showcase/basic animated grass

AdamStrange(Posted 2015) [#1]


The engine core has gone from static to realtime now, so I can include animated effects.

Above is a quick demo of the wind/animated grass. The grass is always slowly moving, but when you walk over it, it sways more (decaying). It's actually a wind cloud system, with the grass being plugged into it.

Here are the 1st person and 3rd person view (you can zoom right in from overhead view down to 1st person)




degac(Posted 2015) [#2]
Damn!
I like the swinging...
I would see it in action in a lawn or on a hill. Just to see the wind effect!


AdamStrange(Posted 2015) [#3]
Here's a 1st person shot just looking over the grass - slightly different colour too.



Hardcoal(Posted 2015) [#4]
nice work..!


videz(Posted 2015) [#5]
This is cool. Is this good for a bigger environment?

I'm always intrigued on how do you make good animated grass in blitz3d. Can you share your code or give some pointers? :-)


RemiD(Posted 2015) [#6]
one way to achieve this effect is to progressively rotate the root of the mesh from a start angle to an end angle, and then rotate the other way.

another way to achieve this effect is to progressively change the position of the vertices from a start position to an end position so that it gives the illusion to move.


AdamStrange(Posted 2015) [#7]
@Videz, it's BlitzMax not Blitz3d, but the general concept would work.
Also could be used for a large environment, but you would need to have some form of model culling the further away you get!

The first thing is to decide how to approach this at the model level render.
1 - For each 3d vertex (x,y,z) I also store an offset float parameter. 0=no offset, 1=some offset, 10=lots of offset
2 - each model also has parameters for how much sin effect the wind will have and also the cos (think side to side) movement
3 - the wind is a global effect where you give x,y,z wind power values. The vertexes are then offset with this the cos/sin and the offset variables

In the above example I am using a standard x,y grid for the map. the global Wind is set for each grid position. The renderer then renders each object using this - and it all works.

OK = that's how the general renderer operates.

The grass model itself is made from 3 separate models:
1 - a flat textured 4 vertex plane forms the bottom - this is not moving, but gives depth
2. a 3 sided textured triangular pyramid with the centre at the bottom. This doesn't move either
3. a flat sided dude with no top or bottom. The bottom vertexes are much closer than the top. The top also have different weights applied as offsets
- Both model 2 and 3 are two sided
- All three are combined (grouped together)

That gives you the model, we now need to setup the map

for each copy of the grass (on the xy grid), the grass model will be initial randomly rotated in the y axis and also randomly sized

you then cycle through each map position, decide if it needs to be displayed, then display with the settings you require

I can do a quick tutorial on this if this would help you visualise things?


videz(Posted 2015) [#8]
awesome and yes that would be nice.. but no rush please or if you can spare the time, thanks :)

Thanks guys for the tips!


Derron(Posted 2015) [#9]
Do you have plans how to "auto hide" gras when standing on it (the grass pokes through the basement of the figurine).


@parameters
Do you add them as "effects" (so multiple things could attached) or is it "static" (field windoffset:float) ?


Maybe you could add animated water in a similar way (without caustics/foam ...just the surface movement).

Of course you are able to replace water with lava ... if this fits more to your settings.

bye
Ron


AdamStrange(Posted 2015) [#10]
Hi Ron,
No the Parameters are just for the wind, but there is no reason why they couldn't be used for something else - other effects possibly

Animated water is already covered as is lava (and everything in-between. The materials already support animated materials and there are a number of base materials dealing directly with water, laval, etc

I hear you about the auto hiding of the grass - It's on the check list now - thanks :)


Grisu(Posted 2015) [#11]
Great job. Please make sure it doesn't "stick" through the stone plate under your character.


AdamStrange(Posted 2015) [#12]
@Derron & @Grisu What I've done is to introduce auto scaling of 'grass' where the players/monsters are positioned. This means that grass no longer sticks through the bottom character plate.

This is a sliding scale, so grass actually shrinks around the players as they move. It looks quite nice in operation and solves this issue :)


AdamStrange(Posted 2015) [#13]
Just discovered something whilst testing:
Currently the floor look is random (just testing).
I went into one room and the floor tiles were arranged in a beautiful octagonal pattern in the centre of the floor.

On zooming out the octagonal pattern got more pronounced as you really saw it from above, zooming in, the pattern got less visible (unless you were looking at the floor and (in this case) the floor wasn't covered with grass. its person, the patterns wasn't really visible at all.

This sorta means that there is the first game mechanic - puzzle hints, floor drawings, only visible from certain angles. It also means that small things on the floor may not be seen from certain viewpoints


Derron(Posted 2015) [#14]
Hide and Seek ... the author hides the things, the players seek things.

I played Pixel Dungeon (open source roguelike game for android) :
https://github.com/watabou/pixel-dungeon

And they used a "explore" button. A descendant of the Game ("Shattered Pixel Dungeon") uses some kind of "stay there for a while and it unvails".

In both cases you discovered "traps" or hidden doors.


Mixing "discover" and "auto hiding grass" I could think of the following "puzzle": if you move over grass (or whatever) it shrinks for a specific time. So when moving further it "slowly" grows back to normal size. If you move multiple tiles fast enough, you might see previously hidden doors in the bottom or hints like "direction arrows". Another option is to hide "knobs" or "switches" in that grass areas. Once you "discovered" them, they stay visible to get used properly.

bye
Ron


AdamStrange(Posted 2015) [#15]

And they used a "explore" button. A descendant of the Game ("Shattered Pixel Dungeon") uses some kind of "stay there for a while and it unvails".

In both cases you discovered "traps" or hidden doors.


That is an excellent concept. I like the wait and things reveal after a while - could be a very cool mechanic!

I checked out pixel dungeon - great soundtrack, the first I really liked.


Derron(Posted 2015) [#16]
Ah... of course the "waiting time" should depend on some skill level ... so a rogue who is trained in "hiding" should reveal things in a shorter time, while a bloody-minded-barbarian will need hours to understand that this switch might be a switch.


bye
Ron


AdamStrange(Posted 2015) [#17]
OK, so now I have the very basic framework operational I can work on the AI.

My first attempt is a modified wander. It goes something like this:
1. is way ahead clear? if it is the move forward
2. are we too far from the walls? then collide
3. have we hit a wall? then collide
4. have we collided? pick a rotation direction and rotate
5. repeat

this gives a very basic wander process with wall hugging/ centre hugging traits.

What are your thoughts on monster AI?


stayne(Posted 2015) [#18]
I wrote some basic wandering AI code a while back. Very sophomoric but it was all I needed.




AdamStrange(Posted 2015) [#19]
Implemented turn to face and 'bullet' firing

A bullet can be anything that moves in a generic straight line and dies when hitting a wall or character, etc

The bullet inherits the casters direction, so a monster must be facing in the correct direction to fire.

I've also been looking at how John Carmack approached the monster AI in Doom etc.


AdamStrange(Posted 2015) [#20]
Here's a couple of shots showing the new dynamic lighting, animation, monster firing, etc



both in 1st and 3rd person


Derron(Posted 2015) [#21]
Here's a couple of shots showing [...] animation [...]


I do not see the animation. Help 1!one!1.

I like the "monster" ... seems like a hexed statue made out of stone to me :p.

The floor-color makes it look like if there is a rectangular "darker" area in the green lighted zone ... just because "dark grey" meets the bright patterns there. I assume the color is like a "gradient" fading out to "world light color" (aka "normal")?


@shadow in the second screen
The shadow of the dwarf seems to get cut instead of more smoothly fading into the plates color.


@shoulder plates
they seem to be NOT connected to their outer border (black pixel dots), same for the right foot front (like a distorted black pixel outline).


But hey... this is one of the threads I like to look at, so no offence meant with the above feedback.


bye
Ron


AdamStrange(Posted 2015) [#22]
Sorry about not showing the animation. Here it is:


@Derron. yep agreed about the dwarf shadowing. it's a model fault. I'll need to go in and re-edit the face triangles.
Also the black outline is intended - there has been extra work done in the renderer and this was one of the results - it gives light and black outlines round objects.


RemiD(Posted 2015) [#23]
Your enemy looks weird... But why not.
Maybe try to decrease the transparency or to make it opaque, it may look better.


Derron(Posted 2015) [#24]
I like the jumping of the barrel ... it just needs some stretching and bending to make it "disney-esc" :p


@outline
hmm I just recognize it at the coloumns front bottom part - the white outline - or is this something different?

The Outline at the "dwarf" has holes which makes it looking like distortions or pixel artifacts - maybe this outlining needs a bit of improvement. Also it might look better if they get a "smoothing" (antialiasing) and a 2px width - but on the other side this might look more "toonish" than desired.


@bullets
They surely are scaled properly when nearing the camera but for now it looks a bit "flat". Maybe they should have a lower initial scale and grow the first bunch of milliseconds ... same for the alpha value. So they do not appear as if they got shot out of a gun but are "created" out of dust or inner beings of the monster..

That "alpha" thing is even more problematic, as the monster is "alphaed" but the bullets are fully opaque.


@Hexagon unit ground
If that resembles some kind of "movement limitation" the whole scenery should have a hexagonal look too (for now it looks like if you can move freely. In that case a "round unit ground" might fit better - and resembles the look of board games with "plastic ground" and figures to stick on them. ... but of course this is artistic freedom, so do like YOU want, not as old ranting Ron "demands".


bye
Ron


AdamStrange(Posted 2015) [#25]
There is currently no scaling of the bullets. They are just placeholders for testing.
Eventually they will be removed and become emitters for the particle system.

Hmm the figure bases. square didn't cut it - round is too many vertexes (and I've never liked round bases), but I like the hex bases - so currently they are staying. They also give you a nice visual clue that round bases lose.


Derron(Posted 2015) [#26]
Then octagons/octaeders - like the colo(u)mns and the barrel have. ... No seriously: it is up to you and surely just a matter of getting used to something.


@bullets
one of the three shots seems to "jump" (like it is thrown in an upwards curve until gravity sums up enough force to bring it down again). Also the bullets "spread" on the horizontal axis, so I assume it is a different movement formula?


bye
Ron