Page 2 of 5
Posted: Mon May 30, 2011 6:22 pm
by Klunk
very nice, work indeed, a couple things you could try adding. I couldn't really tell if your doing it already but we used to stretch the uvs as they get towards the horizon making the clouds smaller and looking more distant. Another thing you could try is using vertex alpha at the horizon of your object it blends the cloud into the horizon nicely and may solve the clouds looking out of scale when the pass in front of the mountains. This may involve adding an extra line of verts and custom shaders as I'm not that keyed up on irrlicht materials.
edit: if you do go down the custom shader path another trick, especially with those kind of cloud textures, is to use a fake "bloom" to the clouds using (if the cloud object origin is 0,0,0) dot(lightpos, vertpos) as the basis.
Re: Simple cloud layer SceneNode
Posted: Thu Jul 28, 2011 7:02 pm
by tbw
Thank you for your very useful tips.
Indeed in my project I combine the cloudscene node with a sun scene node, which produces a nice bloom effect if the whole scene is prepared with postprocessing. Regarding the blending of the clouds with the skybox I use ONE_TEXTURE_BLEND material:
Code: Select all
Material.MaterialType = video::EMT_ONETEXTURE_BLEND;
Material.MaterialTypeParam = video::pack_texureBlendFunc(
video::EBF_SRC_ALPHA,
video::EBF_ONE_MINUS_SRC_ALPHA,
video::EMFN_MODULATE_1X,
video::EAS_TEXTURE | video::EAS_VERTEX_COLOR);
This material comines the alpha channel of the texture with the vertex alpha. So you only have to place the cloudlayer in the right height by using the the method:
Code: Select all
setCloudHeight(f32 centerHeight, f32 innerHeight, f32 outerHeight)
the vertex colors are set by
Code: Select all
setCloudColor(const video::SColor& centerColor, const video::SColor& innerColor, const video::SColor& outerColor)
Playing around with this two functions should lead to acceptable reults.
The stretching of the uvs is a really good idea! I will try this out!
Thanks again!
Re: Simple cloud layer SceneNode
Posted: Wed Aug 03, 2011 2:08 am
by Granyte
What could cause cloud layer not to show while the code still compile fine
Re: Simple cloud layer SceneNode
Posted: Sat Aug 13, 2011 8:37 pm
by jorgerosa
Thanks for share this, this is really great stuff!
Everything works fine, but only if i comment these lines:
Code: Select all
// cloudLayer1->setTranslation(core::vector2d<f32>(0.008f, 0.0f)); // set translation (speed of the clouds)
// cloudLayer2->setTranslation(core::vector2d<f32>(0.006f, 0.003f)); // set translation (speed of the clouds)
// cloudLayer3->setTranslation(core::vector2d<f32>(0.006f, 0.003f)); // set translation (speed of the clouds)
Then, all the code runs ok, but the clouds layers have no movement, of course.
if I uncomment above lines, CODE::BLOCKS returns:
error: no matching function for call to 'irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>)'
I cheched the class, there is:
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
{
// set the translation
Translation = translation;
}
So... everything should work fine... what am i missing?.... (I´m using IRRLICHT V.1.7.2 and OpenGl 3.3.0, just in case...)
Re: Simple cloud layer SceneNode
Posted: Sat Aug 13, 2011 9:35 pm
by serengeor
jorgerosa wrote:Thanks for share this, this is really great stuff!
Everything works fine, but only if i comment these lines:
Code: Select all
// cloudLayer1->setTranslation(core::vector2d<f32>(0.008f, 0.0f)); // set translation (speed of the clouds)
// cloudLayer2->setTranslation(core::vector2d<f32>(0.006f, 0.003f)); // set translation (speed of the clouds)
// cloudLayer3->setTranslation(core::vector2d<f32>(0.006f, 0.003f)); // set translation (speed of the clouds)
Then, all the code runs ok, but the clouds layers have no movement, of course.
if I uncomment above lines, CODE::BLOCKS returns:
error: no matching function for call to 'irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>)'
I cheched the class, there is:
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
{
// set the translation
Translation = translation;
}
So... everything should work fine... what am i missing?.... (I´m using IRRLICHT V.1.7.2 and OpenGl 3.3.0, just in case...)
Try defining the vector2d variable before function and pass it to it.
Re: Simple cloud layer SceneNode
Posted: Sat Aug 13, 2011 10:38 pm
by jorgerosa
serengeor wrote:Try defining the vector2d variable before function and pass it to it.
Worked like a charm! Thanks serengeor! Im still wondering why... but works!...
Here is the solution, might help someone else, too:
Code: Select all
cloudLayer1 = new scene::CCloudSceneNode(smgr->getRootSceneNode(), smgr);
core::vector2d<f32> xx = vector2d<f32>(0.008f, 0.0f);
cloudLayer1->setTranslation(xx); // set translation (speed of the clouds)
Re: Simple cloud layer SceneNode
Posted: Sun Aug 14, 2011 12:22 am
by cobra
@jorgerosa
Changing:
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
to:
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Would be the best solution. It should be that way anyway.
Re: Simple cloud layer SceneNode
Posted: Sun Aug 14, 2011 7:54 am
by serengeor
cobra wrote:@jorgerosa
Changing:
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
to:
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Would be the best solution. It should be that way anyway.
Yeah, I also wondered why it's not like that
Re: Simple cloud layer SceneNode
Posted: Sun Aug 14, 2011 1:33 pm
by mecio
What is wrong?
Code: Select all
#include "CloudSceneNode.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
...
...
CCloudSceneNode* cloudLayer1 = new CCloudSceneNode(smgr->getRootSceneNode(), smgr);
core::vector2d<f32> xx = vector2d<f32>(0.008f, 0.0f);
cloudLayer1->setTranslation(xx);
cloudLayer1->getMaterial(0).setTexture(0, driver->getTexture("media/clouds/cloud01.png"));
cloudLayer1->setCloudHeight(0.5f, 0.1f, -0.05f);
I get this error.
Code: Select all
undefined reference to `irr::scene::CCloudSceneNode::CCloudSceneNode(irr::scene::ISceneNode*, irr::scene::ISceneManager*, int)'|
Re: Simple cloud layer SceneNode
Posted: Sun Aug 14, 2011 1:37 pm
by serengeor
mecio wrote:
I get this error.
Code: Select all
undefined reference to `irr::scene::CCloudSceneNode::CCloudSceneNode(irr::scene::ISceneNode*, irr::scene::ISceneManager*, int)'|
Add .cpp file into your project that contains the function.
Re: Simple cloud layer SceneNode
Posted: Sun Aug 14, 2011 2:33 pm
by mecio
I have it already but when i hanged
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
to
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
message disappeared
Re: Simple cloud layer SceneNode
Posted: Mon Aug 15, 2011 10:31 am
by tbw
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
is correct. (MS compiler does not care about it). I will change it a soon as possible and I will re-upload the source/example!
Thank you for the hint!
Re: Simple cloud layer SceneNode
Posted: Tue Oct 11, 2011 2:35 am
by eagletree
This scenenode is excellent. Thanks for the good work.
I loaded it on a couple of Macs now and it works as well there as on Windows, just needed the declaration of the vector2df as on Linux. No other scenenode I've tried has worked on the Mac out of the box (though I've only used a few from here so far).
Thanks again.
Re: Simple cloud layer SceneNode
Posted: Wed Oct 12, 2011 6:27 pm
by randomMesh
This is very nice indeed, thank you for sharing.
I got a few notes:
- 1. The demo code linked in the first post still doesn't compile out of the box. You need to apply the changes cobra suggested.
2. You got a memory leak in the demo. You don't drop the CCloudSceneNodes after usage.
3. Every time a c++ programmer uses #define, God kills a kitten. Use a static const irr::u32 to save them!
4. Fix your includes! Instead of including the complete Irrlicht library, only include the needed headers (to reduce compile time).
CloudSceneNode.h:
Code: Select all
#include <ISceneNode.h>
#include <S3DVertex.h>
CloudSceneNode.cpp:
Code: Select all
#include "CloudSceneNode.h"
#include <ISceneManager.h>
#include <ICameraSceneNode.h>
#include <IVideoDriver.h>
Re: Simple cloud layer SceneNode
Posted: Thu Oct 13, 2011 5:56 pm
by hendu
@randomMesh
If you compile irr apps often, create a precompiled header for irrlicht.h; works much better than hand-tuning headers in every file