Board index FlightGear Development Effects and shaders

Shaders specular spot

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

Shaders specular spot

Postby Necolatis » Sat Dec 10, 2016 3:19 pm

The combined shader in ALS acts in a way I don't understand, the lightning applied seems to depend on camera angle:

Here is first without ALS shots, notice how the lightning remains constant on the frontpanel when camera view angle is changed:

Image
Image

Here is the ALS shots, notice how the lightning changes quite significant when moving the camera view angle: (ALS secondary lights is all off)

Image
Image

FG was paused when taking these shots.

FG 2016.4.3, win 10 64 bit. GeForce 550 Ti
Last edited by Necolatis on Sun Dec 11, 2016 6:20 pm, edited 2 times in total.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: ALS shader bug

Postby Thorsten » Sat Dec 10, 2016 4:38 pm

The combined shader in ALS has a big bug, the lightning applied seems to depend on camera angle:


Specular lighting actually does depend on camera angle - so I fail to see why this is a bug of ALS.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS shader bug

Postby Necolatis » Sat Dec 10, 2016 7:38 pm

Sorry for continue this, but why is that?

Is it because ALS considers the near clipping plane geometry, where non-ALS consider the view as a eye location point only?

Because if you consider the view as a point only, the specular rays that hit the view from a certain direction (from certain point on some geometry) would not change when the view angle changes. I also just did a test with my real eyes, looked at a specular spot 0.5 meters away directly, then looked 20cm to the left, and the spot didn't move (without moving my head).

Its also not a minor effect, goes from what looks like 0.5 grey to 0.1 just by changing camera view for 30 degrees. (look at the panel just above the radar)

In Blender for example (using Phong) it looks like this when turning the view, notice that the spot don't change position on the cube. I also tried to adjust the near-clipping distance and it made no effect:

Image
Image

Btw. is there any way in FG to change the near clipping plane distance?
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: ALS shader bug

Postby Thorsten » Sun Dec 11, 2016 8:13 am

The default terrain and model shaders (in both classic and ALS) use a 'mean' half vector (which is based on something like the normal of the projection plane I guess). All the high quality shaders use the exact half vector for each pixel. Since the half vector uses the vector from eye to pixel for the computation, the result is dependent on eye position (and hence view angle) for any reflection phenomenon.

This is model-combined.eff on Heiko's recent C-182 under two different angles at noon:

Image

Image

You can see nicely how the location of the specular highlights moves as the reflection condition is fulfilled for different pixels on the fuselage (if you were to look from underneath, you could equally see how the reflection of the ground moves as different parts of the environment map are hit when you move the camera). You can also see how the bluish sky-light reflection in the canopy does not change that much - because unlike the sun, the sky is a rather broad area emitter.

So as far as the shader code is concerned, model-combined does exactly what it should do over here.

Which would prompt the question whether you're actually running the effect you think you do....
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS shader bug

Postby Necolatis » Sun Dec 11, 2016 10:44 am

Thorsten wrote in Sun Dec 11, 2016 8:13 am:Since the half vector uses the vector from eye to pixel for the computation


Yes, and in my example in the cockpit that angle doesn't change, since I am only rotating the view, not positioning it. And the sim was paused so sun and aircraft positions didn't change either.
Same in the blender pictures I posted, only rotated the view, and so the specular spot did not move on the cube (it moved on the screen ofc.)

