SkyX 0.4 [0.4 version released - Over-cloud rendering!]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

zhuyeaini wrote:hi ,all,when i use skyX,i want to give scene some fog effect,so i set fog color and background color with skyx's api:
...
Try with: mSkyX->getAtmosphereManager()->getColorAt(-dir);
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

Xmas gift:
[youtube]INp05O-D8Fs[/youtube]
lightandshadow
Gnoblar
Posts: 4
Joined: Tue Dec 18, 2012 4:32 am

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by lightandshadow »

@lightandshadow
Great to know you've managed to port the shaders to GLES (2 right?). About tiling all volumetric slices into one huge texture, maybe you could use a couple of textures instead of one. But I warn you: the volumetric clouds will absolutely kill your frame rate due to the huge fillrate, and also you'll lose 3d interpolation :/

Keep me updated on that. One time you would have released the sources I'll evaluate if it's worth to add official SkyX GLES support.
I have most of the shaders ported with the exception of volumetric clouds. Currently, I'm attempting to emulate 3D textures by multiplexing each 3D texture depth layer into a texture atlas, then demultiplexing the layers in the shader.

Multiplex the cloud data into a texture atlas...

Code: Select all

void DataManager::_updateVolTextureData(Cell ***c, const VolTextureId& TexId, const int& nx, const int& ny, const int& nz)
	{
		Ogre::HardwarePixelBufferSharedPtr buffer = mVolTextures[TexId]->getBuffer(0,0);
		
		buffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
		const Ogre::PixelBox &pb = buffer->getCurrentLock();

		Ogre::uint8* pbptr = static_cast<Ogre::uint8*>(pb.data);
		size_t x, y, z, offset;
            
        size_t textureRowSize = 512;
        size_t tileOffset = 128;
        size_t tileRowOffset = tileOffset * textureRowSize * 3;
        size_t tileColumnOffset = tileOffset * 3;
        size_t columns = 4;
        size_t columnIndex = 0;
        size_t rowIndex=0;
        
        for (z=0; z<16; z++)
        {
            for (y=0; y<ny; y++)
            {
                for (x=0; x<nx; x++)
				{
                    size_t tro = (rowIndex * tileRowOffset);
                    size_t texro = (textureRowSize * y)*3;
                    size_t texco = (tileColumnOffset * columnIndex);
                    offset = tro + texro + texco + (x*3);
                    
                    pbptr[offset] = 0;
                    pbptr[offset++] = c[x][y][z].dens*255;
                    pbptr[offset++] = c[x][y][z].light*255;
                    pbptr[offset++] = 0;
                }
            }
            columnIndex++;
            if (columnIndex > 3) {
                columnIndex = 0;
                rowIndex++;
            }
        }

		buffer->unlock();
	}
Demultiplex the texture in the shader...

Code: Select all

precision highp float;

// IN
varying vec3 v3DCoord;
varying vec2 vNoiseUV;
varying float vOpacity;
varying vec3 vEyePixel;
varying float vDistance;
// OUT
// UNIFORM
uniform float uInterpolation;
uniform vec3 uSunDirection;
uniform vec3 uAmbientColor;
uniform vec3 uSunColor;
uniform vec4 uLightResponse;
uniform vec4 uAmbientFactors;
uniform sampler2D uDensity0;
uniform sampler2D uDensity1;
uniform sampler2D uNoise;

vec4 smp3D(sampler2D atlas, vec3 texPos)
{
    texPos.x = texPos.x / 4.0; // because we've packed 4 source images across,
    texPos.y = texPos.y / 4.0; // and 4 images down

    // we'll multiply z by 4 since then, logically, the integer part is
    // how many tiles across to index, and the decimal part is now many
    // tiles down to index
    texPos.z *= 4.0;

    // figure out how many tiles across to index, with each tile being
    // 1.0 / 4.0 in size
    texPos.x += floor(texPos.z) / 4.0;

    // remove the integer part of z, then multiply by 4 to do much what
    // we just did to y
    texPos.z = fract(texPos.z) * 4.0;
    texPos.y += floor(texPos.z) / 4.0;
    
    return texture2D(atlas, texPos.xy);
}

