[2.1] How to HMLS PBS dunamic cubemap reflection ?
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
[2.1] How to HMLS PBS dunamic cubemap reflection ?
How to dynamic cubemap reflection with OgreHMLSPbsDatablock??
c++ game developer.
current project: Imperial Game Engine 2.5
current project: Imperial Game Engine 2.5
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
first create a camera for the cubemap, then a cube texture, and a workspace:
"WorkspaceCubeMap" should be defined somewhere, my definition looks like this:
Then you can use that "envCubeMap" as reflection texture on your hlmsPbsDatablock
Be aware that this is very expensive, so one thing you can do is to update "envCubeMapWorkspace" not every frame, maybe every other frame or less (that's why I set it as disabled) or you can just set it as enabled and let it run
Code: Select all
envCam = sceneManager->createCamera( "envCubeMapCamera",true,true );
Ogre::Camera* envCam->setFOVy(Ogre::Degree(90));
envCam->setAspectRatio(1);
envCam->setFixedYawAxis(false);
envCam->setNearClipDistance(0.01);
envCam->setFarClipDistance(1000);
Ogre::TexturePtr envCubeMap = Ogre::TextureManager::getSingletonPtr()->createManual(
"envCubeMap",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_CUBE_MAP,
512,
512,
Ogre::MIP_UNLIMITED, //if you want mipmaps
Ogre::PF_R8G8B8,
Ogre::TU_AUTOMIPMAP | Ogre::TU_RENDERTARGET | Ogre::TU_AUTOMIPMAP_AUTO, //if you want mipmaps
0,
true
);
Ogre::CompositorChannel channel;
channel.target = envCubeMap->getBuffer(0)->getRenderTarget(); //Any of the render targets will do
channel.textures.push_back( envCubeMap );
Ogre::CompositorWorkspace* envCubeMapWorkspace = root->getCompositorManager2()->addWorkspace(sceneManager, channel, envCam, "WorkspaceCubeMap", false); //notice it start disabled
Code: Select all
//CUBEMAP WORKSPACE for enviroment map
//+X'. '-X', '+Y', '-Y', '+Z', and '-Z
abstract target cubemap_target
{
pass clear
{
colour_value 0 0 0 1
}
pass render_scene
{
//lod_update_list off
overlays off
camera_cubemap_reorient true
}
pass generate_mipmaps {} //if you want mipmaps
}
compositor_node cubeMapRenderNode
{
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 { }
}
//CubeMap Workspace
workspace WorkspaceCubeMap
{
connect_output cubeMapRenderNode 0
}
Be aware that this is very expensive, so one thing you can do is to update "envCubeMapWorkspace" not every frame, maybe every other frame or less (that's why I set it as disabled) or you can just set it as enabled and let it run
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I saw this post on my phone, and completely forgot to reply to it when I got home... sorry
However it did give me an idea....
Allow the scripts to define when a compositor is updated, it could be everyFrame, timeInterval, frameInterval or onRequest.
Any thoughts? Cant really think of any other use cases except dynamic env maps...
However it did give me an idea....
Allow the scripts to define when a compositor is updated, it could be everyFrame, timeInterval, frameInterval or onRequest.
Any thoughts? Cant really think of any other use cases except dynamic env maps...
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I would love thatal2950 wrote:Allow the scripts to define when a compositor is updated, it could be everyFrame, timeInterval, frameInterval or onRequest.
I usually do this (but manually) for mirrors and TVs/Screensal2950 wrote:Cant really think of any other use cases except dynamic env maps...
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
ok/ thanks/ i fiirst think its new only dataclock
c++ game developer.
current project: Imperial Game Engine 2.5
current project: Imperial Game Engine 2.5
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
there i integrate according to task cubemap camera. but in resultat is no camera show.
Original
on picture:
camera- cubemap camera.
cube- manual object 2 that have applied cubemap material. last have added sampler of diffuse map.
Original
on picture:
camera- cubemap camera.
cube- manual object 2 that have applied cubemap material. last have added sampler of diffuse map.
c++ game developer.
current project: Imperial Game Engine 2.5
current project: Imperial Game Engine 2.5
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
c++ game developer.
current project: Imperial Game Engine 2.5
current project: Imperial Game Engine 2.5
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Did you do anything special to get the reflections to be correct? Currently they are incorrect out of the box with Ogre when using dynamic cubemaps.
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
This would be awesome! In my Ogre 1.10 I update the dynamic env maps and mirrors every x frames, would be good to stick that into a script indeed!al2950 wrote: Allow the scripts to define when a compositor is updated, it could be everyFrame, timeInterval, frameInterval or onRequest.
Any thoughts? Cant really think of any other use cases except dynamic env maps...
I am about to try to implement Dynamic Env Maps and Mirrors in Ogre 2.1. Is this still the best way to do it? How do you manually update it every x frames using this method?
Thanks for your help!
Ash
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I'll be pushing a dynamic cubemap demo this weekend, if anyone's interested and wants to wait one or two days.
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Ah, great, I'll wait for that - thanks!dark_sylinc wrote:I'll be pushing a dynamic cubemap demo this weekend, if anyone's interested and wants to wait one or two days.
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Demo implemented. The sample is in 2.1-pso branch, but it can be easily backported to 2.1 (in fact it's easier because there is no need to expose the cubemap to the pass; you can just ignore that)
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
dark_sylinc wrote:Demo implemented. The sample is in 2.1-pso branch, but it can be easily backported to 2.1 (in fact it's easier because there is no need to expose the cubemap to the pass; you can just ignore that)
Code: Select all
pass render_scene
{
//Filter stuff that shouldn't be reflected (vampires?)
visibility_mask 0x00000005
overlays off
camera_cubemap_reorient true
}
}
Thanks!
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I've managed to get the envmap rendering, but for some reason the orientation and texture co-ords seem to be off. I thought the PBS shader would be able to receive the cubemap rendered in this way. I have no doubt have misunderstood somewhere. Here is a video of the problem: -
[youtube]Evk9N5EdqOI[/youtube]
Here is the Material in question: -
I am using xrgo's code above to create the texture / camera / workspace and updating the envCam's position each frame.
Any pointers would be appreciated
Thanks!
Ash
[youtube]Evk9N5EdqOI[/youtube]
Here is the Material in question: -
Code: Select all
"fs_carbody": {
"macroblock": "Macroblock_0",
"blendblock": "Blendblock_0",
"shadow_const_bias": 0.01,
"workflow": "specular_ogre",
"diffuse": {
"value": [
0.784314,
0.784314,
0.784314
],
"texture": "FS01_carbody.dds",
"sampler": "Sampler_1"
},
"specular": {
"value": [
0.784314,
0.784314,
0.784314
]
},
"fresnel": {
"value": 0.1,
"mode": "coeff"
},
"roughness": {
"value": 0.000005
},
"reflection" :
{
"texture" : "envCubeMap"
}
}
I am using xrgo's code above to create the texture / camera / workspace and updating the envCam's position each frame.
Any pointers would be appreciated
Thanks!
Ash
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
can you try it in a sphere so its easier to see whats happening
Also! you should try the new sample Tutorial_DynamicCubemap
Also! you should try the new sample Tutorial_DynamicCubemap
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Thanks, I'll try again tonight. I was trying to make the car a mirror, I thought that roughness = 0 would make that happen, but it didn't work. Do you have a datablock that is a proper mirror?xrgo wrote:can you try it in a sphere so its easier to see whats happening
Also! you should try the new sample Tutorial_DynamicCubemap
Thanks!
Ash
- GlowingPotato
- Goblin
- Posts: 211
- Joined: Wed May 08, 2013 2:58 pm
- x 10
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
to make a mirror using specular workflow,
For metallic worflow, have booth diffuse color and specular color set to pure white,
Metallic set to 1.0 and roughness to 0.01
If you set roughness to 0, you will receive a warning saying the roughness value is too low and can cause issues.
Code: Select all
"mirror_material": {
"macroblock": "default_macro",
"blendblock": "default_blend",
"alpha_test": [
"disabled",
0.5
],
"shadow_const_bias": 0.01,
"workflow": "specular",
"diffuse": {
"value": [
0.0,
0.0,
0.0
]
},
"specular": {
"value": [
1.0,
1.0,
1.0
]
},
"roughness": {
"value": 0.01
},
"reflection": {
"texture": "cubeMap.dds",
"sampler": "default_sampler"
}
},
Metallic set to 1.0 and roughness to 0.01
If you set roughness to 0, you will receive a warning saying the roughness value is too low and can cause issues.
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Clearly... it's upside down <captain obvious flies away>
Are you rendering to a RenderTexture instead of directly to the RenderWindow? I suspect it could be an Ogre bug.
Is this D3D11 or GL?
Edit: I just realized the PassScene applies camera reorientation relative to its current orientation. That means the camera you're telling Ogre to use for rendering could be upside down. Try ensuring it has an identity quaternion as orientation. If that doesn't work... I guess you could roll the camera so it counters the upside down?
Are you rendering to a RenderTexture instead of directly to the RenderWindow? I suspect it could be an Ogre bug.
Is this D3D11 or GL?
Edit: I just realized the PassScene applies camera reorientation relative to its current orientation. That means the camera you're telling Ogre to use for rendering could be upside down. Try ensuring it has an identity quaternion as orientation. If that doesn't work... I guess you could roll the camera so it counters the upside down?
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I set the _envCam's orientation to Identity on creation. I assume that the compositor takes care of the orientation after that?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
@Ash You will see your post has been edited and a lot of what you wrote was lost. I accidentally hit "Edit" instead of "Quote" and didn't realize. I hate it when it happens!!!
Sorry.
First check it truly is identity (maybe it's being overridden somewhere). or else try rolling it the envCam's 180°.
Btw. look for "mCamera->setOrientation( oldCameraOrientation * CubemapRotations[sliceIdx] );" in OgreMain's code. Place a breakpoint, and see that oldCameraOrientation is identity.
Sorry.
I meant the _envCam's orientation.AshMcConnell wrote:I set the _envCam's orientation to Identity on creation. I assume that the compositor takes care of the orientation after that?
Do you mean the main camera that I am rendering the "real" scene with (rather than the camera for env mapping)? It is connected relatively to the car. If it is showing everything correctly, I'm not sure how it could be upside down - maybe I'm being silly
I set the _envCam's orientation to Identity on creation. I assume that the compositor takes care of the orientation after that?
First check it truly is identity (maybe it's being overridden somewhere). or else try rolling it the envCam's 180°.
Btw. look for "mCamera->setOrientation( oldCameraOrientation * CubemapRotations[sliceIdx] );" in OgreMain's code. Place a breakpoint, and see that oldCameraOrientation is identity.
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
Maybe you've done nothing wrong. I just realized the demo works on 2.1-pso branch... this may be a 2.1-specific bug. Mmmm....
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact:
Re: [2.1] How to HMLS PBS dunamic cubemap reflection ?
I think other guys have got it working without a tactical piece of code*dark_sylinc wrote:Maybe you've done nothing wrong. I just realized the demo works on 2.1-pso branch... this may be a 2.1-specific bug. Mmmm....
*Dirty hack
- AshMcConnell
- Silver Sponsor
- Posts: 605
- Joined: Fri Dec 14, 2007 11:44 am
- Location: Northern Ireland
- x 16
- Contact: