Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

12045 Posts in 1593 Topics- by 594 Members - Latest Member: Soidgetoutt

19. June 2013, 04:25:45 pm
Xith3D CommunityXith3D InternalsDeveloper discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)Atmospheric effects on sphere
Pages: [1]
Print
Author Topic: Atmospheric effects on sphere  (Read 2624 times)
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« on: 24. June 2008, 08:22:41 pm »

For this time, I will not ask for something  Wink

For my application, I have made a Xith adaptation of the Real-Time Atmospheric Scattering algorithm given by Sean O'Neil on his website http://sponeil.net/ (Code is under BSD license).

So, if you are interested to add it to Xith, here are the files...

PS: At the moment, there is only the view "from space" and no clouds. I 'll try to add them if i have some spare time.

Edit : i forgot to mention something :
i didn't found the "Transform - into - Matrix" method in the Quaternion classes. I may have missed it so i have added this code:
Code:
   
    private final Matrix3f getMatrix(){
        Matrix3f m = new Matrix3f();
       
        // 9 muls, 14 adds
        float x2 = this.getA() + this.getA();
        float y2 = this.getB() + this.getB();
        float z2 = this.getC() + this.getC();
       
        float xx = this.getA() * x2;
        float xy = this.getA() * y2;
        float xz = this.getA() * z2;
       
        float yy = this.getB() * y2;
        float yz = this.getB() * z2;
        float zz = this.getB() * z2;
       
        float wx = this.getD() * x2;
        float wy = this.getD() * y2;
        float wz = this.getD() * z2;
        float fTemp = 1-xx; // Saves one addition

        m.m00(1f-(yy+zz));
        m.m01(xy-wz);
        m.m02(xz+wy);
       
        m.m10(xy+wz);
        m.m11(fTemp-zz);
        m.m12(yz-wx);
       
        m.m20(xz-wy);
        m.m21(yz+wx);
        m.m22(fTemp-yy);

        return m;
    }
« Last Edit: 24. June 2008, 08:29:21 pm by Mancer » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #1 on: 24. June 2008, 08:33:00 pm »

For my application, I have made a Xith adaptation of the Real-Time Atmospheric Scattering algorithm given by Sean O'Neil on his website http://sponeil.net/ (Code is under BSD license).

So, if you are interested to add it to Xith, here are the files...

PS: At the moment, there is only the view "from space" and no clouds. I 'll try to add them if i have some spare time.

Man, this is really great. Finally there someone new, who's willing to contribute something... something cool Smiley. I will definitely integrate it to xith. Thanks a lot.

Edit : i forgot to mention something :
i didn't found the "Transform - into - Matrix" method in the Quaternion classes.

Try that one:
Code:
myMatrix.set( myQuaterion );

Marvin
Logged
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« Reply #2 on: 24. June 2008, 08:45:00 pm »


Man, this is really great. Finally there someone new, who's willing to contribute something... something cool Smiley. I will definitely integrate it to xith. Thanks a lot.

It's a pleasure !
For all your help and work on this project, I think it's normal !!!

Try that one:
Code:
myMatrix.set( myQuaterion );
Stupid me ! I forgot to see there !  Cheesy
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #3 on: 24. June 2008, 09:05:24 pm »

I don't need to integrate it. You did an impressive job and have already complete and very validly integrated it. I am deeply impressed. Unfortunately you forgot to include the bloom effect classes into the archive. Could you please send them to me?

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #4 on: 24. June 2008, 09:19:57 pm »

What does the transformVector() method exactly to? could you please paste the code?

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #5 on: 24. June 2008, 09:34:35 pm »

Forget about the bloom stuff Grin. There were just two lost imports in the EffectFactory, that were referring to the bloom effect classes. I could simply remove them.

May I assume, that you're working on a bloom-effect-factory, which you will contribute to xith Smiley?

Marvin
Logged
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« Reply #6 on: 24. June 2008, 09:35:06 pm »

Oh sorry ! I forgot this part in my copy-paste !
It is just a multiplication with the vector once you have "transformed-into-matrix" the quaternion Grin
Code:
    public Vector3f transformVector(Tuple3f v){
        Vector3f out = new Vector3f();
       
        this.getMatrix().mul( v, out );
       
        return out;
    }

The Bloom classes aren't necessary for the atmospheric effect. You can remove them in the import section without problem. (i have also forget to clean the file before posting them  Grin )
In fact the bloom effect is work-in-progress !!!

When it will works, i ll share it also.




Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #7 on: 24. June 2008, 09:50:38 pm »

Thanks.

I have committed your code to xith3d. Unfortunately the sphere is just black. Could you please check, if I used your transformVector() method in the right way? Or maybe I messed up anything else.

And another question: The GLSLAtmosphereFactory is an Updatable, but is never pushed to the Updater. Is this a bug? Or doesn't the factory need to be an Updatable?

Marvin

EDIT: Oops! Forget about the update thing. I found it Smiley.
« Last Edit: 24. June 2008, 10:03:15 pm by Marvin Fröhlich » Logged
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« Reply #8 on: 24. June 2008, 10:27:51 pm »

Strange... it looks good...
I'll check that on Thursday i think
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #9 on: 24. June 2008, 10:42:45 pm »

I'll check that on Thursday i think

Cool. Thanks.

Marvin
Logged
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« Reply #10 on: 26. June 2008, 07:45:38 am »

The problem is solved!

(It was due to my bad usage of pooling and releasing Tuple...  Grin )
 
Have a look in the attached file.

Oh, one more thing:
For now, the factory settings are shared to all spheres with atmosphere.
(like the wavelength filtered by the atmosphere)

Maybe it could be more interesting for users to have different settings for each planet.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #11 on: 26. June 2008, 10:26:23 am »

The problem is solved!

Thanks.

Oh, one more thing:
For now, the factory settings are shared to all spheres with atmosphere.
(like the wavelength filtered by the atmosphere)

Maybe it could be more interesting for users to have different settings for each planet.

Sure. This was on my list anyway Wink.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #12 on: 26. June 2008, 11:01:04 am »

(It was due to my bad usage of pooling and releasing Tuple...  Grin )

Actually it wasn't doe to that reason. Your usage of the vecmath2-pools was totally correct. But there seems to be a bug in the pooling code. I will try to fix it tomorrow.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4403


May the 4th, be with you...


View Profile
« Reply #13 on: 27. June 2008, 01:36:42 am »

I found the reason, why pooling was a problem. Since uniform parameters are stored by reference, no instances from the pool must be used for shader parameters. I will fix this by making the uniform variables stored as a cheap copy.

Marvin
Logged
Mancer
Enjoying the stay
*
Offline Offline

Posts: 68


View Profile
« Reply #14 on: 27. June 2008, 09:49:21 am »

Yes, this is exactly why i've made the changes in my last file.

Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic