Board index FlightGear Development Effects and shaders

Night lighting on an Urban/Suburban/Town etc texture

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Mon Feb 01, 2021 4:34 am

What is the best way to supply lights to an Urban, Suburban, Town, Industrial, Transport or similar texture? I have been trying to find out how to apply a relief-light but can't seem to find any documentation on the subject. And with the new compositor, is there, perhaps, a better approach?

I've also searched the forum and found this from a post by Thorston, but as this is my first venture into this topic, I'm not understanding how to use it:
I've looked into the urban effect. This supports an implicit lightmap. The z-component of the normal map is read as emissive strength (well, the b-color channel) and the emissive color is declared in /Effects/urban.eff as <night-color type="vec3d">0.75 0.59 0.05</night-color>. So at night, if the urban effect is on, cities are illuminated with that color where the city normalmap /Textures.high/Terrain/city2-relief-light.png has a blue color value.

Which means that you can illuminate any urban/suburban texture you like by declaring a derived effect which inherits from urban and just changes the color value of the light, and then supplying a normal map which has no r and g color values but just specifies illumination via the b channel. This'd even work for roads I guess.

Any help will be much appreciated!
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby Thorsten » Mon Feb 01, 2021 7:20 am

Look into the existing examples of lit urban texture and then look at the matching normal map - you'll quickly grasp how it's done.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Mon Feb 01, 2021 10:10 pm

Thank you for your quick reply, @Thorsten! Unfortunately, I'm a complete beginner on this topic, so it is not obvious to me how to create the <texture>.relief-light.png, even though (for hours) I've looked at the existing examples and tried various possibilities.
  • I have created a working <texture>.mask.png. I "assume" this procedure is somewhat similar, but I've "assumed" things before and found them to be incorrect.
  • Existing relief-light.png files appear to be on a transparent background. I'm not understanding how the non-illuminated (greenish) area is created or how the entire relief-light.png is done.
  • Is the non-illuminated value set to the (emissive?) "vec3d" sRGBp color, in this case, 0.75, 0.59, 0.05 or sRGB8 (192, 151, 12)? Where is that set? I "assume" I don't insert the value somewhere in the urban.eff.
  • Is the "blue" channel area (illuminated area) a normal blue (0.498, 0.498, 0.914)?
Any help you (or someone else) is willing to give me would be greatly appreciated.
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby Thorsten » Tue Feb 02, 2021 7:41 am

so it is not obvious to me how to create the <texture>.relief-light.png


Basically you take a painting program of your choice (gimp,...) select a brush of your choice and just paint the color you want onto a texture. One of the colors encodes night lighting light, so... you visually find out which one by inspecting the existing example, and paint that color onto the texture you need for your application in the shape you want.

Granted, it takes some familiarity with the painting tool, but that's how it's done and you can learn that in an afternoon. :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Tue Feb 02, 2021 6:20 pm

So here's an example relief-light.png from FG2020.4.0: Image
You can see it uses transparency.
Here is an attempt to create a relief-light.png by sampling the colors from the example and simply painting: Image
My conclusion is that creating a relief-light is not (quite) as simple as sampling the (blue) color from the example, or even a standard blue by entering the standard blue values (0. 0, 255), selecting the brush and moving it around the image where you want areas illuminated. There is a considerable difference between the two in addition to the fact that one works (the example) and one doesn't (the "simple painting" try).
So my question is, how was the example created?
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby Thorsten » Tue Feb 02, 2021 6:49 pm

My conclusion is that creating a relief-light is not (quite) as simple as sampling the (blue) color from the example, or even a standard blue by entering the standard blue values (0. 0, 255), selecting the brush and moving it around the image where you want areas illuminated.


You lost me on the part why that is your conclusion, because I'm not aware of any other magical technique to create illumination that way - to the best of my knowledge the original file WAS created by moving a brush around the image where you want areas illuminated (I'd argue the small imperfections even show the brushwork). I didn't do the city illumination myself, but I can vouch that all autumn coloring (which is encoded in pretty much the same way as the lighting) IS done by moving a brush across the texture sheet.

Of course texture work isn't generally something you do in 10 minutes - it generally requires a bit of practice and patience, so there's that. Your version looks like the 5 attempt - too impatient.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Tue Feb 02, 2021 8:02 pm

@Thorsten, I agree with what you've said. Of course the paint brush tool is used to paint in Gimp or Photoshop or some other program. I will try to find another way of getting the information I'm looking for. Have a good day!
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby danielHL » Tue Feb 02, 2021 8:41 pm

I hope you can find the answers you are looking for. I'm also hoping for more brightly lit cities in FG in the future :) So keep up and try to learn, texture development is always highly welcome. Maybe you have a look at the mailing list archives. If I recall there were a few threads in the last year from people who improved grass textures and and general color issues of a lot of textures.

Maybe you contact them directly, might be more efficient for you - but for the project it may be better to document it in the forum or on the mailing list. Anyway, you will still need to tell what you have done and what part in particular isn't working or you need help with. My advice would be to first identify the correct pair of texture files and xml for a region and make sure you can in fact make any visible change to them by painting. Then try your way up to the lighting layers...
danielHL / D-FMPW
danielHL
 
Posts: 280
Joined: Fri May 02, 2014 7:23 pm
Callsign: D-FMPW
Version: next
OS: Linux

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby Johan G » Tue Feb 02, 2021 11:30 pm

danielHL wrote in Tue Feb 02, 2021 8:41 pm:[...] for the project it may be better to document it in the forum or on the mailing list.

Or better yet, the wiki. :wink:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Tue Feb 02, 2021 11:50 pm

Good ideas. I'll be happy to write a "How To" wiki if I ever figure it out and no one else beats me to it (or already knows how and would like to do it).
I'm not new to texturing, I have a working texture set for Nova Scotia-Prince Edward Island-New Brunswick. It would be nice to add lighting. I found a discussion of a relief-light which I'll look into further as time permits.
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby montagdude » Wed Feb 03, 2021 2:59 pm

So, I think there are two issues here. One is the night lighting, which AFAIK is literally done by just brushing that bluish purplish color on the texture. Normally you just color over the streets, as that's where the street lamps would be. Are you saying that you tried this, but you didn't see any illumination when you tested it in FlightGear?

The second part is the relief map, which is what the transparency with red/green edges is for. That is for getting the urban shader to make the buildings stick up out of the texture. That's the harder part to get right, but then on the other hand, I think most people prefer random buildings or osm2city buildings over the urban shader anyway, so it's not as important. I have had some success getting this to work in Gimp, though my results haven't been as good as the examples included in FG. Here are some notes I have in a README that I wrote for myself. If someone can offer improvements, feel free:

To create the relief-light map:

  • Color in the streets in the light blue color. This color tells FlightGear what should be lit at night.
  • Create a layer that is just the greenish color
  • Bring in the town image as a layer, select and remove houses using Select By Color tool with feather edges on (radius 10) and a threshold of 40.
  • Remove the selection on the greenish layer. This should give an alpha map corresponding to height for the urban shader.
  • Desaturate the town layer and do a normal map on it. Choose the x and y channels to get a bright green color as the result. Do color to alpha with that green color as the input.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Fri Feb 05, 2021 7:06 pm

Thank you, @montagdude! Your comments and notes clear up what a relief-light.png is and provides information about creating one.

I still haven't been able to get anything illuminated by just painting on the texture itself. I am now trying to create a working relief-light file that includes the painting to illuminate parts of the image. One possible problem is that I am only now getting familiar with Gimp. I have used Photoshop in the past, so am much more familiar with it when working with graphics. If I can't figure things out, I will try to detail what I've done and perhaps someone can tell me where I've gone wrong.
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby montagdude » Sat Feb 06, 2021 6:32 pm

Well, I didn't mean you're supposed to paint on the same file. You make a separate copy, usually lower resolution. You can bring in the original texture as a background layer, paint over that, and then hide the background layer before exporting it as the relief-light file. And of course, you need to copy the textures over to fgdata and reference them in the relevant materials.xml or regions.xml file.
montagdude
 
Posts: 266
Joined: Tue Dec 31, 2019 7:04 am

Re: Night lighting on an Urban/Suburban/Town etc texture

Postby pb321 » Wed Feb 10, 2021 4:19 pm

Thanks, @montagdude!. I tried painting on the image even though that didn't seem right. I will get back to this soon and try again.
What background should be used on the layer to be painted? Is "color to alpha" still used when not bothering with the "relief" of the "relief-light.png" part of the procedure?
pb321
 
Posts: 424
Joined: Sun Nov 27, 2016 5:08 pm
Version: 2020.4.0
OS: Windows 10 Pro


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 6 guests