Board index FlightGear Development Scenery

lightmaps for random buildings

Questions and discussion about enhancing and populating the FlightGear world.

Re: lightmaps for random buildings

Postby jam007 » Sun Nov 27, 2022 3:40 pm

I would like to improve some buildings I made earlier using this technique but am a bit stuck.
As I understand it you create, or have, one ordinary texture (but with black windows). You create one reflective texture with black for reflections and transparent otherwise. And one lightmap texture with black for fully illuminated (emissive) and transparent for dark parts. Correct?
But what is the code for combining those textures? I assume a xml-file for the building with effects-settings.
jam007
 
Posts: 584
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: lightmaps for random buildings

Postby TheEagle » Sun Nov 27, 2022 3:49 pm

At least for lightmaps, white would be fully illuminated, and black would be unlighted - the alpha channel doesn't matter for a normal lightmap (I think). And I guess it is the same for reflection maps.
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: 3433
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 jam007 » Mon Nov 28, 2022 8:57 am

Thanks!
I must have misunderstood the images in this post
jam007
 
Posts: 584
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: lightmaps for random buildings

Postby Volador » Mon Nov 28, 2022 6:45 pm

Hi Jam007,

Here is the latest progress on he random buildings texture atlas I've been working on (and off) (as time allows). Gabo has been helping with the code that sets the illumination code .eff and also the reflection visibility as it's already implemented in buildings.eff (and was going to work on the tower blocks part of the texture) file but then couldn't commit the time. @Eagle - are you sure about the alpha channel, this has made the whole process very confusing for the lightmap (for me) and I've not got it to work on Next yet but Gabo got it to work on 2020.3 - so I'm still a bit lost and it could be how GIMP and Photoshop differ in how they display the alpha - but that's not the whole story. The texture atlas has so far got daylight houses but the flats and towerblocks have not been changed yet, neither the roof textures or a new normal map (normal map at the end of the process). If this thread helps you figure it out could you share what you discover?
https://sourceforge.net/p/flightgear/as ... 20atlases/
User avatar
Volador
 
Posts: 1142
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 » Mon Nov 28, 2022 8:06 pm

I have looked at the shader source code, and I can confirm that when <lightmap-multi> is set to zero (disabled), then the lightmap's RGB value sets the color and the <lightmap-factor n="0"> sets the lighting intensity - the lightmap's alpha value is ignored.
For reflection maps, only the alpha channel is used to set the reflectivity where fully transparent = no reflections and fully opaque = full reflection intensity - the RGB channels are used to set the dirt color (if dirt is enabled). I hope everything is more clear now ! :)
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: 3433
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 » Mon Nov 28, 2022 8:45 pm

@Eagle are you referring to the buildings.eff code (for the random buildings only) shader code? I'm checking because if I understood some previous info apparently there are different shaders employed for OSM buildings and other buildings can use different shaders.
User avatar
Volador
 
Posts: 1142
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 » Tue Nov 29, 2022 2:33 am

@Volador: I've just checked - the fragment shaders are inherited from model-combined.eff (which is the one I read the shaders of), only the first vertex shader is overwritten - but this kind of stuff is handled within the fragment shader, so what I wrote in my last post still holds true ! :)
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: 3433
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 jam007 » Thu Dec 01, 2022 1:50 pm

Ok. As I understand it from the above the building.eff uses the lightmap-texture for both reflection and lighting. The rgb values determines the lighting and the alpha the reflection. Is that correct?
jam007
 
Posts: 584
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: lightmaps for random buildings

Postby TheEagle » Thu Dec 01, 2022 1:52 pm

No, for normal single-channel lightmaps (where <lightmap-multi> is set to 0 in the effect file) the alpha value is ignored completely. You need a separate reflection map in which the alpha value is used for the reflectivity.
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: 3433
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 jam007 » Thu Dec 01, 2022 2:36 pm

