irrWeatherManager 0.0.5 - weather system for Irrlicht

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

Hi Cobra,

Line 448 of ICloudSceneNode.cpp appears to have been commented out by accident.

Here are lines 445 through 451:

Code: Select all

		p[1+idx].Pos.X	= particle.pos.X + h.X - v.X;
		p[1+idx].Pos.Y	= particle.pos.Y + h.Y - v.Y;
		p[1+idx].Pos.Z	= particle.pos.Z + h.Z - v.Z;
		//p[1+idx].Color  = particle.color;
		p[1+idx].Normal.X = view.X;
		p[1+idx].Normal.Y = view.Y;
		p[1+idx].Normal.Z = view.Z;
If you compare that to other lines dealing with color in that code block, it looks like it shouldn’t be commented.

I found it while trying to integrate the WeatherManager into my 3d viewer. I’m using my existing directional light, with it’s own set of controls for the diffuse/ambient ratio, so I removed the sunlight and the calls to setAmbientLight2 in IWeatherManagerAtmosphere.cpp. When I did that, I found that large portions of each cloud were green instead of gray if ambient light was less than 100%. Removing the comment on line 448, helped a lot, but there was still a small green spot on each cloud. I couldn’t find where the green was working its way into the cloud color, so I added the 2 lines shown below to ICloudSceneNode.cpp, forcing the colors to be grayscales:

Code: Select all

	// make each particle
	for (i=0; i < ParticleCount; i++)
	{
		core::vector3df tmppos = ParticleData[i].pos;

		ParticleData[i].color.setRed(ParticleData[i].color.getBlue()); // added by CES
		ParticleData[i].color.setGreen(ParticleData[i].color.getBlue()); // added by CES

		// rotate
		m.transformVect(tmppos);
Thanks again for a nice addition to Irrlicht,
--Carl
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi CarlS.

Thanks a lot for your report, and I'm sorry about my late reply.

I do remember commenting that line out for something I was implementing. I'll experiment when I can and try to figure out why I did it.
Josiah Hartzell
Image
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Hey cobra!

Again, thanks for a great irrlicht addon! I'd again have some linux build targets for your C::B prjs ready.

p.
beer->setMotivationCallback(this);
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi Polylux.

Thanks for the feedback.

Linux build targets would be great!

- Josiah
Josiah Hartzell
Image
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

Hi Cobra,

I found a minor issue in ICloudSceneNode.cpp at line 661.
In the function makeRandomCloud, the color is assigned to the cloud particles in a for loop starting at an index of 1. This leaves the 0th particle with no color assigned, and that particle appears very dark if you’re using directional light with ambient light set less than max.

Code: Select all

	// make particles
//	for (i=1; i<count+25; i++) // original
	for (i=0; i<count+25; i++) // 20110125 CES
	{
I was also wondering about a possible fix for jitter of the sun and moon billboards when the camera is moved. Earlier in this thread, it was mentioned that one option might be to use the same approach as the SkyBox. However, looking through the code, it looks like that is already being done. From looking at the billboard jitter, it looks as though the camera position being used as a reference for the billboard is one frame old. Holding down the left arrow key causes the billboard to jump to the right and stay there like it is referenced to the camera’s previous position. Release the arrow key and the billboard snaps back to it’s correct position.

--Carl
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi CarlS.

Thank you for the bug reports.

I've fixed the previous possible bug you mentioned, and the new bug you mentioned.

In addition to that, I've also fixed the "jitter" bug.

Since I've already got these changes made, and I'll add some others, I'll probably release 0.1.51 soon.


Until then, here's how you fix the "jitter" bug:


IWeatherManagerAtmosphere.cpp, line 281:

Remove:

Code: Select all

vt.X=sun_place.X+cameraPos.X;
vt.Y=sun_place.Y+cameraPos.Y;
vt.Z=sun_place.Z+cameraPos.Z;

IWeatherManagerAtmosphere.cpp, line 280:

Replace:

Code: Select all

core::vector3df vt;
To:

Code: Select all

core::vector3df vt = sun_place;

IAtmosphereStarSceneNode.cpp, line 88:

Change:

Code: Select all

vertices[0].Pos = pos + horizontal + vertical;
vertices[1].Pos = pos + horizontal - vertical;
vertices[2].Pos = pos  - horizontal - vertical;
vertices[3].Pos = pos  - horizontal + vertical;

To:

Code: Select all

vertices[0].Pos = pos + campos + horizontal + vertical;
vertices[1].Pos = pos + campos + horizontal - vertical;
vertices[2].Pos = pos + campos - horizontal - vertical;
vertices[3].Pos = pos + campos - horizontal + vertical;

IWeatherManagerAtmosphere, line 286:

Remove:

Code: Select all

vt.X=-sun_place.X+cameraPos.X;
vt.Y=-sun_place.Y+cameraPos.Y;
vt.Z=-sun_place.Z+cameraPos.Z;
bill->setMoonPosition(vt);

IAtmosphereStarSceneNode.cpp, line 124:

Replace:

Code: Select all

vertices[0].Pos = MoonPosition + horizontal + vertical;
vertices[1].Pos = MoonPosition + horizontal - vertical;
vertices[2].Pos = MoonPosition - horizontal - vertical;
vertices[3].Pos = MoonPosition - horizontal + vertical;

With:

Code: Select all

MoonPosition = -pos;

vertices[0].Pos = MoonPosition + campos + horizontal + vertical;
vertices[1].Pos = MoonPosition + campos + horizontal - vertical;
vertices[2].Pos = MoonPosition + campos - horizontal - vertical;
vertices[3].Pos = MoonPosition + campos - horizontal + vertical;

I also removed IAtmosphereStarSceneNode::setMoonPosition().


And now you should have smooth movement of your sun and moon!

Enjoy, and keep an eye out for 0.1.51. :)

- Josiah

PS:
In case anyone is wondering what is going on with DevSH's involvement in irrWeatherManager:

I'm still the only developer for irrWeatherManager since DevSH has started another project. None of his changes were added.
Last edited by cobra on Wed Feb 16, 2011 1:25 am, edited 1 time in total.
Josiah Hartzell
Image
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

Watching closely.....

this code i dont understand

Code: Select all

vt.X=(sun_place.X-cameraPos.X)+cameraPos.X; 
vt.Y=(sun_place.Y-cameraPos.Y)+cameraPos.Y; 
vt.Z=(sun_place.Z-cameraPos.Z)+cameraPos.Z;
looks like the same result as

Code: Select all

vt.X=(sun_place.X); 
vt.Y=(sun_place.Y); 
vt.Z=(sun_place.Z);


but maybe i am missing something.

I have a request if possible. Do you understand why the directx driver does not update the time? (moon,sun, fog etc...)
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Seven:

You are right.

When I was fixing that, I was thinking they were two different variables (both occurances of cameraPos in each line).

I guess that's a side-effect of multitasking. :lol:

I updated my previous post with the fixed instructions.

Thanks for pointing that out.

I'll look into the Direct3D problem when I can.


- Josiah
Josiah Hartzell
Image
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

cobra wrote:Seven:

I'll look into the Direct3D problem.

- Josiah

fantastic! this is one of the most useful additions that I have seen and having it work on all drivers would be a huge benefit for us.
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

Hi Cobra,

That did the trick; the sun amd moon no longer do the jitterbug :mrgreen:

Thanks a lot posting the fix early, looking forward to 0.1.51

--Carl
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

I just noticed that the jitterbug patch fixed the erratic motion of the sun, but it caused the moon to dissappear.
This was happening because MoonPosition was never being set before being used.
To fix this, place the following code before line 124 in IAtmosphereStarSceneNode.cpp,

Code: Select all

   MoonPosition.X = -pos.X;
   MoonPosition.Y = -pos.Y;
   MoonPosition.Z = -pos.Z;
--Carl
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

CarlS wrote:I just noticed that the jitterbug patch fixed the erratic motion of the sun, but it caused the moon to dissappear.
This was happening because MoonPosition was never being set before being used.
To fix this, place the following code before line 124 in IAtmosphereStarSceneNode.cpp,

Code: Select all

   MoonPosition.X = -pos.X;
   MoonPosition.Y = -pos.Y;
   MoonPosition.Z = -pos.Z;
--Carl

You missed the line where I set MoonPosition to -SunPosition. :)

