[SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

[SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by van4dium » Sun Jan 31, 2016 3:46 pm

Hi All.

I try to render dynamic cubemap, everything works fine except for two points:

1) the cubemap (applied to sphere) "reflect" inverse
2) the sky cube is not rendered

There is a way to solve these problems?

Cubemap.compositor

Code: Select all

abstract target cubemap_target
{
   pass clear
   {
      colour_value 0 0 0 1
   }

   pass render_scene
   {
      //Filter stuff that shouldn't be reflected (vampires?)
      visibility_mask      0x00000004
      overlays         off
      camera_cubemap_reorient true
   }
   
   pass generate_mipmaps {}
}

compositor_node CubemapRendererNode
{
   in 0 cubemap

   target cubemap +X : cubemap_target { }
   target cubemap -X : cubemap_target { }
   target cubemap +Y : cubemap_target { }
   target cubemap -Y : cubemap_target { }
   target cubemap +Z : cubemap_target { }
   target cubemap -Z : cubemap_target { }
} 
The sky is rendered by another workspace.

Thank you in advance.

Van.
Attachments
img.jpg
Last edited by van4dium on Fri Feb 05, 2016 6:47 pm, edited 1 time in total.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by xrgo » Sun Jan 31, 2016 4:32 pm

1) yeah.. that's a known issue, not sure why it hasn't been fixed yet http://www.ogre3d.org/forums/viewtopic. ... 6&p=518971
-modify the shader:

Code: Select all

vec3 cubeMapCoord = reflDir * pass.invViewMatCubemap;
      cubeMapCoord.z = -cubeMapCoord.z;
      vec3 envColourS = textureLod( texEnvProbeMap, cubeMapCoord,....
-or modify OgreHlmsPbs.cpp (line ~855):

Code: Select all

        //---------------------------------------------------------------------------
        //                          ---- PIXEL SHADER ----
        //---------------------------------------------------------------------------

        Ogre::Matrix3 viewMatrix3, invViewMatrix3;
        viewMatrix.extract3x3Matrix( viewMatrix3 );
        invViewMatrix3 = viewMatrix3.Inverse();

        //Add this to fix inverted cubemap
        invViewMatrix3[2][0] *= -1;
        invViewMatrix3[2][1] *= -1;
        invViewMatrix3[2][2] *= -1;
2) since you're rendering the sky as a post process, when the cubemap camera renders the scene there is no sky! you'll have to add the same post process node to your cubemap_target
0 x

van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by van4dium » Sun Jan 31, 2016 6:12 pm

thanks xrgo.
I solved the first two problems, but another appeared.
The sky cube faces are not rendered in the proper order (always +X)

Cubemap.compositor

Code: Select all

abstract target cubemap_target
{
   pass clear
   {
      colour_value 0 0 0 1
   }

  pass render_quad
  {
	  quad_normals camera_direction
	  material Test01SkyPostprocess
  }
   pass render_scene
   {
      //Filter stuff that shouldn't be reflected (vampires?)
      visibility_mask      0x00000004
      overlays         off
      camera_cubemap_reorient true
   }
   
   pass generate_mipmaps {}
}

compositor_node CubemapRendererNode
{
   in 0 cubemap

   target cubemap +X : cubemap_target { }
   target cubemap -X : cubemap_target { }
   target cubemap +Y : cubemap_target { }
   target cubemap -Y : cubemap_target { }
   target cubemap +Z : cubemap_target { }
   target cubemap -Z : cubemap_target { }
} 
Attachments
img.jpg
0 x

van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by van4dium » Thu Feb 04, 2016 12:26 pm

I tried some combination of the compositor but the only way where I can see the sky is with the above script (it is not displayed correctly, but is visible).
(The sky is always displayed as the image above)

Where am I wrong?

I ask for help.

Van.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by xrgo » Thu Feb 04, 2016 9:16 pm

to be honest I have no idea why is looking like that, I do my sky as a skydome mesh =/, are you there dark_sylinc? xD
van4dium wrote:I tried some combination of the compositor
you mean swapping the "+-XYZ"?:

Code: Select all

