Grass Node v0.3.x
etcaptor- since it can load or create procedurally, i'd go for procedural when you're in the wilderness, but have it load exclusion zones around houses and hand made flowerbeds. for editor options, i guess box/circle select and delete, scale, and change sprite is all it will need.
zenoid- Thanks for the heightmap code, its about 10,000X faster than using a triangle selector! It should work in old irrlicht versions, but it needs camera->getViewFrustrum()->getBoundingBox() which was introduced in either 0.10 or 0.11
zenoid- Thanks for the heightmap code, its about 10,000X faster than using a triangle selector! It should work in old irrlicht versions, but it needs camera->getViewFrustrum()->getBoundingBox() which was introduced in either 0.10 or 0.11
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
cool,,,, I will add a fog in distance so it will hide the being-created particles and terrain interpolating better...(an eye is sensitive to these contrasts on horizont )I got 40fps with maxed distance 2500 and density 1500!..... i have an intel 2,4, ATI radeon 9600agp126mb, sooooo, this is so cool, ....... I am on my way for a TES 5: irrlichtion....vzzzzzssschh
what is this thing...
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
Some time ago i thought about grass. You coud create grass not only from highmap,but from highmap and grass map. for grass map create texture with color coded grass type, example: black color - no grass,red-low grass,blue-flowers,green-2 types mixed grass and so on. After checking grass map,read highmap and set grass high pos.
Good luck.
Good luck.
bitplane, if you want dynamic wind you can use this simple wind generator I wrote by experimenting with perlin noise.
It's not very fast, but it's not too slow either (it works for me).
Just keep in mind that if lights are supposed to work properly you need to update the vertex normals every time you skew the top of the grass.
Anyway, if you (or anyone else) is interested here is the wind generator. (Sorry for making such a tall post, I don't know where else to post it)
IWindGenerator.h
CWindGenerator.cpp
You can look at the demo program I wrote using that wind generator to see how it looks. You'll probably get bad FPS in the demo but that's I was in a hurry and there was little point in optimizing the grass rendering since that's what bitplane is trying to do.
http://www.wc3jass.com/files/WindDemo.rar - Download there
It's not very fast, but it's not too slow either (it works for me).
Just keep in mind that if lights are supposed to work properly you need to update the vertex normals every time you skew the top of the grass.
Anyway, if you (or anyone else) is interested here is the wind generator. (Sorry for making such a tall post, I don't know where else to post it)
IWindGenerator.h
Code: Select all
#ifndef IWINDGENERATOR_H_INCLUDED
#define IWINDGENERATOR_H_INCLUDED
#include <irrlicht.h>
namespace irr
{
namespace scene
{
class IWindGenerator : public IUnknown
{
public:
virtual void setStrength( f32 strength ) = 0;
virtual void setRegularity( f32 regularity ) = 0;
virtual core::vector2df getWind( const core::vector3df& position, s32 timeMs ) = 0;
};
IWindGenerator* createWindGenerator(f32 strength=3.0f, f32 regularity=1.0f);
}
}
#endif
Code: Select all
#include "IWindGenerator.h"
namespace irr
{
namespace scene
{
class CWindGenerator : public IWindGenerator
{
private:
f32 Strength;
f32 Regularity;
public:
void setStrength( f32 strength );
void setRegularity( f32 regularity );
core::vector2df getWind( const core::vector3df& position, s32 timeMs );
};
void CWindGenerator::setStrength( f32 strength )
{
Strength = strength;
}
void CWindGenerator::setRegularity( f32 regularity )
{
Regularity = regularity;
}
inline f32 rndGenerator(s32 x)
{
x = (x<<13) ^ x;
return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
}
inline f32 cosInterpolater(f32 a, f32 b, f32 x)
{
f32 ft = x * 3.1415927;
f32 f = (1 - cos(ft)) * .5;
return a*(1-f) + b*f;
}
inline f32 windSmoother(s32 x)
{
return rndGenerator(x)/2 + rndGenerator(x-1)/4 + rndGenerator(x+1)/4;
}
inline f32 noiseInterpolate( f32 x )
{
s32 intX = (int)(x);
f32 fracX = x - intX;
f32 v1 = windSmoother(intX);
f32 v2 = windSmoother(intX + 1);
return cosInterpolater(v1 , v2 , fracX);
}
inline f32 noise( f32 x )
{
f32 total = 0;
f32 p = 0.50;
s32 n = 4;
f32 frequency = 1;
f32 amplitude = 1;
for ( s32 i=0; i<n; i++ )
{
total += noiseInterpolate(x * frequency) * amplitude;
frequency = frequency + frequency;
amplitude *= p;
}
return total;
}
core::vector2df CWindGenerator::getWind( const core::vector3df& position, s32 timeMs )
{
f32 seed = (timeMs + position.X*7*cos(timeMs/120000.0f) + position.Z*7*sin(timeMs/120000.0f))/ 1000.0f;
f32 dir = 2*core::PI*noise( seed / Regularity );
f32 amp = Strength*sin( seed );
return core::vector2df( amp*cos(dir), amp*sin(dir) );
}
IWindGenerator* createWindGenerator( f32 strength, f32 regularity )
{
CWindGenerator* wind = new CWindGenerator();
wind->setStrength(strength);
wind->setRegularity(regularity);
return wind;
}
}
}
http://www.wc3jass.com/files/WindDemo.rar - Download there
okay, small update with the new wind. Wind is a CPU killer when applied to each blade, but pretty fast if done to a whole area. Also I think wind looks better on billboards, but hey too late for that now. I changed the CWindGenerator.cpp to .h, since most of the functions were inline anyway.
I've not done the generation from image thing yet, expect that next release (0.3)
edit: oh yeah i'm not fixing the normals at all :. light is not supported. where should a quad's normal point to? should I be using twice as many vertices so each side has its own normals?
i've also been thinking about the grass map thing.. hows about this- alpha = density, brightness = height, colour balance = diversity.
edit2: update 0.2.2
i'm now making a grid of current windspeeds instead of calculating for each blade, and only updating it if 30ms have passed. I'm doing the same with the mesh too, fps++
I've not done the generation from image thing yet, expect that next release (0.3)
edit: oh yeah i'm not fixing the normals at all :. light is not supported. where should a quad's normal point to? should I be using twice as many vertices so each side has its own normals?
i've also been thinking about the grass map thing.. hows about this- alpha = density, brightness = height, colour balance = diversity.
edit2: update 0.2.2
i'm now making a grid of current windspeeds instead of calculating for each blade, and only updating it if 30ms have passed. I'm doing the same with the mesh too, fps++
wind should prolly be done on a shader. . .
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars