Simple cloud layer SceneNode
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.
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
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:
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:
the vertex colors are set by
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!
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);
Code: Select all
setCloudHeight(f32 centerHeight, f32 innerHeight, f32 outerHeight)
Code: Select all
setCloudColor(const video::SColor& centerColor, const video::SColor& innerColor, const video::SColor& outerColor)
The stretching of the uvs is a really good idea! I will try this out!
Thanks again!
Re: Simple cloud layer SceneNode
What could cause cloud layer not to show while the code still compile fine
-
- Competition winner
- Posts: 117
- Joined: Wed Jun 30, 2010 8:44 am
- Location: Portugal
- Contact:
Re: Simple cloud layer SceneNode
Thanks for share this, this is really great stuff!
Everything works fine, but only if i comment these lines: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: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...)
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)
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;
}
Re: Simple cloud layer SceneNode
Try defining the vector2d variable before function and pass it to it.jorgerosa wrote:Thanks for share this, this is really great stuff!
Everything works fine, but only if i comment these lines:Then, all the code runs ok, but the clouds layers have no movement, of course.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)
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: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...)Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation) { // set the translation Translation = translation; }
Working on game: Marrbles (Currently stopped).
-
- Competition winner
- Posts: 117
- Joined: Wed Jun 30, 2010 8:44 am
- Location: Portugal
- Contact:
Re: Simple cloud layer SceneNode
Worked like a charm! Thanks serengeor! Im still wondering why... but works!...serengeor wrote:Try defining the vector2d variable before function and pass it to it.
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
@jorgerosa
Changing:
to:
Would be the best solution. It should be that way anyway.
Changing:
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Re: Simple cloud layer SceneNode
Yeah, I also wondered why it's not like thatcobra wrote:@jorgerosa
Changing:to:Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
Would be the best solution. It should be that way anyway.Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Working on game: Marrbles (Currently stopped).
Re: Simple cloud layer SceneNode
What is wrong?
I get this error.
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);
Code: Select all
undefined reference to `irr::scene::CCloudSceneNode::CCloudSceneNode(irr::scene::ISceneNode*, irr::scene::ISceneManager*, int)'|
Re: Simple cloud layer SceneNode
Add .cpp file into your project that contains the function.mecio wrote: I get this error.Code: Select all
undefined reference to `irr::scene::CCloudSceneNode::CCloudSceneNode(irr::scene::ISceneNode*, irr::scene::ISceneManager*, int)'|
Working on game: Marrbles (Currently stopped).
Re: Simple cloud layer SceneNode
I have it already but when i hanged
to
message disappeared
Code: Select all
void CCloudSceneNode::setTranslation(core::vector2d<f32>& translation)
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Re: Simple cloud layer SceneNode
Code: Select all
void CCloudSceneNode::setTranslation(const core::vector2d<f32>& translation)
Thank you for the hint!
Re: Simple cloud layer SceneNode
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.
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.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: Simple cloud layer SceneNode
This is very nice indeed, thank you for sharing.
I got a few notes:
CloudSceneNode.cpp:
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).
Code: Select all
#include <ISceneNode.h>
#include <S3DVertex.h>
Code: Select all
#include "CloudSceneNode.h"
#include <ISceneManager.h>
#include <ICameraSceneNode.h>
#include <IVideoDriver.h>
"Whoops..."
Re: Simple cloud layer SceneNode
@randomMesh
If you compile irr apps often, create a precompiled header for irrlicht.h; works much better than hand-tuning headers in every file
If you compile irr apps often, create a precompiled header for irrlicht.h; works much better than hand-tuning headers in every file