void main(void)
{    
    // x - Sun light power
    // y - Sun beta multiplier
    // z - Ambient color multiplier
    // w - Distance attenuation
	// uLightResponse = float4(0.25,0.2,1,0.1);
	
	// Ambient light factors
	// x - constant, y - linear, z - cuadratic, w - cubic
	// float4 uAmbientFactors = float4(0.4,1,1,1);

	vec3 Noise = texture2D(uNoise, vNoiseUV*5.0).xyz;
	vec3 Final3DCoord = v3DCoord+0.002575*(Noise-0.5)*2.0;
	Final3DCoord.z = clamp(Final3DCoord.z, 0.0, 1.0);

	vec3 Density0 = smp3D(uDensity0, Final3DCoord).xyz;
	vec3 Density1 = smp3D(uDensity1, Final3DCoord).xyz;
	vec3 Density  = Density0*(1.0-uInterpolation) + Density1*uInterpolation;
	
	vec3 finalcolor = vec3(0,0,0);
	float Opacity = 0.0;
	
	if (Density.x > 0.0)
	{
	    float cos0 = clamp(dot(uSunDirection,vEyePixel), 0.0, 1.0);
	    float c2=cos0*cos0;
		
		float Beta = c2*uLightResponse.y*(0.5+2.5*clamp(1.0-2.0*uSunDirection.y, 0.0, 1.0)*Density.y);

		float sunaccumulation = max(0.2, clamp(Beta+Density.y*uLightResponse.x+pow(vDistance,1.5)*uLightResponse.w, 0.0, 1.0));
		float ambientaccumulation = 
			  clamp(uAmbientFactors.x + uAmbientFactors.y*v3DCoord.z + uAmbientFactors.z*pow(v3DCoord.z,2.0) + uAmbientFactors.w*pow(v3DCoord.z,3.0), 0.0, 1.0)*uLightResponse.z;
	    
		finalcolor = uAmbientColor*ambientaccumulation + uSunColor*sunaccumulation;
		Opacity = (1.0 - exp(-Density.x*(7.5-6.5*v3DCoord.z)))*vOpacity;
	}
	
    gl_FragColor = vec4(finalcolor, Opacity);
}
I've attached both the red and green texture channels to this post, along with the render. Any idea where I might be going wrong here?
Attachments
Render
Render
render.jpg (52.28 KiB) Viewed 7147 times
texture atlas green channel
texture atlas green channel
atlas-green.jpg (142.06 KiB) Viewed 7147 times
Texture Atlas red channel
Texture Atlas red channel
atlas-red.jpg (150.14 KiB) Viewed 7147 times
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

I know what's happening. Unfortunately I haven't access to a computer right now, I'll properly reply you during the next few days.

Xavier
lightandshadow
Gnoblar
Posts: 4
Joined: Tue Dec 18, 2012 4:32 am

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by lightandshadow »

Xavyiy wrote:I know what's happening. Unfortunately I haven't access to a computer right now, I'll properly reply you during the next few days.
Xavier
Since I am not sure what each depth slice should look like, I am unsure if the problem is located in the way I am building the texture atlas, somewhere in the shader or both. If you can point me in the right direction, I can probably get things working from there.

Also, I forgot to mention that I was using the Ogre 1.8.2 SDK. Could this be related?
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

Since I am not sure what each depth slice should look like, I am unsure if the problem is located in the way I am building the texture atlas, somewhere in the shader or both. If you can point me in the right direction, I can probably get things working from there.
Sorry for the delay!
I'm resting a little from study so I'll make it short:

For me, your atlas texture looks fine. I've only one "but" regarding this part: in theory, each slide must be XY seamless, since I force it while generating the volumetric data. Anyway I can't ensure that since I haven't rechecked it (maybe I just think I did it but finally I didn't implement it)

The problem: you're using a too low number of slices and the slice number 0 still has some non-zero data so, in the pixel shader, the lowest part of the geometry doesn't fade out gradually from 0 to a non-zero vlaue of density (Edit: or maybe it's 0, I can't see it very well in the image, and this artifact comes 100% from the lack of Z-axis interpolation). Also, there is another one reason for this problem: the way you're demultiplexing the atlas texture doesn't make any kind of interpolation between slices (texture3d does it) so you will not achieve this gradual fade in the z-axis. That is the biggest problem here (you can always force to zero the first slice, but if you don't simulate the 3d interpolation you'll not get a smooth effect). A cheap way of simulating 3d interpolation is by lookup two texture values from the 2 closest slices and then linearly interpolate them: (1-a)*val1 + a*val2, should be enough (the HW alreay does the XY interpolation(filtering) so I think that will give aceptable results).
Also, I forgot to mention that I was using the Ogre 1.8.2 SDK. Could this be related?
Don't worry about the Ogre version you're using. The problem doesn't come from that part. I'm using 1.8.X too :)

Hope that helps,

Xavier
inzero
Kobold
Posts: 33
Joined: Sun Dec 19, 2010 9:55 am

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by inzero »

Xavyiy wrote:Xmas gift:
[youtube]INp05O-D8Fs[/youtube]
Wow great job! All I can think of is this:

[youtube]M55YPXlhyzc[/youtube]

:D :wink:
lightandshadow
Gnoblar
Posts: 4
Joined: Tue Dec 18, 2012 4:32 am

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by lightandshadow »