Check in the last code snippet on my post with the instructions.

This is what it contains:

Code: Select all

MoonPosition = -pos;

vertices[0].Pos = MoonPosition + campos + horizontal + vertical;
vertices[1].Pos = MoonPosition + campos + horizontal - vertical;
vertices[2].Pos = MoonPosition + campos - horizontal - vertical;
vertices[3].Pos = MoonPosition + campos - horizontal + vertical;
- Josiah
Josiah Hartzell
Image
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

cobra wrote: You missed the line where I set MoonPosition to -SunPosition. :)
doh! :shock: :lol: :shock:
You're right, I left that one out when cutting and pasting.
What a difference a line makes.

--Carl
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Just to let irrWeatherManager users know:

The next release ( 0.1.58 ) should be ready for release soon.

It includes an experimental imposter LOD system that I've been working on for a few days.

Here's a little test:

1,000 10-particle clouds all in the screen at once, 50,000 units away from the camera:

102 FPS with imposters enabled
60 FPS with imposters disabled


EDIT:
In the same case as above, I gained 4 FPS with threshold-based particle orientation updating for the camera position and target. Now it's 106 FPS in the same case as above with imposters enabled.

With this change:

106 FPS with imposters enabled
64 FPS with imposters enabled


In another test I got a steady 54 FPS with 2,200 clouds in the scene.

It also includes the sun/moon "jitter" fix, among some other things.

Moreover, to clear up any confusion started by the mid-section posts, DevSH is not part of irrWeatherManager's development, and none of his code has been added.

- Josiah
Josiah Hartzell
Image
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

again, this is fantastic. Were you able to look into the directx driver not updating the weather manager?
Post Reply