🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Convincing trees

Started by
95 comments, last by VanKurt 20 years, 9 months ago
Yep, it looks like there is a problem with z-fail. Can you be specific about your texture format, and how you created and rendered it ?

Oh btw, forgot about this reply:
quote:
What is this concept about ? If you have z-information, how can you use it with 2D quad so that DirectX doesn`t care ? Do you then "copy" Zbuffer values of the tree into Z-Buffer directly ?

The idea is to convert the z-information into a bumpmap, so that perspective lighting can be preserved, even on a flat surface.

quote:
Also Yann, how many rotations of same tree do you allow per scene ?

More or less infinite. It''s an image cache, so the tree gets splatted in whatever position he was at the moment the LOD decided to convert it to a texture. But for better efficiency, I somewhat quantize (snap) the rotation angles, currently to 10 degrees precision. This will decrease the number of cache usage.

quote:
Yann, those trees you showed us, how many tris do they have actually in your case ?

The trees I normally use have approx. 20,000 to 150,000 faces.

quote:
20.000 would seem as an overkill for just one tree until there is just one in the scene.

20k is far from enough for a big realistic tree. You need around 100k for those. And about the performance: well, that''s what the LOD system is there for.
Advertisement
quote: Original post by Yann L
20k is far from enough for a big realistic tree. You need around 100k for those. And about the performance: well, that''s what the LOD system is there for.


Can''t get my artists to build high level characters, let alone trees... How do you force them too ? Alcohol ? Torture ?... :=



-* So many things to do, so little time to spend. *-
-* So many things to do, so little time to spend. *-
@Ingenu:
Try XFrog! It works without wanting cash, food or anything ;-)

@Yann:
Well, I just use a 512x512x4 Texture. I set the clear-color-alpha to 0 and render the tree as I do with the 3D version.
Then I copy this image via glCopyTexImage2D to a texture.
Done!
quote: Original post by Ingenu
Can''t get my artists to build high level characters, let alone trees... How do you force them too ? Alcohol ? Torture ?... :=

Heh, we always have those company sponsored pool parties for high-poly artists (and programmers of course), with lots of naked wo..., uh, well, I think that''s confidential...

Seriously though, we use XFrog for all our trees, plants, and general vegetation.

quote:
Well, I just use a 512x512x4 Texture. I set the clear-color-alpha to 0 and render the tree as I do with the 3D version.
Then I copy this image via glCopyTexImage2D to a texture.

That''s weird. It definitely looks like a depth buffer problem.
Allright! I reduced the problem to one last thing:



As you can see in this image the alpha of the texture (left) looks a little strange; there seems to be only 1/0 or visible/invisible! I don''t think that this is a problem occuring while rendering this quad (all other objects look ok), but rather something going wrong while rendering this texture.
But when the tree is rendered to the screen (right) and NOT to a texture it looks good... (the leafs are smoothly blended into the background).
(Btw.: The green border around the leafs (left) is my BG-color... )

Could you help me out AGAIN??? Thanks!!!
First suggestion would be to check the number of alpha bits you have got in the texture you are rendering to. While you may be requesting 8-bit alpha, is that what its giving you?
Just looked through the whole post again, and was wondering how people are creating their trees. Are they generated in a tree editor offline and the data saved out, or generated at runtime from a seed value? Each option has its benefits and draw backs, was justing wondering what people found best (whether using 3rd party programs or not).
I set my texture up this way:

GLuint uberTex;void InitTEX( void ){	int size = 256;	int channels = 4;	unsigned int *pTexture = NULL;  	pTexture = new unsigned int [size * size * channels];	memset(pTexture, 80, size * size * channels * sizeof(unsigned int));    	// Register the texture with OpenGL and bind it to the texture ID	glGenTextures(1, &uberTex);                                	glBindTexture(GL_TEXTURE_2D, uberTex);                    	// Create the texture and store it on the video card	glTexImage2D(GL_TEXTURE_2D, 0, channels, size, size, 0, GL_RGBA, GL_UNSIGNED_INT, pTexture);                        	// Set the texture quality	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	// Since we stored the texture space with OpenGL, we can delete the image data	delete [] pTexture;                                           }




Then I render my texture like this:

glPushMatrix();		// Setup vieport		glViewport(0, 0, 256, 256);		// Translate to right position		glTranslatef( 0, -35, -85 );		// Render the Model		model.Render();		// Bind texture		glBindTexture(GL_TEXTURE_2D,uberTex);		// Copy data to texture		glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 256, 256, 0);		glClearColor(0.3f, 0.0f, 0.0f, 1.0);		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Set our viewport back to it''s normal size		glViewport(0, 0, 1152, 864);	glPopMatrix();
Well, if you''re rendering to the normal display buffer rather than a p-buffer then it shouldn''t be a problem, as rendering directly to the normal buffer without the render to texture works. Could be dest alpha perhaps, or some other frame buffer test that sets a hard on/off limit.
You might want to make sure the internal format of the texture is RGBA8 or similar if you intend to use the alpha bits. Otherwise you might get a 16 bit texture with one bit of alpha on some implementations, unless the user has a quality flag set in the control panel.

This topic is closed to new replies.

Advertisement