Xavyiy wrote:The problem: you're using a too low number of slices and the slice number 0 still has some non-zero data so, in the pixel shader, the lowest part of the geometry doesn't fade out gradually from 0 to a non-zero vlaue of density (Edit: or maybe it's 0, I can't see it very well in the image, and this artifact comes 100% from the lack of Z-axis interpolation). Also, there is another one reason for this problem: the way you're demultiplexing the atlas texture doesn't make any kind of interpolation between slices (texture3d does it) so you will not achieve this gradual fade in the z-axis. That is the biggest problem here (you can always force to zero the first slice, but if you don't simulate the 3d interpolation you'll not get a smooth effect). A cheap way of simulating 3d interpolation is by lookup two texture values from the 2 closest slices and then linearly interpolate them: (1-a)*val1 + a*val2, should be enough (the HW alreay does the XY interpolation(filtering) so I think that will give aceptable results).

Xavier
The red channel in the texture atlas does go completely to black, even at 16 slices.

As you suspected, the problem was the lack of interpolation between each slice. When I added this and dialed down the cloud size, I was able to see the grey sky between the clouds.

I misunderstood what texture3D did in GLSL (I thought it was integer coords and did not interpolate between slices). Since it uses values between 0 and 1, I am stuck with either 16 or 32 slices as I cannot fill up only part of the texture. 16 slices seems good enough for my application, so I am using a 4x4 tiled texture atlas at 512x512.

Thanks!
Attachments
Demo 3 without terrain
Demo 3 without terrain
render.jpg (16.42 KiB) Viewed 6966 times
TheSHEEEP
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 972
Joined: Mon Jun 02, 2008 6:52 pm
Location: Berlin
x 65

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by TheSHEEEP »

Just a quick question that I could not find an answer in a lazy 5 minute search:

Does SkyX work with multiple suns/moons?
This would be extremely useful for fantasy/sci-fi scenarios.
I know that in 2009 you gave the answer that this was not possible, but I thought it couldn't hurt to ask again ;)

Btw. the above clouds video is really good looking!
My site! - Have a look :)
Also on Twitter - extra fluffy
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Mind Calamity »

I'm getting this exception when trying to use HDR lighting:

Code: Select all

06:58:47: OGRE EXCEPTION(2:InvalidParametersException): Parameter called uExposure does not exist.  in GpuProgramParameters::_findNamedConstantDefinition at G:\Libraries\ogre\v1-8\source\OgreMain\src/OgreGpuProgramParams.cpp (line 1451)
Any ideas ?

If I remove

Code: Select all

mSkyX->setLightingMode(SkyX::SkyX::LM_HDR);
it works again...

Also getColorAt returns constant zeros. Here's how I'm trying to use it:

Code: Select all

	Real time = mSkyController->getTime().x;
		bool day = time > 7 && time < 21;
		Vector3 dir = (day) ? mSkyController->getSunDirection() : mSkyController->getMoonDirection();
		dir.normalise();
		Vector3 vcol = mSkyX->getAtmosphereManager()->getColorAt(-dir);
		Color col(vcol.x, vcol.y, vcol.z);
		mSkyLight->setDiffuseColour(col);
		mSkyLight->setDirection(-dir);
The direciton is alright, but if I check the vCol Vector3 or the col ColourValue, I get 0, 0, 0.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

@TheSHEEEP
No, SkyX uses a physically-based atmosphere model where only the sun is taked account. It's of course possible to modify the shaders in order to add the contribution of more than one light source, but that will requiere deep changes and it's only worth for very specific cases. About multiple moons, it's just a matter of placing a billboard on the right place and adapt the scene illumination based on it, so yes but not doing it directly via SkyX.

@Mind Calamity
Well, that's weird because of I'm using the HDR mode in the Paradise Engine for almost all scenes. The error is because one of the SkyX shaders does not uses uExposure.

Are you using OpenGL? If yes, make sure to use 1.8.1+ since the OGL preprocessor is broken in previous Ogre versions. If you're running it under DX, are you using the lastest SkyX version (0.3.1), make sure to have updated your SkyX media folder to the last version (0.3.1) too.

Xavier
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

Some news: I'll try to release SkyX 0.4 this week, or at max next week. It's already done, it's just a matter of time caused by my high-density schedule :P

By the way, I profit to spam you a little with a Paradise Engine development video (well, the sky is SkyX!):
[youtube]EAWwwvyiaOE[/youtube]

If you're interested in any: SkyX, Hydrax or the Paradise Engine itself, feel free to follow me @Xavyiy , I'm used to tweet a lot about my work!

Xavier
BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by BTolputt »

Looks pretty snazzy, Xavyiy. For your info though, the download link for SkyX is down.

http://www.paradise-studios.net/downloads/hydrax_skyx/ = 404
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