Thorsten wrote in Sun Dec 11, 2016 8:13 am:Which would prompt the question whether you're actually running the effect you think you do....


Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
  <name>Aircraft/JA37/Models/Effects/ja37-cockpit-shader</name>
  <inherits-from>Effects/model-combined-deferred</inherits-from>
  <parameters>
    <rain-enabled type="int">0</rain-enabled>
    <ambient-correction type="float">0.0</ambient-correction>
    <normalmap-enabled type="int">0</normalmap-enabled>

    <lightmap-enabled type="int">1</lightmap-enabled>
    <lightmap-factor type="float" n="0"><use>/controls/lighting/flood-norm</use></lightmap-factor>

    <reflection-enabled type="int">0</reflection-enabled>
    <reflect-map-enabled type="int">0</reflect-map-enabled>
    <reflection-correction type="float">-0.25</reflection-correction>
    <reflection-fresnel type="float">0.0</reflection-fresnel>
    <reflection-rainbow type="float">0.0</reflection-rainbow>
    <reflection-noise type="float">0.0</reflection-noise>
    <reflection-dynamic type="int">0</reflection-dynamic>

    <dirt-enabled type="int">0</dirt-enabled>
    <dirt-factor type="float">0.0</dirt-factor>
    <dirt-color type="vec3d">0.0 0.0 0.0</dirt-color>

    <!-- light map -->
    <texture n="3">
        <type>white</type>
    </texture>
  </parameters>
 
</PropertyList>


Did I do something wrong?
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: ALS shader bug

Postby Thorsten » Sun Dec 11, 2016 11:12 am

Yes, and in my example in the cockpit that angle doesn't change, since I am only rotating the view, not positioning it.


Ah... I guess that's a view axis change, not a view angle change - that's why I misunderstood.

Did I do something wrong?


Not sure - does the lightmap actually work? It might be down to a compilation error driven by some custom g-force filter changes as well. I guess time for you to sift through the log file :mrgreen:
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS shader bug

Postby Necolatis » Sun Dec 11, 2016 2:16 pm

Since I wrote to you that I think the g-force shaders are fine as you made them some days ago, I installed 2016.4.3 which I haven't messed with, and saw this issue on.

Yes, the lightmap works excellent, just tested it. :)

I did some more tests:

    The specular on the ALS water works fine, so at least something works on my system.

    Confirmed that filters was off.

    I found another place on the plane (curved area in front of HUD), to better test the spot on, and if I look directly towards the sun, the specular spot is correct. If I rotate some degrees to the left, the specular moves to the right on the mesh, and no longer is on line with the sun and camera, and vice versa. (can post screenies if you like)

    With log-level on warn I get no complaints.

I last did a test where I replaced the fuselage with 1 big single smooth face with normal upwards: (seems per pixel lightning also don't work for me, either that or minimum specular spot size (128) gives a very big spot)

Wireframe ALS:
Image

ALS:
Image

Non ALS:
Image

Non ALS:
Image

ALS:
Image

Notice I really had to adjust my view rotation precisely to get the specularspot to show in ALS. Even rotating the view a tiny bit, and the surface became dark.

I tried the 182S also, but everything was so curved it was hard to verify this proper. I did the big single face test on the Alphajet though and got same result.

Also tried with <inherits-from>Effects/model-combined-deferred</inherits-from> directly, same result.

I do not think the problem is in my view setup, as I did this in different views of the airplanes, including the default ones.

Any ideas where I could look to find this error? The install is 2016.4.3 without any changes.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: ALS shader bug

Postby Thorsten » Sun Dec 11, 2016 4:34 pm

Upon doing some forensics, it unfortunately turned out that the model shader did not use the real half-vector as I had thought (it's not originally my code, I just ported it to ALS). So it's not a bug as such, just a feature that was never implemented (as a side note, I really wish you could find a more polite way to start a thread than shouting 'BUG' in the title if you're seeing something you can't make sense of - it doesn't really put me into a particularly enthusiastic mood).

I've pushed a tentative computation borrowed from the terrain shader - looking at the C-182 it seems to do okay, but I haven't looked at every possibility. Please give it a test run.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS shader bug

Postby Necolatis » Sun Dec 11, 2016 6:16 pm

Sorry about that, sometimes I don't think much about how I word things.

Will try to be more polite. And thank you for looking into it.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Shaders specular spot

Postby Necolatis » Sun Dec 11, 2016 7:03 pm

Works perfectly! Thank you so much. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Shaders specular spot

Postby Thorsten » Sun Dec 11, 2016 7:24 pm

Well, thanks for doing the leg-work. It was an excellent series of tests on your side allowing to narrow this down quickly.

(I sort of wish the information typically given by others would be just half of that...)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests