So, ummm, we are like doing grass now? May I join?



Code:
void World::CreateGrass()
{
	RN::Model *grass = RN::Model::WithFile("models/dexsoft/grass/grass_1.sgm");
	grass->GetMaterialAtIndex(0, 0)->culling = false;
	grass->GetMaterialAtIndex(0, 0)->discard = true;
	grass->GetMaterialAtIndex(0, 0)->override = RN::Material::OverrideGroupDiscard | RN::Material::OverrideCulling;
	
	RN::InstancingNode *node = new RN::InstancingNode(grass);
	RN::Random::MersenneTwister random;
	
	for(int i = 0; i < 50000; i ++)
	{
		RN::Vector3 pos = RN::Vector3(random.RandomFloatRange(-100.0f, 100.0f), 0.0f, random.RandomFloatRange(-100.0f, 100.0f));

		RN::Entity *ent = new RN::Entity(grass, pos);
		entity->SetScale(random.RandomFloatRange(2.5f, 3.0f));
		entity->SetRotation(RN::Vector3(random.RandomFloatRange(0, 360.0f), -90.0f, 0.0f));
		
		node->AttachChild(entity);
	}
	
	
	_camera->ambient = RN::Vector4(0.127, 0.252, 0.393, 1.0f) * 2.0f;
	
	_sunLight = new RN::Light(RN::Light::Type::DirectionalLight);
	_sunLight->SetRotation(RN::Quaternion(RN::Vector3(60.0f, -60.0f, 0.0f)));
}



Edit: We added a fast path that covers exactly these kinds of things. Same code, "little" bit different FPS (it's capped at 1000):


Edit2: Added another fast path. 1 million grass entities, my CPU is bored as fuck... GPU on the other hand is currently crying about the fragment operations.


(to be fair, the screenshot is NOT staged, but the FPS changes quite heavily depending on how good it is with keeping up with all the fragments. But then again, I'm on a shitty HD 6770M, so with an actual GPU this isn't impossible to achieve in a stable way)

Here is how this looks in the profiler: http://cl.widerwille.com/T2lx

Last edited by JustSid; 12/20/13 02:18.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com