L3DT users' community
Large 3D terrain generator

Rendering grass and highly detailed terrain textures

Got a problem or need advice?

Rendering grass and highly detailed terrain textures

Postby Aaron » Mon Dec 08, 2008 11:56 am

Hi Everyone,

In response to the frequently asked question of "how do I render blades of grass on terrain?", I've written a guide on rendering grass and highly detailed terrain textures. If you have any questions or would like to discuss such matters, please reply here.

Cheerio,
Aaron.

Pre-emptive snarky off-topic warning: This thread is a 'sticky' and I would therefore request that the discussion remains on the given topic.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Another source of information

Postby Bradicus » Wed May 20, 2009 3:59 am

I found this chapter out of the online version of Nvidia's GPU Gems very enlightening. it's on the topic of billboard grass rendering.

http://http.developer.nvidia.com/GPUGems/gpugems_ch07.html
Bradicus
Newbie
 
Posts: 1
Joined: Wed May 20, 2009 3:43 am

Re: Rendering grass and highly detailed terrain textures

Postby joehot200 » Wed Jul 13, 2016 9:46 pm

For those using jMonkeyEngine, I have got a detail mapping vert/shader that you can download from here:

http://endcraft.net/DetailShaders

Detail map is the one used by L3DT.

For those who do not use jMonkeyEngine, the shader will probably still be of help to anybody using LWJGL or OpenGL, as it demonstrates the use of four samples of the detail map and applying it to the defuse colour, like so:
Code: Select all
 float tile = 80.0; //Amount texture is to be tiled
      vec2 detTex = newTexCoord * vec2(tile);
      vec4 diffuseColor = texture2D(m_DiffuseMap, newTexCoord); //Get the colour from the texture.
      float detailMult = (diffuseColor.r + diffuseColor.g + diffuseColor.b) * 2.0; //This is here so that in black patches of terrain it will not be detail mapped, making it white.
      if (detailMult > 1.0){
        detailMult = 1.0; //Make sure that the detail mapping is not above 1.0.
      }
      float detailIntensity = 1.4; //Intensity of detail. Doesn't quite work as one might expect though.
      vec4 detail = texture2D(m_DetailMap, detTex / vec2(0.5)); //Sample 1, for close-up detail
      detail *= vec4(detailIntensity); //As most of the detail map is white, this will make a lot of it whiter than white.
      vec4 detail2 = texture2D(m_DetailMap, detTex / vec2(1)); //Sample 2, for mid-range detail
      detail2 *= vec4(detailIntensity);
      vec4 detail3 = texture2D(m_DetailMap, detTex / vec2(2)); //Sample 3, for further detail
      detail3 *= vec4(detailIntensity);
      vec4 detail4 = texture2D(m_DetailMap, detTex / vec2(4)); //Sample 4, for far detail.
      detail4 *= vec4(detailIntensity);
      detail += detail2;
      detail += detail3;
      detail += detail4;
      detail /= vec4(4); //Add all the intensities together and then divide by 4, giving the average.
      vec4 detailColor = vec4(1.0) - detail; //Only recommended to use if you use the L3DT default detail map. Because "detail" can be greater than 1, 1 - detail can result in negative values, causing black spots - Which is desired.
      detailColor *= detailMult; //Multiply the detail map by the amount you want to show. Basically, if it is black, you do not want the detail map making it looked speckled and white.
      diffuseColor += detailColor; //Add detail colour to diffuse.


I am using it on a car game I am developing. The results change something like this:
Image
To this:
Image

Here's two other pictures:
Image
Image

Hope this helps someone. Feel free to email me (joehot200 at gmail.com) if anyone has any queries. Though I may take a while to get back to you.
joehot200
Member
 
Posts: 15
Joined: Mon Nov 23, 2015 10:48 pm


Return to Help and support

Who is online

Users browsing this forum: No registered users and 10 guests