Board index FlightGear Development Scenery

lightmaps for random buildings

Questions and discussion about enhancing and populating the FlightGear world.

lightmaps for random buildings

Postby Volador » Sun Mar 13, 2022 11:38 am

In my quest to contribute to the random building textures I'm puzzled by some recent test results. Here's a pic of my new textures and lightmap at night, the foreground building windows don't seem to be as bright as the (not random) buildings in the background. I have a separate buildings-lightmap.png for the lightmap in which lit windows are bright values - is there something basic I'm missing here - any lightmap experts out there? Is there some alpha trick I'm missing?

Image

lightmap texture:
Image
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby Volador » Sun Mar 13, 2022 2:41 pm

and reading the wiki there seems to be more to it than just a texture recoloured to look like a night-time view acting as a lightmap - and looking at the atlas_facades.png there are greens and reds however in the roads texture there are just grey levels for the lightmap... confused
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby Thorsten » Sun Mar 13, 2022 4:14 pm

and reading the wiki there seems to be more to it than just a texture recoloured to look like a night-time view acting as a lightmap


Yes, a lightmap encodes illumination. In a multi-channel lightmap the r, g and b values determine where light is (and at what relative amount) and the strength parameter in the effect tells how strong the light source is.

In a single channel lightmap, I guess it's only the red channel that matters (though I would have to look into the code again to be sure, it's been a while).

Since the 'night time view' will be bright where there is light, it'd sort of work, but probably not as you intend.

So please read documentation first, it'll save you lots of trouble. :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: lightmaps for random buildings

Postby Volador » Sun Mar 13, 2022 5:59 pm

Chatting with another contributor it seems bits of the wiki might be out of date (trying my best to contribute here while not being fully able to understand the code), the situation currently was using some info from an older post of yours Thorsten where you gave some help on setting up a reflection map but also pointed me to the location of the lightmap.

Code: Select all
Ah, I think I understand the problem:

I guess that may be because the lightmap is also used as reflection map, i.e. the building reflects just where the windows are lit at night - dependent on how you did the lightmap, you may run into trouble.

Simply edit Effects/building.eff, go to the block


<texture n="3">
      <image>Textures/buildings-lightmap.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>clamp</wrap-s>
      <wrap-t>clamp</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>


insert just below


<texture n="4">
      <image>Textures/buildings_my_reflect_map.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>clamp</wrap-s>
      <wrap-t>clamp</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>

where buildings_my_reflect_map.png is your distribution of reflective material, then replace the blocks further down

<texture-unit n="4">
        <unit>4</unit>
        <image>
           <use>texture[3]/image</use>
        </image>
        <filter>
           <use>texture[3]/filter</use>
        </filter>
        <wrap-s>
           <use>texture[3]/wrap-s</use>
        </wrap-s>
        <wrap-t>
           <use>texture[3]/wrap-t</use>
        </wrap-t>
        <internal-format>
           <use>texture[3]/internal-format</use>
        </internal-format>
     </texture-unit>

with

<texture-unit n="4">
        <unit>4</unit>
        <image>
           <use>texture[4]/image</use>
        </image>
        <filter>
           <use>texture[4]/filter</use>
        </filter>
        <wrap-s>
           <use>texture[4]/wrap-s</use>
        </wrap-s>
        <wrap-t>
           <use>texture[4]/wrap-t</use>
        </wrap-t>
        <internal-format>
           <use>texture[3]/internal-format</use>
        </internal-format>
     </texture-unit>


and you should have an independent reflection map to edit. No idea why they were implemented that way...


I'm guilty of poking around with the building.eff file to change numbers as advised but it might be old information because that section of the building .eff file has another entry now with six references to texture where the old post showed five references and perhaps that n=4 value is significant and should not be re-defined as a variable?

Code: Select all
   <technique n="4">
      <!-- Atmospheric scattering technique with model shader-->
      <pass>
         <texture-unit n="4">
            <unit>4</unit>
            <image>
               <use>texture[4]/image</use>
            </image>
            <type>
               <use>texture[4]/type</use>
            </type>
            <filter>
               <use>texture[4]/filter</use>
            </filter>
            <wrap-s>
               <use>texture[4]/wrap-s</use>
            </wrap-s>
            <wrap-t>
               <use>texture[4]/wrap-t</use>
            </wrap-t>
            <internal-format>
               <use>texture[3]/internal-format</use>
            </internal-format>
         </texture-unit>


Anyway, I think for me my contribution here is more 'art' than 'code' so I will continue to seek input from a willing expert in the code field who has a little time ;)

Some recent progress:
Image

Image
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby Volador » Sun Mar 13, 2022 6:25 pm

FG Mars edition anyone hahaha - getting a bit closer

Image
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby Gabo Huerta » Fri Jul 01, 2022 1:46 pm

I think I have solved part of the problem a little bit by increasing the brigthness of the light map.

So far I have only applied a new light map texture to one building but it seems to work, I don't know if this solution could affect any other render settings.

The 2 drawbacks to this solution are:
1 the lightmap can start to show a bit early.
2 the lightmaps are not guides which light up the normal building textures anymore, but basically independent textures by themslves which swap the normal building texture, and reflections during night time.
This requires a lot of work to make the light map textures, which could take a long time but I think it might be worth it.

On the following pictures all the windows are black on the buildings texture, the reflec-map goes exactly on top of the windows, during the night the textures on the windows almost swap with pictures of real windows taken from wikicommons , some lightning effects were created by blending alpha channel and the normal building texture.

