Page 12 of 21

Posted: Tue Sep 04, 2007 6:53 pm
by Kerion
So if I am understanding you correctly, I would need to add a pass to the terrain material (easy enough), which has a fragment shader which calculates the interpolation. The result of that fragment shader (the final interpolated texture), would then be used for the lightmap pass of the terrain? That sound about right?

Posted: Tue Sep 04, 2007 6:55 pm
by CABAListic
Yes, but the pass with the fragment shader already *is* the lightmap pass of the terrain, just to prevent any misunderstandings :)

So, better say that you would replace the lightmap pass of the demo material with your customised interpolating pass.

Posted: Tue Sep 04, 2007 6:57 pm
by Kerion
Sounds great. When I get it working, I will post a video of ETM + Caelum doing time correct lightmaps :D

Posted: Tue Sep 04, 2007 9:18 pm
by CABAListic
Ok, new release is out, get it at the usual place: ETM v2.2

Changes in this version:
  • Fixed bounding boxes of terrain tiles (were not updated correctly when editing terrain)
  • Fixed a crash when setting maxLOD to 1 and enabling lodMorph
  • Feature: Added optional vertex normals (needed for dynamic lighting)
  • Feature: Added base texture creation to SplattingManager (see demo)
  • License: Switched to the less restrictive GPLv2 with runtime exception. You can now link statically even in closed source apps, if you like.
Base textures have varied uses :) You can even use them with the minimap creation function for more detailed minimaps, basically a sort of top-down view on your map:
Image

Have fun.

Posted: Tue Sep 04, 2007 9:24 pm
by Kerion
Hey, one more quick question for you. In PSLighting.cg is defined as:

void main
(
float2 iTexCoord0 : TEXCOORD0,
out float4 oColor : COLOR,
uniform sampler2D lightMap
)
{
oColor = tex2D(lightMap, iTexCoord0);
}

Which is simple enough, but where is the lightMap parameter coming from? Is that being assigned internally by ETM? If so, in my case, I guess I will leave that as is but change the definition to:

void main
(
float2 iTexCoord0 : TEXCOORD0,
out float4 oColor : COLOR,
uniform sampler2D lightMap,
uniform sampler2D lightMapInter0,
uniform sampler2D lightMapInter1
)

In my final engine, I would likely modify ETM so that it's not passing a lightmap texture I don't need, but for the quick and dirty hack to get this to work, I am guessing that lightMap is passed in internally and that I will be setting the lightMapInter0 and lightMapInter1 properties (I know I will be doing that, I am just curious about the lightMap argument).

Posted: Tue Sep 04, 2007 9:31 pm
by CABAListic
Nope, this is not coming from ETM, it's coming from the material. It's simply the texture unit from the material pass specifying the lightmap. So for your case you would indeed replace it with two parameters, just as in the material pass you need to define two texture units.

Posted: Tue Sep 04, 2007 9:49 pm
by Kerion
Ah, so OGRE does that automatically. For all the years I've been playing with OGRE, this is the first time I am playing with fragment shaders. So OGRE automatically associates each texture unit defined with the n'th sampler2D used in the parameters?

So really all I need to do from frame to frame is make sure the texture_units are updated with the correct lightmap and pass in the interpolation factor. Hmm, this isn't going to be nearly as difficult as I thought. Thanks again Cabal!

Posted: Wed Sep 05, 2007 2:02 am
by Brocan
CABAListic wrote:Ok, new release is out, get it at the usual place: ETM v2.2
Thanks for revision and new features, impressive as always :D

Posted: Wed Sep 05, 2007 3:56 am
by Kerion
Well I've got the lightmap interpolation working, and so far it looks great. I still need to do a couple of things, like adjust the ambient light used to make the light map based on time of day (right now I am using a flat 0.5, 0.5, 0.5 ambient).

Does anyone know a realistic formula to approximate the curve of light as the sun rises and falls? I doubt it's a perfectly linear fall off, though I guess a linear one would approximate it well enough for most situations.

Posted: Wed Sep 05, 2007 4:50 am
by Kerion
It all looks good, accept that the Caelum skydome is wayyyy above the terrain, in such a way that a giant band of "nothing" (fog basically) is left between the bottom of the skydome and the terrain horizon. Have to play with that a little a bit.

Posted: Wed Sep 05, 2007 9:25 am
by Vectrex
Kerion wrote:Well I've got the lightmap interpolation working, and so far it looks great. I still need to do a couple of things, like adjust the ambient light used to make the light map based on time of day (right now I am using a flat 0.5, 0.5, 0.5 ambient).

Does anyone know a realistic formula to approximate the curve of light as the sun rises and falls? I doubt it's a perfectly linear fall off, though I guess a linear one would approximate it well enough for most situations.
Doesn't caelum also set the ambient light over time?