BTolputt wrote:Looks pretty snazzy, Xavyiy. For your info though, the download link for SkyX is down.

http://www.paradise-studios.net/downloads/hydrax_skyx/ = 404
Thanks! :)

Yeah, these string-based urls are not used anymore. Here are the download links: http://www.paradise-studios.net/?page_id=270 (We're working on a better website, don't worry too much about the low quality of the current one!)

Xavier
BTolputt
Greenskin
Posts: 121
Joined: Thu Feb 18, 2010 8:05 am
x 2

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by BTolputt »

No problems, Xavyiy. I wouldn't have worried about it really, but the website itself uses the same URL. So unless you know the "page_id", you cannot get to the download!
User avatar
ahmadi
Gnome
Posts: 312
Joined: Sat Nov 26, 2005 4:03 pm

change angle of the sun.

Post by ahmadi »

Hi
First, Thank you for SkyX, its excellent.
How can i change angle of sun of SkyX!? its always zero, seems that the SkyX sun always is in Equator! then when the sun is in middle of sky, shadow length always is zero!
I want change it to 30' or more.
Please note that "mBasicController->setEastDirection();" don't do that! because it only change sunrise or sunset position no change of sun position when the sun is in middle of sky.
Thank you for any help.
_________________________________
Best regards

Ahmadi
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

@ahmedi
You need to create a custom SkyX::Controller and implement the desired sun/moon behaviour here. In the basic controller the sun/moon trajectories always pass trough the top of the sky.

--------------

Here is the first video of the next Hydrax version (running in the Paradise Engine), still A LOT of work to do:

[youtube]Sysf32-ClqM[/youtube]

Xavier
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Mind Calamity »

:O That looks beautiful! Will Paradise be open source or just free ? I think the latter, because you said something about HydraX going commercial in the future.

Anyways, great job. :)
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.3.1 [0.3.1 version released! + Z-up fork!]

Post by Xavyiy »

The Paradise Engine will be a commercial solution, but it'll be available a free version for non commercial projects. Some future features are only going to be available on the commercial version, but the free version will include sky, water, post-processing effects, linear lighting pipeline, multiple shadow techniques, among others.

Xavier
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by Xavyiy »

Hi people!

Finally I've found some time for releasing SkyX 0.4, featuring over-cloud rendering support and some little fixes!

As usual, download links are available at: http://www.paradise-studios.net/?page_id=270

Hope you like it!

Xavier
Transporter
Minaton
Posts: 933
Joined: Mon Mar 05, 2012 11:37 am
Location: Germany
x 110

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by Transporter »

@Xavyiy
Nice work! I have a few notes on SkyX:

1. I have the following line in my ogre.log

Code: Select all

22:14:55: Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
2. To make sample 2 and 3 also running with ogre 1.9 you have to replace

Code: Select all

// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Ogre.h>
#include <OgreTextAreaOverlayElement.h>
by

Code: Select all

// ----------------------------------------------------------------------------
// Check for OgreOverlay
// ----------------------------------------------------------------------------
#if OGRE_VERSION > ((1 << 16) | (8 << 8) | 1)
#define OGRE_EXTERNAL_OVERLAY
#endif

// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Ogre.h>
#ifdef OGRE_EXTERNAL_OVERLAY
#include <OgreOverlaySystem.h>
#endif
#include <OgreTextAreaOverlayElement.h>
Btw, it would be nice to switch from ExampleApplication to TutorialFramework because of the overlay stuff.

3. Updated CMake files
SkyX-v0.4-CMake.zip
Update for CMake
(20.61 KiB) Downloaded 146 times
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by Mind Calamity »

Transporter wrote:@Xavyiy
Nice work! I have a few notes on SkyX:

1. I have the following line in my ogre.log

Code: Select all

22:14:55: Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
That's been there since 0.3.

Also, great job on the over-cloud rendering! It's beautiful! :D
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by Xavyiy »

@Transporter
Thanks! I'll update the CMake package in the official site ASAP. About the log message: it's the normal behaviour, anyway I'll remove these annoying/unnecesary warnings in the next version.
Also, great job on the over-cloud rendering! It's beautiful!
Thanks :)!
Transporter
Minaton
Posts: 933
Joined: Mon Mar 05, 2012 11:37 am
Location: Germany
x 110

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by Transporter »

Xavyiy wrote:Thanks! I'll update the CMake package in the official site ASAP. About the log message: it's the normal behaviour, anyway I'll remove these annoying/unnecesary warnings in the next version.
You're welcome! Btw, you should check all links on all pages of your website. A lot of links are not working.
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: SkyX 0.4 [0.4 version released - Over-cloud rendering!]

Post by drwbns »

I can't remember, but was it not possible to go through the cloud layer before?
Post Reply