In the building.eff code there is, from what I can see, no separate reflection map but (maybe) texture[3] which seems to be the lightmap:
Code: Select all
<!-- Light Map -->
      <texture n="3">
         <image>Textures/buildings-lightmap.png</image>
         <type>2d</type>
         <filter>linear-mipmap-linear</filter>
         <wrap-s>clamp</wrap-s>
         <wrap-t>clamp</wrap-t>
         <internal-format>normalized</internal-format>
      </texture>
      <lightmap-enabled type="int"> 1 </lightmap-enabled>
      <lightmap-multi type="int"> 0 </lightmap-multi>
      <lightmap-factor type="float" n="0">
         <use>/sim/time/sun-angle-rad</use>
      </lightmap-factor>
      <lightmap-color type="vec3d" n="0"> 0.3 0.3 0.3 </lightmap-color>

      <!-- Reflection -->
      <reflection-enabled type="int"> 1 </reflection-enabled>
      <reflect-map-enabled type="int"> 1 </reflect-map-enabled>
      <reflection-correction type="float"> -0.15 </reflection-correction>
      <reflection-dynamic type="int"> 0 </reflection-dynamic>
      <reflection-fresnel type="float"> 0.0 </reflection-fresnel>
      <reflection-rainbow type="float"> 0.0 </reflection-rainbow>
      <reflection-noise type="float"> 0.0 </reflection-noise>
      <texture n= "5" >
         <type>cubemap</type>
         <images>
            <positive-x>Aircraft/Generic/Effects/CubeMaps/buildings/N.png</positive-x>
            <negative-x>Aircraft/Generic/Effects/CubeMaps/buildings/S.png</negative-x>
            <positive-y>Aircraft/Generic/Effects/CubeMaps/buildings/W.png</positive-y>
            <negative-y>Aircraft/Generic/Effects/CubeMaps/buildings/E.png</negative-y>
            <positive-z>Aircraft/Generic/Effects/CubeMaps/buildings/U.png</positive-z>
            <negative-z>Aircraft/Generic/Effects/CubeMaps/buildings/D.png</negative-z>
         </images>
      </texture>
   ...
   </parameters>

   <technique n="4">
      <!-- Atmospheric scattering technique with model shader-->
      <pass>
         <texture-unit n="4">
            <unit>4</unit>
            <image>
               <use>texture[3]/image</use>
            </image>
            <type>
               <use>texture[3]/type</use>
            </type>
            <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>
...
   </technique>

Hm?
jam007
 
Posts: 584
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: lightmaps for random buildings

Postby TheEagle » Thu Dec 01, 2022 3:31 pm

Ohh, now I see … the building.eff inherits from model-combined.eff. In the latter, we have a texture n="4" in the parameters section, which is referenced in the technique by texture unit 4 (the reflection map texture unit). But - building.eff overwrites the declaration of texture unit 4 in the technique and uses texture n="3" from the parameters which is … the lightmap texture unit !

So you were right: the lightmap for buildings is used both for the light and the reflection - RGB sets the light color, and the alpha channel sets the reflectivity. Sorry for causing confusion …
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: 3433
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 » Thu Dec 01, 2022 8:22 pm

From what I understand from conversations with Gabo, the history was that Gabo originally 'cheated' and set the code up so that the light-map and reflection map were in the same slot (or used the same bitmap that had dark and light areas for both day and night scenarios). He's re-written the code so that we have a separate light-map (any illuminated windows and walls) and now a separate reflection map (just solid rectangles where there is glass). The hurdle is that the reflection map was blocking the light-map, so I think he tweaked transparency or factors so that night time gave more weight to illumination and daytime gave more weight to the reflections ( or a value in-between to catch both cases acceptably). At present it does not work on Next, I'll dig out the latest code (that Gabo got working on 2020.3) when I can but given your knowledge on the subject you might know how to solve it for Next?
User avatar
Volador
 
Posts: 1142
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 » Thu Dec 01, 2022 8:30 pm

Well, depends on what "doesn't work" means exactly ? ;) Does it give an error ?
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: 3433
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 » Fri Dec 02, 2022 5:36 pm

These are the work in progress texture atlases and the folder containing Gabo's new buildings.eff code. Gabo said to also replace the building.eff code in the folder Compositor (Although I'd question you'd only need to replace the building.eff in the folder Effects?) - my OSM buildings disappeared using this new .eff file. The textures do work if you do a straight swap with the new texture file and the current buildings.eff

https://sourceforge.net/p/flightgear/as ... 20atlases/

Also just popped in a lightmap test texture but that's not called in the code
User avatar
Volador
 
Posts: 1142
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 Dec 02, 2022 7:18 pm

Uhhh, I think you must have misunderstood Gabo - I think, https://sourceforge.net/p/flightgear/as ... ilding.eff is the replacement file for the 2020.4.0 nightlies and https://sourceforge.net/p/flightgear/as ... ilding.eff is for the 2020.3 releases - if you used the latter with a nightly / git next build, that might explain that you got no buildings anymore ! ;)
So, please retry, using https://sourceforge.net/p/flightgear/as ... ilding.eff as replacment for your fgdata-gitnext/Effects/buildings.eff.
Also in the two effect files from the repo you linked, the reflection map is in a separate file again - so what I said in the first place about the lightmap's alpha channel being ignored is valid for those ! :mrgreen:
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: 3433
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

PreviousNext

Return to Scenery

Who is online

Users browsing this forum: No registered users and 2 guests