[Flightgear-devel] 3d clouds rendering order

2010-03-01 Thread Lauri Peltonen
Hello all!

Attached is a quick fix for the massive depth sorting problem (as
stated by a slashdotter, see
http://games.slashdot.org/comments.pl?sid=1565430cid=31297500 ) of 3d
clouds.

It simply sorts the 3d cloud layers so that farthest away clouds are
rendered first, which should be the desired behaviour with translucent
objects.

I once again hope that the patch is correct, did it with 'cvs diff -U *'
this time, on simgear/simgear/scene/sky/.


On another topic, are the 2d cloud layers broken? When I toggle off 3d
clouds, all clouds disappear. I expected to see the good old 2d clouds.
IIRC they had some depth sorting problems too, which I was going to try
to fix too.

Lauri A.K.A. Zan
--
Lauri Peltonen
Index: cloud.cxx
===
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/sky/cloud.cxx,v
retrieving revision 1.69
diff -u -r1.69 cloud.cxx
--- cloud.cxx	23 Jan 2010 11:40:42 -	1.69
+++ cloud.cxx	1 Mar 2010 20:10:25 -
@@ -757,7 +780,7 @@
 last_lat = lat;
 }
 
-layer3D-reposition( p, up, lon, lat, dt, layer_asl);
+layer3D-reposition( p, up, lon, lat, alt, dt, layer_asl);
 return true;
 }
 
Index: cloudfield.cxx
===
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/sky/cloudfield.cxx,v
retrieving revision 1.35
diff -u -r1.35 cloudfield.cxx
--- cloudfield.cxx	23 Jan 2010 11:40:43 -	1.35
+++ cloudfield.cxx	1 Mar 2010 20:10:25 -
@@ -69,7 +69,7 @@
 sgVec3 SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y;
 
 // reposition the cloud layer at the specified origin and orientation
-bool SGCloudField::reposition( const SGVec3f p, const SGVec3f up, double lon, double lat,
+bool SGCloudField::reposition( const SGVec3f p, const SGVec3f up, double lon, double lat, double alt,
 		   double dt, int asl )
 {
 osg::Matrix T, LON, LAT;
@@ -132,7 +132,11 @@
 field_transform-setMatrix( LAT*LON*T );
 }
 
-field_root-getStateSet()-setRenderBinDetails(asl, DepthSortedBin);
+// Render the clouds in order from farthest away layer to nearest one.
+// I *think* we should not use the altitude difference directly, but instead
+// allocate enough bins to hold all cloud layers.
+// Assume 100km is the highest where clouds may exist! :o
+field_root-getStateSet()-setRenderBinDetails(10 - abs(alt - asl) + CLOUDS_BIN, DepthSortedBin);
 
 return true;
 }
Index: cloudfield.hxx
===
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/sky/cloudfield.hxx,v
retrieving revision 1.19
diff -u -r1.19 cloudfield.hxx
--- cloudfield.hxx	26 Nov 2009 17:24:02 -	1.19
+++ cloudfield.hxx	1 Mar 2010 20:10:25 -
@@ -113,7 +113,7 @@
 * @param asl altitude of the layer
 */
 bool reposition( const SGVec3f p, const SGVec3f up,
-double lon, double lat, double dt, int asl);
+double lon, double lat, double alt, double dt, int asl);
 
 osg::Group* getNode() { return field_root.get(); }
 
 
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] 3d clouds rendering order

2010-03-01 Thread Lauri Peltonen
Hello again.

Please forget the last patch I sent, since it was a huge black hole in
my head I think :)

This one does the same but is much simpler, just pushes all 3d clouds
into CLOUDS_BIN which is depth sorted from back to front, and all 3d
clouds render nicely.

I still see problem with 2d cloud layers hiding the 3d clouds behind
them. It needs a bit more thinking to get that one working correctly.

Lauri A.K.A. Zan

P.s. the 2d cloud layers work, it was the same black hole again.
--
Lauri Peltonen
Index: cloudfield.cxx
===
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/sky/cloudfield.cxx,v
retrieving revision 1.35
diff -u -r1.35 cloudfield.cxx
--- cloudfield.cxx	23 Jan 2010 11:40:43 -	1.35
+++ cloudfield.cxx	1 Mar 2010 21:25:47 -
@@ -132,7 +132,8 @@
 field_transform-setMatrix( LAT*LON*T );
 }
 
-field_root-getStateSet()-setRenderBinDetails(asl, DepthSortedBin);
+// Render the clouds in order from farthest away layer to nearest one.
+field_root-getStateSet()-setRenderBinDetails(CLOUDS_BIN, DepthSortedBin);
 
 return true;
 }
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel