Jump to content


Photo

Electrically flickering windows


9 replies to this topic

#1 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 04 August 2018 - 09:37 AM

In my mission I have a lot of flickering electric lights, but at the moment it somewhat stands out that the windows have a constant light intensity. They're lit up by those same electric lights from the interior, so they should be flickering in a similar way too.

So far Ive found 2 methods for making something flicker:
1) adding 'rgb candle_01 [ time * .05 ]' to the material, such as in diamond_pattern02_flicker02.
2) making the _color intensity depend on the sound volume, which is what the electric lamps use.

The problem with #1 is that it's more pulsating slowly than flickering, while #2 requires a sound to be played at an audible volume. Isn't there a better way to make a texture flicker in an electric kind of way?

#2 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37446 posts

Posted 04 August 2018 - 09:41 AM

You can increase the speed of the flickering in 1 by using higher numbers than .05.
TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#3 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 04 August 2018 - 10:00 AM

Multiplying the speed by 3-5 looks fairly decent and I can work with that, but still it's constantly going up and down a sine curve. The ideal would be to make it blink off every now and then. Alright, I could think of a way to script it, but can it be done via a material?

#4 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5710 posts

Posted 04 August 2018 - 10:01 AM

In regards to method 1 you should use the flickering method as used by the light shader of the nearby light. This way both light and window flickering will be in sync.

 

Another approach (especially if there are several light sources nearby) would be to make uses of the script function vector getLightInPVS(...). It computes the light hitting the respective entity. Note though that

  1. it requires you to write a scriptobject to be used by the respective windows
  2. the materials used by that windows must be altered, too
  3. it may get performance houngry if there are lots of lights/windows in the scenes your mission consists of
  4. the light calculation will most probably refer to the origin, which, depending on where that is, my lead to inaccurated results
  5. it may not take blocked off light sources into account.

I was thinking about creating such a script object on my own for a while now. It is already possible to change the skin of windows by adding them as a target to a nearby light source, as long as the latter uses the tdm_light_holder scripobject. Most stock combined light entities do so. That is a change introduced by me in 2.05 iirc. The above behaviour would be an extension to that behaviour, but I haven't found the time to completely think it through yet.

 

However, depending on your mission a simpler solution might already suffice.


  • Bikerdude and Dragofer like this
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#5 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 04 August 2018 - 10:15 AM

Another approach (especially if there are several light sources nearby) would be to make uses of the script function vector getLightInPVS(...). It computes the light hitting the respective entity.

Alright, so this sounds like making a kind of lightgem calculation to find out how bright the exterior window should be. It's an interesting idea and I think it'd be especially useful for doors with windows in them, though for my usage a simpler solution can indeed be used because most of the time you can't see the light source and the exterior window simultaneously. In those cases where you do see both I can use a good light.

I'm thinking now of just using a fast-acting fading script that's called at random intervals on certain windows, if nothing else.

Edited by Dragofer, 04 August 2018 - 10:21 AM.


#6 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 04 August 2018 - 10:56 AM

Actually at a second glance it looks like

rgb candle_01 [ time * .05 ]

can be interpreted as 'let the intensity follow the pattern of candle_01 at a speed of [time * 0.5].

If I knew what kind of asset 'candle_01' is, then it'd be possible to create new patterns for electrical flickering. Any ideas where it's found?
  • Springheel likes this

#7 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37446 posts

Posted 04 August 2018 - 11:08 AM

Multiplying the speed by 3-5 looks fairly decent and I can work with that, but still it's constantly going up and down a sine curve. The ideal would be to make it blink off every now and then. Alright, I could think of a way to script it, but can it be done via a material?

 

The strength of each change is controled by the "table" the formla uses (that's what candle01 is).  A table that uses "0, 0.5, 1, 0.5" will cycle from off to half brightness to full brightness to half and back to off. A table like " 1, 1, 1, 1, 1, 0, 1, 1, 1" would stay on full brightness most of the time but would blink off momentarily (the length of time each number occupies depends on the speed you set using the "time" formula).

 

You can make your own table in material files (the light material file has examples of the syntax).  Or you can pick a table the already has the values you want and put that name in the material shader instead of the candle one currently being used.


  • Dragofer likes this
TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#8 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 04 August 2018 - 11:20 AM

Excellent, that's just what I was looking for. Just replacing candle_01 with stormtable already comes very close.

#9 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1803 posts

Posted 25 August 2018 - 06:46 AM

Did you try to use the "sound" keyword in your material?

Right, you need it to be playing currently.

What would happen if you put the second sound on this side of the window and gag it? So that not only it's flickering but also mumbling.



#10 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 565 posts

Posted 25 August 2018 - 03:53 PM

Did you try to use the "sound" keyword in your material?
Right, you need it to be playing currently.
What would happen if you put the second sound on this side of the window and gag it? So that not only it's flickering but also mumbling.


Thanks for offering ideas duzenko - if I got your point correctly you'd make the windows themselves emit a muted flickering sound? The issue with that is that the colour intensity is tied to the sound intensity, so an audible sound has to be heard. Hmm... maybe I could make a custom soundshader where the sound is played with 0.01 range. Re-export each room's windows as a single model to reduce the number of speakers.

Well what I've settled on so far is to make new window materials and instruct them to follow a table of colour intensities + use healthier lamps for places where you can see both the lamp and the exterior window.

Ideal world would be to link the windows directly to the lamp entities, but there are good alternatives which I'm quite pleased with.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users