compositor_node CubemapRendererNode
{
   in 0 cubemap

   target cubemap +X : cubemap_target { }
   target cubemap -X : cubemap_target { }
   target cubemap +Y : cubemap_target { }
   target cubemap -Y : cubemap_target { }
   target cubemap +Z : cubemap_target { }
   target cubemap -Z : cubemap_target { }
} 
It seems that it should work!, you just have to find the correct order... And you will need to have 2 CubemapRendererNode, one for the normal render and another with the swapped coords for the cubemap

good luck!
0 x

van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by van4dium » Fri Feb 05, 2016 6:46 pm

Thank you so much xrgo,
I solved the problem.

I removed the nodes of the compositor for the skybox,
and I used a big cube for the sky.

In this way the cubemap renders the sky like a regular mesh (legacy v1)
I was inspired by another thread http://www.ogre3d.org/forums/viewtopic. ... 59#p518703

I thought I would create a class to simulate the skies of ogre 1.x (skybox, skydome, skyplane) but using ogre 2.1 (v2 ManualObject).
It will also create an HLMS to manage the various skies.

it's a good idea :?:

Van.
(sorry fo my english)
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [OGRE 2.1] Dynamic cubemap sky (postprocessing) render

Post by xrgo » Fri Feb 05, 2016 7:39 pm

van4dium wrote:I thought I would create a class to simulate the skies of ogre 1.x (skybox, skydome, skyplane) but using ogre 2.1 (v2 ManualObject).
It will also create an HLMS to manage the various skies.

it's a good idea :?:
yes! in fact that's what I ended up doing, I am not using v1 stuffs at all anymore. I am going to share my code later =)
0 x

van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by van4dium » Fri Feb 05, 2016 9:47 pm

Beautiful, I can not wait to see your code.

One other thing .. A little 'OT.
A basic example HLMS implementation, very narrow, where can I find it?
I searched the forum but could not find anything simple.

Thanks again.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by xrgo » Fri Feb 05, 2016 10:21 pm

So, this is my sky...
https://www.dropbox.com/s/lst1qy7j89tr2 ... r.zip?dl=0
took the basic hlms from here http://www.ogre3d.org/forums/viewtopic. ... 01#p519340 credits to Kinslore! (so that answers your question)

its called WeatherManager because soon will handle other stuffs (rain wind etc)
I quickly deleted someofmyownenginestuffs so it wont be plug and play =/

A little explanation:
its a sky dome with 3 uvs, as you can see in the blend file also included
1. for sky color depending on daytime, it uses SkyTones.png Yaxis is domeheight, Xaxis is daytime.
2. for panoramic clouds and horizon.
3. for tileable clouds.
clouds animates over time.

sadly, I can't share my clouds textures "CloudsTile_01.dds" and "CloudsPano_01.dds" that the code wants, you'll have to create your own :P

Saludos!
0 x

van4dium
Halfling
Posts: 40
Joined: Fri Jul 30, 2010 2:40 am

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by van4dium » Sat Feb 06, 2016 2:22 pm

It is very promising.
This is a day / night system.
It is much more complex than what I was trying to do :).
However it is a great place to start.

Maybe in the future we could join forces to create a complete ogre skysystem to 2.1.
That can handle simple skies (one texture) to a daynight system (with rain, wind, god rays and other atmospheric and visual effects). :D
I'm trying to do the porting of pseudo lens flare . http://john-chapman-graphics.blogspot.i ... flare.html
Some things work now, but it's still very WIP.
It could be an effect to add to the framework.

I saw that updates the location using a FrameListener.
In my shader, I move vertices with camera_position_object_space.
This way, you can use only the tick to update the time of day.

SkyBox_vs.glsl

Code: Select all

#version 330

in vec3 vertex;

uniform mat4 wvpMat;
uniform vec3 camPosObj;

out vec3 texCoord;

void main()
{
    gl_Position = wvpMat * vec4(vertex + camPosObj, 1.0);
    texCoord = vertex;
}
Ok the uv are not used because it is a cubemap.

