Editable Terrain Manager [v2.2 released]
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
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?
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
Ok, new release is out, get it at the usual place: ETM v2.2
Changes in this version:
Have fun.
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.
Have fun.
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
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).
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).
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
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!
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!
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
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.
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.
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
-
- Ogre Magi
- Posts: 1266
- Joined: Tue Aug 12, 2003 1:53 am
- Location: Melbourne, Australia
- x 1
- Contact:
Doesn't caelum also set the ambient light over time?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.
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
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.Vectrex wrote:Doesn't caelum also set the ambient light over time?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.
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
-
- Gnoblar
- Posts: 13
- Joined: Mon Jul 16, 2007 7:51 pm
Hey Kerion
Indeed I hadn't saved, but I tried to make another one, as similar as possible, and another one for bonus .
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.
http://fileho.com/download/d86e70280878 ... 2.zip.html
Indeed I hadn't saved, but I tried to make another one, as similar as possible, and another one for bonus .
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.
http://fileho.com/download/d86e70280878 ... 2.zip.html
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
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.
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.
- neocryptek
- Gnome
- Posts: 335
- Joined: Sat Mar 01, 2003 11:21 pm
- Location: Idaho, USA
- Contact:
-
- Gnoblar
- Posts: 13
- Joined: Mon Jul 16, 2007 7:51 pm
-
- Goblin
- Posts: 235
- Joined: Wed Feb 05, 2003 5:49 am
- Contact:
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
By creating a corresponding terrain material
This might look something like this:
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.
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
}
}
}
}
Also note that you should use a fairly large (2048x2048) base texture, otherwise this just won't look good.
-
- Silver Sponsor
- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
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.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.
Enough is never enough.