Dynamic Cubemaps? Possible work around?

Got problems with your models? Struggling with textures? Get help with your custom assets.

Dynamic Cubemaps? Possible work around?

Postby Hezus on Mon Feb 14, 2011 10:03 pm

Hey everyone,

I have a room with a light switch, which can be toggled. The room has a toilet prop with reflective surface. Now if I build the cubemaps with the lights on, the material on the toilet will be perfectly reflective. If I build cubemaps with the light off, there won't be any reflection.

You can probably guess what the problem is: After switching off the light, the reflections of the props will remain and appear full bright in a dark room. Alternativly I could build cubemaps in the dark room, but as soon as the light is on, they will just appear non-reflective and thus horribly dull.

As far as I know, dynamic cubemaps are not (yet) possible in Source. Can anyone come up with a out-of-the-box solution or work-around for this problem?

So far I've tried:
- teleporting props from a duplicated dark room to the original lit room. When the lit toilet is disabled and the dark toilet from the other room teleports into the lit room, it magically inherits the reflective properties of the disabled toilet. Even though their names are completely different. Unsure why Source does that, but it's not working.

- Adding a non-refective skin to the prop and toggle that with the light switch. Gave me the best results so far. But sadly this only works once. As soon as the light goes out, the toilet will switch to its non-reflective skin, but when the light goes on again the reflection data is suddenly gone, even though it correctly switched to the reflective skin.

Help is greatly appreciated. :smt023

EDIT: Managed to fix it.
Last edited by Hezus on Tue Feb 15, 2011 2:52 pm, edited 1 time in total.
Hezus
Dumpling
Dumpling
 
Joined: Mon Sep 14, 2009 11:17 am

Re: Dynamic Cubemaps? Possible work around?

Postby MayheM on Mon Feb 14, 2011 10:32 pm

The only thing I can think of is HDR may help with the problem. Since when you build lightmaps in HDR they will actually fad to dark as they are taken. I could be wrong, but it is worth a try...
Image
User avatar
MayheM
Veteran
Veteran
 
Joined: Tue Oct 16, 2007 7:46 pm
Location: Lancaster SC

Re: Dynamic Cubemaps? Possible work around?

Postby Jman on Mon Feb 14, 2011 10:46 pm

You could also duplicate the rooms that need the dynamic lighting and teleport the player rather than the props.
User avatar
Jman
Veteran
Veteran
 
Joined: Wed Mar 30, 2005 11:01 pm

Re: Dynamic Cubemaps? Possible work around?

Postby MayheM on Mon Feb 14, 2011 10:57 pm

The only thing with that Jman is what if they go in, turn the lights off and then leaves the room. You would have to have two versions of the map.
Image
User avatar
MayheM
Veteran
Veteran
 
Joined: Tue Oct 16, 2007 7:46 pm
Location: Lancaster SC

Re: Dynamic Cubemaps? Possible work around?

Postby omnicoder on Mon Feb 14, 2011 11:15 pm

MayheM wrote:The only thing with that Jman is what if they go in, turn the lights off and then leaves the room. You would have to have two versions of the map.

Monitors + teleports could solve that.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: Dynamic Cubemaps? Possible work around?

Postby Hezus on Tue Feb 15, 2011 12:54 pm

MayheM wrote:The only thing I can think of is HDR may help with the problem. Since when you build lightmaps in HDR they will actually fad to dark as they are taken. I could be wrong, but it is worth a try...


HDR indeed adjusts itself to the light level, but that has nothing to do with material reflection, though. Thanks for the suggestion anyway.

Creating 2 versions of the map is also impossible with the complex entity setup I currently have. Teleporting props over is something I can work with, but the player really needs to remain in the same place.

EDIT #2:
Managed to get it working :) Eureka!

I figured out how to bypass that disable bug. I decompiled the toilet and recompiled it with a different name and a non-reflective skin. Now I can have a non-reflective toilet and a reflective toilet next to eachother without them interfering eachother's reflections. Even after disabling and enabling the reflections stay.

Then I got rid of the button's Toggle function and started working with "OnIn" and "OnOut". So OnIn, the light goes off, the lit toilet disables and the dark toilet enables and vica versa.
Last edited by Hezus on Tue Feb 15, 2011 2:24 pm, edited 2 times in total.
Hezus
Dumpling
Dumpling
 
Joined: Mon Sep 14, 2009 11:17 am

Re: Dynamic Cubemaps? Possible work around?

