Board index FlightGear Development Effects and shaders

Glass

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

Re: Glass

Postby wlbragg » Thu Apr 20, 2017 9:12 pm

Does anyone have a working example of a "fog" mask as might be used if you had heater vents blowing on a windshield?

I have tried to make this work on several different occasions and it simply won't work for me.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Necolatis » Fri Apr 21, 2017 12:10 am

It works for me. Look in the JA37 in FGAddon.
But notice it wont remove frost, only fog.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2032
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Glass

Postby wlbragg » Fri Apr 21, 2017 5:32 pm

I had a few issues that I know about.

First, I need to emphasize this information is coming from a complete novice in understanding of Blender texturing and texturing in general.

The layout of the glass layers and their settings obviously affect the truths of the following statements.
However, the following actions lead to a successful outcome in my case.
Unlike the JA37 glass which was the outside glass layer and had the normals pointing inward, the J3Cub glass object required being double sided and the normals pointing outward. It was also the inside glass layer.

The glass object needed to be uv mapped. This is where I don't have a complete grasp of the technology I am trying to manipulate.
UV mapping not only required the act of creating the map but also assigning a texture to it. I used the 1X1 pixel alpha files glass-alpha.png from the JA37.

The JA37 used the Face Textures and Face Textures Alpha check boxes on the "material's" tab. That wasn't required on the J3 and must be unrelated?

The shader doesn't consider the alpha channel as being a non-red color. I imagine this is my complete lack of understanding of the ins and outs of an image and the shaders use of it. As soon as I changed the non colored areas by use of the alpha channel to black instead, I started seeing results.

This is the results..

Image

Image

And the mask
Image

@Necolatis, thank you for the help!
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Richard » Fri Apr 21, 2017 11:16 pm

wlbragg wrote in Fri Apr 21, 2017 5:32 pm:The layout of the glass layers and their settings obviously affect the truths of the following statements.


I've got an inside glass and an outside glass as two objects; with opposite normal. If you do 2sided you'll see the inside reflection on the outside.

With blender the glass is the same as any other texture UV mapped surface, you need to assign the material, set the uv map, and assign a transparent texture (can be a 1x1), but the UV map needs to be valid and match the overlay that you pass to the shader. I temporarily set the UV map to the actual shader texture, aligned it, and finally set it back to my tranbg.png

If you don't assign a transparent texture it can interfere with the shader.
Richard
 
Posts: 727
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Glass

Postby wlbragg » Sat Apr 22, 2017 4:50 am

I've got an inside glass and an outside glass as two objects; with opposite normal. If you do 2sided you'll see the inside reflection on the outside.


The Cub has an inside glass and an outside glass as two objects with "the same" normal.
The inside glass inherits "glass", is two sided, normals pointing outward, has the frost and fog and interior reflection assigned to it.
The outside glass inherits "model-combined-transparent", is single sided, normals pointing outward.

I guess I need to figure out how to get the interior to work single sided and with the normals inward.

Thanks Richard!
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Thorsten » Sat Apr 22, 2017 5:36 am

The shader doesn't consider the alpha channel as being a non-red color. I imagine this is my complete lack of understanding of the ins and outs of an image and the shaders use of it.


Forget the colors you can see, for the shader a texture is just a table. You input lookup coordinates (s,t), and it outputs four numbers, (r,g,b,a).

If you have a red texture, it has the values (1,0,0,1). If you use the eraser tool on it to create an alpha channel, it becomes (1,0,0,0) - since the shader reads the red channel (first number), you haven't changed anything. If you change the color to black instead, you change this to (0,0,0,1), and now the first number is different.

Changing the alpha channel might fiddle with the color you can see, but it does not change the first three numbers (ideally - the graphics program might zero the other channels as well for zero alpha, in which case you have an encoding problem).
Thorsten
 
Posts: 11203
Joined: Mon Nov 02, 2009 8:33 am

Re: Glass

Postby wlbragg » Sat Apr 22, 2017 6:37 am

Thanks for the explanation Thorsten, that make total sense.


But notice it wont remove frost, only fog.

@Necolatis, I guess the idea is for "custom" frost we can use the overlay "blue" channel.
the primary function is to render damage on the glass, but with a different color, also dirt or an alternative more finely controlled frost pattern can be used.


I'm using it for a heat vent that also affects frost.

Image

Image
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby wlbragg » Sat Apr 22, 2017 7:30 pm

OK, another problem.

I'm using the "overlay" for frost so I can control its image. But it uses the same effects framework as the generic frost and fog which I need for the fogging. So if I inherit glass and use /environment/aircraft-effects/frost-level for other effect inheritances I get the default frost along with "overlay" frost that I want.

Ideally I want to control the "overlay with the following
/environment/aircraft-effects/overlay-alpha = /environment/aircraft-effects/frost-level

then I only need a way to turn off the default frost in this effect file definition and inheritance.

I thought maybe using
Code: Select all
 <texture n="1">
      <image>Aircraft/J3Cub/Models/glass-alpha.png</image>
      <type>2d</type>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <internal-format>normalized</internal-format>
   </texture>

where glass-alpha is a transparent image, that it wouldn't have any frost image to render in this effect definition.

So the entire definition would look something like this
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
  <name>interior-glass-reflection-front</name>
  <inherits-from>Effects/glass</inherits-from>
  <parameters>
    <texture n="1">
            <image>Aircraft/J3Cub/Models/glass-alpha.png</image>
       <type>2d</type>
       <filter>linear-mipmap-linear</filter>
       <wrap-s>repeat</wrap-s>
            <wrap-t>repeat</wrap-t>
       <internal-format>normalized</internal-format>
    </texture>
    <texture n="2">
       <image>Aircraft/J3Cub/Models/Effects/interior/windshield.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>
    <use-mask type="int">1</use-mask>
    <overlay-color type="vec3d" n="0">1.0 1.0 1.0</overlay-color>
  </parameters>
</PropertyList>

But this still is rendering the default frost. Is there an easy way to disable the default frost but not the fog?
Last edited by wlbragg on Sun Apr 23, 2017 3:16 am, edited 3 times in total.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby wlbragg » Sat Apr 22, 2017 7:43 pm

Hum, I just started the sim to continue work on this and now it suddenly appears to be working. In case I am missing something, should the above configuration work?

Other than needing to match the frost graphics a bit better with the original, it appears to be working as I expected.
Image
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Thorsten » Sun Apr 23, 2017 5:16 am

So if I inherit glass and use /environment/aircraft-effects/frost-level for other effect inheritances I get the default frost along with "overlay" frost that I want.


I'm not sure I'm understanding the problem but just in case.

The original effect contains the line

Code: Select all
<frost-level><use>/environment/aircraft-effects/frost-level</use></frost-level>


In a derived effect, you can re-define this assignment (like any other parameter) in the <parameters> section in any way you like. For instance

Code: Select all
<frost-level>0</frost-level>


is going to permanently disable frosting for the particular derived effect whereas

Code: Select all
<frost-level><use>/systems/environment/frost-level</use></frost-level>


is going to use a parameter created by your own systems simulation for it. So you can at every level of inheritance control each parameter. The defaults assigned by the effect are just a convenient convention, a suggestion for you to use, but you're i no way bound by them.
Thorsten
 
Posts: 11203
Joined: Mon Nov 02, 2009 8:33 am

Re: Glass

Postby wlbragg » Sun Apr 23, 2017 6:00 am

Thanks for the reply Thorsten. OK I think I am stuck at <frost-level></frost-level> if "true" at all, or max of 1 will create "generic" frost for any object with a glass inheritance regardless of what parameter feeds it, right?

So, I have a side window object "side-window" that has its separate definition inheriting glass and it generates generic frost by <frost-level></frost-level> being fed a value.

Now I have the forward windshield object "interior-screen" that also has its own definition inheriting glass and uses an overlay mask for fog (red channel) and a "custom" (blue channel) for frost. I don't want the generic frost. I need the custom frost so I can also model heater vents on the frost.

Because I turn on <frost-level></frost-level> anywhere via nasal or in the effect definition itself, it gives me "generic" frost on the "interior-screen" object or any object that inherits glass, right?

So I thought a quick way to turn off the "generic frost" for the "interior-screen" object is to include a texture n="1", and overload the "generic" frost.png with a transparent.png. Then I can use whatever property I want to feed the "interior-screen" object's custom frost using <alpha-value>. I hope this makes sense.

Unfortunately at the moment I am regressing miserably. What was working earlier suddenly stopped and now I'm not even getting interior reflections. I'm baffled as to what I did to cause this regression but I am sure I will, in time, figure it out. So frustrating to have something working and suddenly, NOT!

So until I get back to where I was I guess it is all somewhat of a moot point.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Thorsten » Sun Apr 23, 2017 8:15 am

Because I turn on <frost-level></frost-level> anywhere via nasal or in the effect definition itself, it gives me "generic" frost on the "interior-screen" object or any object that inherits glass, right?


Yes, so in the derived effect where you don't want it, you just turn it off via

Code: Select all
<frost-level>0</frost-level>


and it will affect all other effects but this one. Then you want to use the overlay instead, so you add

Code: Select all
<overlay-alpha><use>/environment/aircraft-effects/frost-level</use></overlay-alpha>


and the frost level will control the strength of the overlay texture here, but the strength of the frosting everywhere else. There's no need to override the texture.
Thorsten
 
Posts: 11203
Joined: Mon Nov 02, 2009 8:33 am

Re: Glass

Postby wlbragg » Sun Apr 23, 2017 8:42 am

Gees, OK, simple!

Beat me over the head a few times and I might just get it. :oops:
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby wlbragg » Sun Apr 23, 2017 3:16 pm

I noticed that in the JA37 glassInternal is a "single sided", non uv-map, interior sheet of glass in the model, outward facing normals, with exterior reflection effect applied.
The glassOuter is a "single sided", uv-mapped, exterior sheet of glass in the model, inward facing normals, with fog and frost effect applied.

Does anyone have a comment as to why the physical glass objects are arranged this way, with the glassOuter actually being the "interior" piece of glass? Does it matter which object gets the inside or outside position?

Any idea as to why applying the transparent.png as the uv-map that I loose the "interior" glass reflections?

I'm temporarily moving the physical glass layers to be arranged like the JA37 does it (what in my mind is backwards) and testing it to see if I get the reflections back like that. Every thing I think I know tells me it shouldn't make any difference?

EDIT:

As I figured, the objects physical position isn't the issue.

So my only issue is I loose the "interior" glass reflections if I apply a transparent uvmap texture to the that object?
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 4989
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: Glass

Postby Necolatis » Sun Apr 23, 2017 3:52 pm

The JA37 glass layers is named opposite, just was too lazy to change it. glassOuter is the glass the pilot sees, glassInternal is the glass as seen from outside. They are both in 3D placed on top of each other.

I think if you place a transparent texture on the glass that should be seen from outside, then you wont get any reflections. So I think its best it has no texture.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2032
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

PreviousNext

Return to Effects and shaders

Who is online

Users browsing this forum: MSN [Bot] and 2 guests