Van.
(I think it's better to open another topic.)
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by xrgo » Sat Feb 06, 2016 3:36 pm

van4dium wrote:It is very promising.
This is a day / night system.
It is much more complex than what I was trying to do .
However it is a great place to start.
hope it helps =)
van4dium wrote:Maybe in the future we could join forces to create a complete ogre skysystem to 2.1.
that would be great, but actually I don't requiere much more than what I have, I just need rain now, and for that I only need a particle system, and I am waiting for the new one to be merged. and more clouds textures to make the sky overcast. I am going to try to keep it simple
van4dium wrote:I'm trying to do the porting of pseudo lens flare . http://john-chapman-graphics.blogspot.i ... flare.html
Some things work now, but it's still very WIP.
It could be an effect to add to the framework.
that's a great effect! hope you can share it when ready, maybe it could be included in the ogre samples
van4dium wrote:I saw that updates the location using a FrameListener.
In my shader, I move vertices with camera_position_object_space.
thats sounds really smart, I am going to try it, thanks!

Saludos!
0 x

User avatar
Aiden
Halfling
Posts: 46
Joined: Fri Jul 14, 2017 3:16 pm

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by Aiden » Wed Aug 30, 2017 12:09 pm

Hello,
I appreciate all the work you guys have done in improving Ogre.
I myself am working on a multi-player tank game which is nearly complete, at least it was before I begun porting into Ogre 2.1 due to performance issues.

So far porting into 2.0 was major success, performance was improved greatly esp with the use unique id's , and items instead of entities.

I am however stuck on implementing a skybox(nearly gave up), I am new to Ogre and 3d programming, esp shaders and vertex programs. I'm looking for working skybox that I can use on my tank game so I can continue development on the 2.1 branch. I've tried some of the samples code esp TutorialSky_Postprocess and Postprocessing which worked but the scene became dark and the screen would begin flickering at times.
Now I'm researching on skyboxes and stuff, I heard you can make own by adding a cube and adding texture on the inside. I managed to add a cube but could not figure out how to add texture on the inside since the cube is an imported mesh.

2.1 performance improvement.
Ogre 2.1 was upto 3 times as fast as compared to previous releases just as it has been said.
I tried adding hundreds of objects(items) on the scene and it didn't even lag a bit (Ogre 1.xx would have frozen).
I can see xrgo is working on a WeatherManager :D ,
xrgo wrote:its called WeatherManager because soon will handle other stuffs (rain wind etc)
This would be a very nice addition to my project whichever status it is in, and would save me alot of time. I intend to work on the shader stuff when am finalizing the game and improving the appearance stuff.

I tried adding the

Code: Select all

yWeatherManager
class to my project however there are some missing variables like

Code: Select all

sunLightObject 
,

Code: Select all

godRaysShaderParameters


Right now I would give anything to get anything that works for my projects as development has stalled.

I hope you can fix the files if you get free time so I can just add them to my project.
Also please repo and push them there so that other people can also help on improving the code.
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 818
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by xrgo » Wed Aug 30, 2017 6:28 pm

I am really sorry its hard to integrate, it was extracted from my engine, and i was really lazy and missed some stuffs that I should have removed, so its not plug n play, its going to need a bit of work.
just omit all the godrays stuffs
and the sunlightObject its just a directional light object of my engine, just use the sunLight which is a Ogre light
0 x

User avatar
Aiden
Halfling
Posts: 46
Joined: Fri Jul 14, 2017 3:16 pm

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by Aiden » Thu Aug 31, 2017 12:12 am

Ok, I'll try and see where I'll get. I'll will inform you when I get stuck.
Thanks for your time.
0 x

User avatar
Aiden
Halfling
Posts: 46
Joined: Fri Jul 14, 2017 3:16 pm

Re: [SOLVED][OGRE 2.1] Dynamic cubemap sky (postproc) render

Post by Aiden » Thu Sep 07, 2017 1:32 pm

xrgo wrote: just omit all the godrays stuffs
and the sunlightObject its just a directional light object of my engine, just use the sunLight which is a Ogre light
So much stuff breaks. I get many errors during compilation, unfortunately I couldn't get it to work. I'll just have to find another solution to this.
Thanks for the hint, I might try it again once I understand how Ogre 2.1 works, I just recently started using Ogre .
0 x

Post Reply