Posted: Thu Sep 06, 2007 4:27 am
by Kerion
Vectrex wrote:
Kerion wrote:Well I've got the lightmap interpolation working, and so far it looks great. I still need to do a couple of things, like adjust the ambient light used to make the light map based on time of day (right now I am using a flat 0.5, 0.5, 0.5 ambient).

Does anyone know a realistic formula to approximate the curve of light as the sun rises and falls? I doubt it's a perfectly linear fall off, though I guess a linear one would approximate it well enough for most situations.
Doesn't caelum also set the ambient light over time?
Not that I could tell. At any rate, I got a very realistic curve going for the lightmap generation and it looks good at this point. At high speed the interpolation is somewhat obvious (like in 1:1024 time scale), but in a more game realistic time scale (say 1:24 or 1:12), it will be hardly noticeable but should give a nice realistic feel to the shading of the terrain.

Posted: Fri Sep 07, 2007 11:59 am
by OgreUser
Great job :D
A lil screenie for teh bump :

Image

Posted: Fri Sep 07, 2007 4:39 pm
by KungFooMasta
That terrain looks good! :shock:

Posted: Fri Sep 07, 2007 5:07 pm
by Kerion
Hey OgreUser, I don't suppose I could get the heightmap and splat data for that terrain could I? I would love to use that as a test terrain for this lightmap interpolation. Your terrain looks great, so I figure it will make a great video.

Posted: Fri Sep 07, 2007 10:09 pm
by OgreUser
Hey Kerion :)
Indeed I hadn't saved, but I tried to make another one, as similar as possible, and another one for bonus :wink: .

I zipped all I could find in the ET media folder needed for the terrain :

1. http://fileho.com/download/3e7ccb263412 ... 1.zip.html


2.
Image
http://fileho.com/download/d86e70280878 ... 2.zip.html

Posted: Fri Sep 07, 2007 10:11 pm
by Kerion
Spectacular, thanks. I will post some videos of the lightmap stuff soon I hope. Still working on an issue with Caelum.

Posted: Fri Sep 07, 2007 10:31 pm
by CABAListic
Hehe, nice work, especially considering that the sample is just a demonstration and not a real editor in any way :D

Posted: Fri Sep 07, 2007 11:01 pm
by KungFooMasta
I'm curious, has anybody developed a ETMaterial class, that can manage switching, adding, and removing splatting textures? (this would have to interface the splats per pass also, and create/destroy passes on the fly) I wonder if a Brush Class would be needed, and if it would, would it be part of the ETMaterial class or not, since it could be used for deforming. (interested in the design and if anybody has done it. :) )

When I get back to tinkering with ETM, hopefully at the end of this year, I will start working on one, if nobody else has. I remember an ETMaterial class in the first release of ETM, the would probably be a good place to start.

Posted: Sat Sep 08, 2007 5:10 am
by neocryptek
Could someone upload these somewhere else where you don't need to use Internet Explorer and download some adware (or worse?) plugin just to download the files?

And thanks OgreUser, they look great!

Posted: Sat Sep 08, 2007 9:24 am
by OgreUser
My bad, rapidshare should be fine :

http://rapidshare.com/files/54176385/ET ... k.zip.html

Posted: Sat Sep 08, 2007 9:31 am
by Kerion
Hmmm, perhaps I am missing something, but how do I get ET to use the ETbase.png as it's base texture?

Posted: Sat Sep 08, 2007 10:19 am
by CABAListic
By creating a corresponding terrain material :)
This might look something like this:

Code: Select all

material Terrain
{
  // specify the distance at which to switch to the base texture
  lod_distances 300
  
  // insert here your usual splatting based technique
  // technique { ... }
  // ...
  
  // simple base texture pass
  technique
  {
    lod_index 1
    
    pass
    {
      // base texture
      texture_unit
      {
        texture base.png
      }
      
      // lightmap
      texture_unit
      {
        texture lightmap.png
        colour_op modulate
      }
    }
  }
}
Basically you add another technique for lower LOD rendering which just uses your base texture modulated by the lightmap. But I've not tried this, it's just off the top of my head, so you probably need to tweak it a bit :)

Also note that you should use a fairly large (2048x2048) base texture, otherwise this just won't look good.

Posted: Sat Sep 08, 2007 6:58 pm
by Dibalo
This might be a stupid question: How large maps ETM can handle with proper fps? Let´s say we have up to six splatting textures and lightmap.

Posted: Sat Sep 08, 2007 7:22 pm
by jjp
Dibalo wrote:This might be a stupid question: How large maps ETM can handle with proper fps? Let´s say we have up to six splatting textures and lightmap.
Depends entirely on the system you want to use, on the size of the textures and on what else is in your scene. You'll have to test it yourself, there is no other way of knowing.