Postby srredfire on Tue Feb 15, 2011 2:21 pm

Why not create two skins for the prop?

One lit, and one unlit. Turn light on, switch skin. Turn light off, switch skin.
srredfire
Veteran
Veteran
 
Joined: Sat Jul 22, 2006 10:44 pm

Re: Dynamic Cubemaps? Possible work around?

Postby Hezus on Tue Feb 15, 2011 2:26 pm

srredfire wrote:Why not create two skins for the prop?

One lit, and one unlit. Turn light on, switch skin. Turn light off, switch skin.


That's what I already tried. There is a bug in Source where as soon as you want to switch back to the reflective skin, all the cubemap reflections are suddenly gone.

EDIT: Have to correct myself here. Switching the skin does work, but only if the name of the model is different from the original. That's probably why it didn't work correctly the first time around. Makes it even easier :)
Hezus
Dumpling
Dumpling
 
Joined: Mon Sep 14, 2009 11:17 am

Re: Dynamic Cubemaps? Possible work around?

Postby Groxkiller585 on Sun Feb 20, 2011 12:43 am

Just a note, if you want actual animated cubemaps (like say something occurs in a given space always, repetetively, at the same time, no variation AT ALL) you can record a demo from the object's reflective viewpoint of said object moving across, convert it to an animated texture, and use that as the envmap. There's a specific parameter for animated bumpmaps, it's on the VDC somewhere.
User avatar
Groxkiller585
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Fri Jul 09, 2010 3:43 pm

Re: Dynamic Cubemaps? Possible work around?

Postby kraid on Sun Feb 20, 2011 9:50 am

My solution:
Compile this map (or single room) with only this one cubemap preferably placed where the prop will be in the final version.
Load the map, run buildcubemaps with lights on, exit the game and extract the cubemap from the bsp.
Now do the same again but with disabled lights. (you'll have to rename the cubemap vtf's)
If you're working with HDR you'll need to extract both, the LDR and HDR version of the cubemap.
Name them exactly the same but keep the .hdr.vtf on the HDR version.

Next you need to place them somewhere in your materials folder and use them as a envmap texture.
Make sure to add the .hdr to the texturename, that way it'll load the HDR version and only use the LDR one if the user disabled HDR.

Now you got a toilette_lighton.vmt and a toilette_lightoff.vmt material. (or whatever you named it)
Next step is the prop. Compile it using texturegroups in order to get two materials onto the same prop.

Once this is done, the rest is just a simple I/O thing in Hammer.
Whenever the light is switched, just change the skin of the prop.
Goldeneye Source v4.2.3
get it now and play for FREE!!!
http://www.goldeneyesource.net
kraid
Been Here A While
Been Here A While
 
Joined: Thu Jan 22, 2009 12:09 pm

Re: Dynamic Cubemaps? Possible work around?

Postby Gambini on Sun Feb 20, 2011 11:11 pm

There´s also an undocumented entity called info_lighting_relative. which turns an entity/several entities reporting lighting and reflection to a remote location, with its cubemaps included. Not sure if it can be switched on/off but it works as what you want so far.

If you still want to try it, do the following:

- Make a remote room that looks like the actual room but in different state (for example, if the light is off by default, make this room lit) -there´s no need to make it look exactly like the actual one, as this remote room serves the purpose of reflection and lighting only-

- Somewhere in this fake room, preferably in the center, put an entitiy "info_lighting_relative" -you´ll have to name it manually as this entity isn´t included in the fdg file-

- With smartedit disabled add two keys:
-key "lighting landmark" value "XX1 infotarget´s name"
-key "targetname" "XX2 ligthingoriginhack"

- Add an info_target in the actual room in proportional placement where the info_lighting_relative has been put. (for example if you´ve put it in the center, put the infolight in the center of the room).

- put a name to the info_target entity remember XX1.
- Add a key "ligthtingoriginhack" value "remember XX2" to the prop´s properties (the prop has to be dynamic).

*XX1 and XX2 are just example names.

Now if you compile the map and run buildcubemaps the aforesaid dynamic_prop will be lighted by and reflect the remote room environment. The question is if this can be really turned on/off via I/O. In any case, if you have trouble understanding this (likely, because my rough english) check the intro level of HL2, the train transition features this effect.
User avatar
Gambini
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 20, 2008 1:52 am
Location: Buenos Aires, Argentina.

Return to Custom Asset Help

Who is online

Users browsing this forum: No registered users