Image
Image
Image
Image
Image
User avatar
Gabo Huerta
 
Posts: 23
Joined: Tue Sep 24, 2013 2:45 am
Location: Australia
Version: 2020.3
OS: Windows

Re: lightmaps for random buildings

Postby Volador » Fri Jul 01, 2022 8:18 pm

Nice work Gabo, and thanks for spending some time figuring it out :) do I understand that with this technique that I need to create a bitmap which is the buildings as they appear at night with the windows lit (not a bitmap which is just the lit windows surrounded by blank alpha)
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby TheEagle » Fri Jul 01, 2022 10:04 pm

If I got this right this is the "old"-ish method of lighting something - a day texture and a night texture, a material animation that selects the day or night texture based on the sun angle and an emission animation that is only active at night. It has the plus point of working without ALS, but in return you need an XML file for every building (if of course Gabo did some effect magic, then just forget this message)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: lightmaps for random buildings

Postby Gabo Huerta » Fri Jul 01, 2022 10:50 pm

ok this is what I have done.

Once reflection and lightmap are separated textures I modified the textures to the following.

First, in the buildings textures I changed all the windows to black, getting rid of any detail on them

Image

the same for the "reflection map" (the alpha channel has been replaced by pure white for demonstration purposes)

Image

this is the lightmap for the only building I worked on (the alpha channel has been replaced by pure white for demonstration purposes):

Image

at the end, to improve the brightnes of the lightmap I changed this value on building.eff

Code: Select all
   <lightmap-color type="vec3d" n="0"> 0.8 0.8 0.8 </lightmap-color>


which originally was

Code: Select all
   <lightmap-color type="vec3d" n="0"> 0.3 0.3 0.3 </lightmap-color>


I don't know if this change affects any other visual effect, the lightmap is still blending with the texture of the building but it seems to be more dominant.

Changing the topic, I don't know if you can help me to have access to sourceforge and maybe teach me how it works so I can upload all the files I modified.
User avatar
Gabo Huerta
 
Posts: 23
Joined: Tue Sep 24, 2013 2:45 am
Location: Australia
Version: 2020.3
OS: Windows

Re: lightmaps for random buildings

Postby TheEagle » Sat Jul 02, 2022 1:21 am

For commit access to the SourceForge repos you need to ask on the developer mailing list, but generally it's better to create a fork, do your changes there, and when everything is tested and working properly you open a pull request. As for uploading the files, you should familiarize yourself with svn or git - git is pretty easy, it's basically just
Code: Select all
#for initial clone
git clone <some-repo-url> <some-folder-name>

#then, as often as you want
cd <some-folder-name>
git pull
<make changes to the files>
git add *
git commit -a
git push

and your changes will be in the SourceForge repo (either your fork or the base repo). But do only commit and push working code if possible ! :wink:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: lightmaps for random buildings

Postby Volador » Sat Jul 02, 2022 5:45 pm

Gabo, I have write access to the FGassets folder on sourceforge as part of this updating buildings texture project I took on, if you'd like to chat on email we can get the textures together and with your guidance I'll do some more work on my updated artwork and I'll be able to pop the finished files into Sourceforge. From there we can wait for a friendly Dev to commit the work (if they approve, of course) :)

But, if Eagle's suggestion would be cleaner, (if I understand the process) would we be updating the textures and the building.eff and then ask for the commit?
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby TheEagle » Sat Jul 02, 2022 5:59 pm

The usual way is to fork the main FGdata repository. This will create a copy of the FGData repo that is owned by the fork creator, and thus it's the fork creator who has the write access. So then you push your changes into your own fork, then file a pull request - then someone with write access to the main FGData repo can merge your changes, but for that to actually happen you might have to put a notice on the mailing list ! :wink:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: lightmaps for random buildings

Postby Volador » Sat Jul 02, 2022 6:10 pm

Thanks Eagle, I think I'm sorted as I've been chatting with the dev's about this one for a while so I have their attention, so if we can get a solution it'll just be an updated building.eff (if it does not break previous versions) and the new random buildings texture atlas bitmap, reflection map bitmap and lightmap bitmap.
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Re: lightmaps for random buildings

Postby Gabo Huerta » Sun Jul 03, 2022 12:06 am

TheEagle wrote in Sat Jul 02, 2022 5:59 pm:The usual way is to fork the main FGdata repository. This will create a copy of the FGData repo that is owned by the fork creator, and thus it's the fork creator who has the write access. So then you push your changes into your own fork, then file a pull request - then someone with write access to the main FGData repo can merge your changes, but for that to actually happen you might have to put a notice on the mailing list ! :wink:

I'll create the fork for me and Volador so we share the textures and .eff files.

Volador: I'll contact you through email and tell you how to get access to our version of FG that we can work on until we finish a good candidate to propose for the main repository.
User avatar
Gabo Huerta
 
Posts: 23
Joined: Tue Sep 24, 2013 2:45 am
Location: Australia
Version: 2020.3
OS: Windows

Re: lightmaps for random buildings

Postby Volador » Sun Jul 03, 2022 8:22 am

Gabo Huerta wrote in Sun Jul 03, 2022 12:06 am:Volador: I'll contact you through email and tell you how to get access to our version of FG that we can work on until we finish a good candidate to propose for the main repository.


Thank you Gabo, it's great you've been able to spend a little time to get this pushed over the line :)
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Next

Return to Scenery

Who is online

Users browsing this forum: No registered users and 3 guests