ogre 2.1 terrain question
- nevarim
- Gnoll
- Posts: 675
- Joined: Mon Jul 05, 2010 6:16 pm
- Location: Pavia Italy
- x 4
- Contact:
ogre 2.1 terrain question
hi all
i saw that in sample2 there is no samples about terrain usage
there is somthing new about this part of ogre? (ogreterrain)
thanks
Neva
i saw that in sample2 there is no samples about terrain usage
there is somthing new about this part of ogre? (ogreterrain)
thanks
Neva
i'm a noob until proven otherwise
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
- Thyrion
- Goblin
- Posts: 224
- Joined: Wed Jul 31, 2013 1:58 pm
- Location: germany
- x 8
Re: ogre 2.1 terrain question
http://www.ogre3d.org/forums/viewtopic.php?f=25&t=88798
The Terra system is WIP and still not merged into 2.1 "main"
The Terra system is WIP and still not merged into 2.1 "main"
-
- Gremlin
- Posts: 178
- Joined: Fri Dec 24, 2010 7:55 pm
- x 10
Re: ogre 2.1 terrain question
On my setup the terrain sample is purple and shiny. Is that just a WIP thing?
dark_sylinc posted a screenshot in the thread Thyrion linked and it looked similar there too. But the other screenshots in that thread look correct with, well... green?
http://i.imgur.com/swSzem7.jpg
Quite keen to play around with it but just wondered if that was an issue with my graphics card not supporting something? I'm not even sure if I'm using Forward3D or not, I haven't changed anything in the sample code.
dark_sylinc posted a screenshot in the thread Thyrion linked and it looked similar there too. But the other screenshots in that thread look correct with, well... green?
http://i.imgur.com/swSzem7.jpg
Quite keen to play around with it but just wondered if that was an issue with my graphics card not supporting something? I'm not even sure if I'm using Forward3D or not, I haven't changed anything in the sample code.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: ogre 2.1 terrain question
That's because of extremely poor choice of material parameters (metalness, roughness & the textures). The purplenish was a test texture to check the diffuse was working and it was just never replaced (replacing textures is tricky because it has to look good and have a small impact on the repository size)Arkiruthis wrote:On my setup the terrain sample is purple and shiny.
It's one of the most recent additions and thus the least tested ones. Particularly someone reported a few potential bugs with metalness and textures, but shouldn't be too hard to fix. I just haven't found the time yet.Is that just a WIP thing?
-
- Gremlin
- Posts: 178
- Joined: Fri Dec 24, 2010 7:55 pm
- x 10
Re: ogre 2.1 terrain question
Ah okay, no worries! Thanks Matias.
- nevarim
- Gnoll
- Posts: 675
- Joined: Mon Jul 05, 2010 6:16 pm
- Location: Pavia Italy
- x 4
- Contact:
Re: ogre 2.1 terrain question
in 2.1 there isn't this terrain sample right?
i'm a noob until proven otherwise
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
-
- Gremlin
- Posts: 178
- Joined: Fri Dec 24, 2010 7:55 pm
- x 10
Re: ogre 2.1 terrain question
What platform are you compiling on?nevarim wrote:in 2.1 there isn't this terrain sample right?
On Windows, inside the Visual Studio solution (OGRE.SLN) there should be a sub-project called "Sample_Tutorial_Terrain".
Did you select "CMAKE_BUILD_SAMPLES2" in the CMake setup? (it's off by default)
- Thyrion
- Goblin
- Posts: 224
- Joined: Wed Jul 31, 2013 1:58 pm
- Location: germany
- x 8
Re: ogre 2.1 terrain question
You know what a branch is?nevarim wrote:in 2.1 there isn't this terrain sample right?
Branches:
- v2-1 -> ogre 2.1 main branch -> no terrain sample
- v2-1-pso -> ogre 2.1 development branch -> has the terrain sample
- v2-1-metal -> another development branch
"v2-1-pso" and "v2-1-metal" will be merged into v2-1 if finished/stable.
You can test the others if you don't want to wait.
-
- Gremlin
- Posts: 178
- Joined: Fri Dec 24, 2010 7:55 pm
- x 10
Re: ogre 2.1 terrain question
Ah yep, I'm on the v2-1-PSO branch, I should've mentioned that.
- nevarim
- Gnoll
- Posts: 675
- Joined: Mon Jul 05, 2010 6:16 pm
- Location: Pavia Italy
- x 4
- Contact:
Re: ogre 2.1 terrain question
great this is working, but there isn't more the sample for to modify terrain?
i'm a noob until proven otherwise
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
used in my project and thanks to everyone
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
Hello! I am trying to integrate Terra in my engine, but I am getting a crash in update... this is what I am doing:
this is the callstack (for some reason I can't examine the actual line inside addRenderable... although ogre is in Debug mode):
it doesn't crash but obviously i don't see the terrain
if I set rootNode->setVisible(false); it also don't crash but again... no visible
if I create an empty datablock:
please help!
Code: Select all
void yTerraManager::init(){
Ogre::Root* root = Ogre::Root::getSingletonPtr();
Ogre::HlmsManager *hlmsManager = root->getHlmsManager();
Ogre::SceneManager* sceneManager = yGraphicsServices::getGraphicsSceneNodeManager().getMainSceneManager();
Ogre::Camera* camera = yGraphicsServices::getGraphicsCameraManager().getMainCamera();
Ogre::RenderWindow *renderWindow = yGraphicsServices::getGraphicsRender().getRenderWindow();
Ogre::CompositorManager2 *compositorManager = root->getCompositorManager2();
Ogre::ArchiveVec library;
std::string renderSystemAppend = "GLSL";
Ogre::String buffer;
if( yUtils::getConfigFileSetting("RenderSystem", buffer) && buffer == "D3D" ) {
renderSystemAppend = "HLSL";
}
Ogre::Archive *archiveTerra = Ogre::ArchiveManager::getSingletonPtr()->load( "../../yoyEngine/media/Hlms/Terra/"+renderSystemAppend, "FileSystem", true );
Ogre::Archive *archiveLibraryCommon = Ogre::ArchiveManager::getSingletonPtr()->load("../../yoyEngine/media/Hlms/Common/"+renderSystemAppend, "FileSystem", true );
Ogre::Archive *archiveLibraryCommonAny = Ogre::ArchiveManager::getSingletonPtr()->load("../../yoyEngine/media/Hlms/Common/Any", "FileSystem", true );
Ogre::Archive *archivePbsLibrary = Ogre::ArchiveManager::getSingletonPtr()->load("../../yoyEngine/media/Hlms/Pbs/"+renderSystemAppend, "FileSystem", true );
Ogre::Archive *archivePbsLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load("../../yoyEngine/media/Hlms/Pbs/Any", "FileSystem", true );
library.push_back( archiveLibraryCommon );
library.push_back( archiveLibraryCommonAny );
library.push_back( archivePbsLibrary );
library.push_back( archivePbsLibraryAny );
Ogre::HlmsTerra *hlmsTerra = OGRE_NEW Ogre::HlmsTerra( archiveTerra, &library );
hlmsManager->registerHlms( hlmsTerra );
#ifdef DEVELOPER
QDir().mkdir("./hlmsShaders/terra/");
hlmsTerra->setDebugOutputPath(true,"./hlmsShaders/terra/");
#else
hlmsTerra->setDebugOutputPath(false);
#endif
mTerra = new Ogre::Terra( Ogre::Id::generateNewId<Ogre::MovableObject>(),
&sceneManager->_getEntityMemoryManager( Ogre::SCENE_STATIC ),
sceneManager, 0, root->getCompositorManager2(),
camera );
mTerra->setCastShadows( false );
//mTerra->load( "Heightmap.png", Ogre::Vector3::ZERO, Ogre::Vector3( 256.0f, 1.0f, 256.0f ) );
mTerra->load( "Heightmap.png", Ogre::Vector3( 64.0f, 4096.0f * 0.5f, 64.0f ), Ogre::Vector3( 4096.0f, 4096.0f, 4096.0f ) );
Ogre::SceneNode *rootNode = sceneManager->getRootSceneNode( Ogre::SCENE_STATIC );
Ogre::SceneNode *sceneNode = rootNode->createChildSceneNode( Ogre::SCENE_STATIC );
sceneNode->attachObject( mTerra );
Ogre::HlmsDatablock *datablock = hlmsTerra->getDatablock( "TerraExampleMaterial" );
//Ogre::HlmsDatablock* datablock = hlmsTerra->createDatablock("test","test",Ogre::HlmsMacroblock(),Ogre::HlmsBlendblock(),Ogre::HlmsParamVec());
mTerra->setDatablock( datablock );
//dont care about shadow right now
// //enable the shader pieces for pbs
// Ogre::Hlms *hlmsPbs = hlmsManager->getHlms( Ogre::HLMS_PBS );
// Ogre::Archive *archivePbs = hlmsPbs->getDataFolder();
// Ogre::ArchiveVec libraryPbs = hlmsPbs->getPiecesLibraryAsArchiveVec();
// libraryPbs.push_back( Ogre::ArchiveManager::getSingletonPtr()->load(
// "../../yoyEngine/media/Hlms/Terra/" + renderSystemAppend + "/PbsTerraShadows",
// "FileSystem", true ) );
// hlmsPbs->reloadFrom( archivePbs, &libraryPbs );
// {
// Ogre::HlmsPbsTerraShadows* mHlmsPbsTerraShadows = new Ogre::HlmsPbsTerraShadows();
// mHlmsPbsTerraShadows->setTerra( mTerra );
// //Set the PBS listener so regular objects also receive terrain shadows
// Ogre::Hlms *hlmsPbs = root->getHlmsManager()->getHlms( Ogre::HLMS_PBS );
// hlmsPbs->setListener( mHlmsPbsTerraShadows );
// }
Ogre::CompositorWorkspace *oldWorkspace = yGraphicsServices::getGraphicsWorkspaceManager().getMainWorkspace();
if( oldWorkspace )
{
Ogre::TexturePtr terraShadowTex = oldWorkspace->getExternalRenderTargets()[1].textures.back();
if( terraShadowTex->getFormat() == Ogre::PF_NULL )
{
Ogre::ResourcePtr resourcePtr( terraShadowTex );
Ogre::TextureManager::getSingleton().remove( resourcePtr );
}
compositorManager->removeWorkspace( oldWorkspace );
}
Ogre::CompositorChannelVec externalChannels( 2 );
//Render window
externalChannels[0].target = renderWindow;
//Terra's Shadow texture
Ogre::ResourceLayoutMap initialLayouts;
Ogre::ResourceAccessMap initialUavAccess;
const Ogre::ShadowMapper *shadowMapper = mTerra->getShadowMapper();
shadowMapper->fillUavDataForCompositorChannel( externalChannels[1], initialLayouts,
initialUavAccess );
compositorManager->addWorkspace( sceneManager, externalChannels, camera,
"Tutorial_TerrainWorkspace", true, -1,
(Ogre::UavBufferPackedVec*)0, &initialLayouts,
&initialUavAccess );
root->addFrameListener(this);
}
bool yTerraManager::frameRenderingQueued(const Ogre::FrameEvent &evt){ //I tried frameStarted too, and in an update() just before renderOneFrame()
const float lightEpsilon = 0.0f;
mTerra->update( Ogre::Vector3::NEGATIVE_UNIT_Y, lightEpsilon );
return true;
}
this is the callstack (for some reason I can't examine the actual line inside addRenderable... although ogre is in Debug mode):
if I comment out this in Terra::optimizeCellsAndAdd:1 Ogre::RenderQueue::addRenderable BaseProjectDevSim 0x7ff6ef43e2d5
2 Ogre::RenderQueue::addRenderableV2 BaseProjectDevSim 0x7ff6ef433e81
3 Ogre::SceneManager::cullFrustum BaseProjectDevSim 0x7ff6ef05b7a5
4 Ogre::SceneManager::_updateWorkerThread BaseProjectDevSim 0x7ff6ef06f414
5 Ogre::updateWorkerThread BaseProjectDevSim 0x7ff6ef06f90c
6 Ogre::updateWorkerThread_internal BaseProjectDevSim 0x7ff6ef06f963
7 BaseThreadInitThunk KERNEL32 0x7ff9e4a02774
8 RtlUserThreadStart ntdll 0x7ff9e52c0d51
Code: Select all
while( itor != end )
mRenderables.push_back( *itor++ );
if I set rootNode->setVisible(false); it also don't crash but again... no visible
if I create an empty datablock:
I get a different crash://Ogre::HlmsDatablock *datablock = hlmsTerra->getDatablock( "TerraExampleMaterial" );
Ogre::HlmsDatablock* datablock = hlmsTerra->createDatablock("test","test",Ogre::HlmsMacroblock(),Ogre::HlmsBlendblock(),Ogre::HlmsParamVec());
which makes me think that some media/hlms paths are wrong but I double check them and I think I haven't missed anything.. the other resources needed (materials, textures, etc. are added when I init Ogre)"Parameter called texShadowMap0 does not exist. Known names are: f3dGrid f3dGrid[0] f3dLightList f3dLightList[0] terrainNormals terrainNormals[0] terrainShadows terrainShadows[0] texCloudsShadows texCloudsShadows[0] " @0x61bc6fd418
please help!
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
FIXED!! the problem was that it was conflicting with my custom pieces for pbs lol.. and it needed a directional light beforehandxrgo wrote:Hello! I am trying to integrate Terra in my engine, but I am getting a crash in update...
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
I have another problem:
when I use a dimension different than Ogre::Vector3( 4096.0f, 4096.0f, 4096.0f ) I get weird normals, I (kind of) solved this by looking at the value that this working dimension uses for the vScale parameter.. and it gave me Vector3(0.000244141, 1, 0.000244141)... so if I force that value always for vScale it works fine with every dimension (that I tested). my guess is that this value is a normalized one with a 1 in Y, maybe can be hardcoded and that can optimize a bit the shaders? EDIT: well if I set a dimension Y of 0, it should be just a plane, but it also shows normals so obviously forcing the value is not correct, I don't know the solution of this yet
also terrain shadows are not working but I just started looking at this one =) EDIT: working now, i was just setting light direction wrong lol
EDIT2: shadows looks reeeeeeeally pixelated in the standard pbs objects when dimension is not 4096 =(
when I use a dimension different than Ogre::Vector3( 4096.0f, 4096.0f, 4096.0f ) I get weird normals, I (kind of) solved this by looking at the value that this working dimension uses for the vScale parameter.. and it gave me Vector3(0.000244141, 1, 0.000244141)... so if I force that value always for vScale it works fine with every dimension (that I tested). my guess is that this value is a normalized one with a 1 in Y, maybe can be hardcoded and that can optimize a bit the shaders? EDIT: well if I set a dimension Y of 0, it should be just a plane, but it also shows normals so obviously forcing the value is not correct, I don't know the solution of this yet
also terrain shadows are not working but I just started looking at this one =) EDIT: working now, i was just setting light direction wrong lol
EDIT2: shadows looks reeeeeeeally pixelated in the standard pbs objects when dimension is not 4096 =(
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: ogre 2.1 terrain question
What dimensions are you using? I can't remember now if there were restrictions (e.g. multiple of 2, power of 2, etc)
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
I tried with many numbers, multiple of 2 and power of 2 also... its really easy to see the problem when using a reflection texture, or just by doing
Code: Select all
outColour.xyz = texture( terrainNormals, inPs.uv0.xy ).xyz
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: ogre 2.1 terrain question
Please post some screenshots (restoring vScale to what the original code) and some code (all the parameters used).
Beware that when resolution changes, normals get less sharper.
Beware that when resolution changes, normals get less sharper.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
this is from the samples, I just changed this:
basically just using the default datablock and added a reflection cubemap
using 4096:
using 128:
looks like it just has more roughness, but if I look up it looks like this:
so you can see its still very glossy =)
now with
using 4096:
using 128:
the effect is proportionally affected with the dimension, in other word for values farther away from 4096 the normals are worst
Code: Select all
Ogre::HlmsManager *hlmsManager = root->getHlmsManager();
//Ogre::HlmsDatablock *datablock = hlmsManager->getDatablock( "TerraExampleMaterial" );
Ogre::HlmsDatablock *datablock = hlmsManager->getHlms( Ogre::HLMS_USER3 )->getDefaultDatablock();
// Ogre::HlmsMacroblock macroblock;
// macroblock.mPolygonMode = Ogre::PM_WIREFRAME;
//datablock->setMacroblock( macroblock );
Ogre::TexturePtr cubemap = Ogre::TextureManager::getSingletonPtr()->getByName("citadela_hor.dds");
if (cubemap.isNull()) {
cubemap = Ogre::TextureManager::getSingleton().load("citadela_hor.dds", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_CUBE_MAP, Ogre::MIP_DEFAULT, 1, false, Ogre::PF_UNKNOWN, true);
}
static_cast<Ogre::HlmsTerraDatablock*>(datablock)->setTexture(Ogre::TERRA_REFLECTION, 0, cubemap);
using 4096:
Code: Select all
mTerra->load( "Heightmap.png", Ogre::Vector3( 64.0f, 4096.0f * 0.5f, 64.0f ), Ogre::Vector3(4096.0f, 4096.0f, 4096.0f) );
using 128:
Code: Select all
mTerra->load( "Heightmap.png", Ogre::Vector3( 64.0f, 128.0f * 0.5f, 64.0f ), Ogre::Vector3(128.0f, 128.0f, 128.0f) );
looks like it just has more roughness, but if I look up it looks like this:
so you can see its still very glossy =)
now with
Code: Select all
outColour.xyz = texture( terrainNormals, inPs.uv0.xy ).xyz
using 128:
the effect is proportionally affected with the dimension, in other word for values farther away from 4096 the normals are worst
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: ogre 2.1 terrain question
I totally misunderstood what you were doing (there is no restriction on dimensions being power of 2 or multiple of 2; I thought you were talking about the heightmap's resolution).
This is clearly a very stupid bug. m_xzRelativeSize is set right after calling createHeightmap, instead of being set before.
This is clearly a very stupid bug. m_xzRelativeSize is set right after calling createHeightmap, instead of being set before.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
yes at first glance its working! thank you so much!!
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
me haz another question..
My engine has the ability to take 8k screenshots, and I would like to disable LOD for the terrain at that moment because it looks very bad.
Also I can capture 360 video but the terrain is only displayed in one view of the cubemap... fo the rest is invisible
The question is... Since I don't care much for performance while doing those things... How can I disable all those optimizations? LOD and cell hiding
EDIT: increasing basePixelDimension and vertPixelDimension in update seems to solve the LOD problem, I can make a setter that does it temporarily =)
My engine has the ability to take 8k screenshots, and I would like to disable LOD for the terrain at that moment because it looks very bad.
Also I can capture 360 video but the terrain is only displayed in one view of the cubemap... fo the rest is invisible
The question is... Since I don't care much for performance while doing those things... How can I disable all those optimizations? LOD and cell hiding
EDIT: increasing basePixelDimension and vertPixelDimension in update seems to solve the LOD problem, I can make a setter that does it temporarily =)
-
- Gremlin
- Posts: 152
- Joined: Sat Aug 12, 2017 4:16 pm
- x 4
Re: ogre 2.1 terrain question
I want to add physic to terrain, but I don't know how.
Here is my attempt: I checked out the array m_terrainCells, I think it may hold the information that form the terrain, but when I take a look at each terrain cell, I don't know how to form the triangle to fit a terrain cell (I think use btBvhTriangleMeshShape may be appropriated for terrain). I also took a look at btOgre2.1, but can't find a way to use it to add physic to terrain.
Here is my attempt: I checked out the array m_terrainCells, I think it may hold the information that form the terrain, but when I take a look at each terrain cell, I don't know how to form the triangle to fit a terrain cell (I think use btBvhTriangleMeshShape may be appropriated for terrain). I also took a look at btOgre2.1, but can't find a way to use it to add physic to terrain.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: ogre 2.1 terrain question
Hello, A few thoughts on Terra:
in the pixel shader shouldn't be the default value when no detail rough or metal be 1 instead of 0...
so later when multiplied by the material value...
its not always 0.
aaaand, the mixing of the details I think it should be something like this:
(the sqrt is just because of the gamma)
this makes more sense, so in the detailWeights texture when I see Red I can actually see the first detail, and when Blue I can see the second... and so on
Saludos!
in the pixel shader shouldn't be the default value when no detail rough or metal be 1 instead of 0...
Code: Select all
@property( roughness_map@n )
float roughness@n = texture( textureMaps[@value( roughness_map@n_idx )],
vec3( inPs.uv0.xy * material.detailOffsetScale[@value(currOffsetDetail)].zw +
material.detailOffsetScale[@value(currOffsetDetail)].xy,
@value( roughness_map@n_idx_slice ) ) ).x;
@end @property( !roughness_map@n )
float roughness@n = 0; //<<<<<<<<<<should be 1
@end
Code: Select all
ROUGHNESS = (roughness0 * detailWeights.x * material.roughness.x +
roughness1 * detailWeights.y * material.roughness.y) +
(roughness2 * detailWeights.z * material.roughness.z +
roughness3 * detailWeights.w * material.roughness.w);
aaaand, the mixing of the details I think it should be something like this:
Code: Select all
diffuseCol.xyz = mix( detailCol0, detailCol1, sqrt(detailWeights.x) );
diffuseCol.xyz = mix( diffuseCol.xyz, detailCol2, sqrt(detailWeights.y) );
diffuseCol.xyz = mix( diffuseCol.xyz, detailCol3, sqrt(detailWeights.z) );
this makes more sense, so in the detailWeights texture when I see Red I can actually see the first detail, and when Blue I can see the second... and so on
Saludos!