Board index FlightGear Development Effects and shaders

Effects and canvas (interior vs. interior-display)

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

Effects and canvas (interior vs. interior-display)

Postby Necolatis » Thu Mar 14, 2019 4:28 pm

When I use interior effect on a canvas it looks as it should, well except not so pretty as display effect.

But when I use display effect on the same canvas, the canvas blending does not work.

I use something like this in the canvas:

Code: Select all
svg.holeMask = svg.p_HSD.createChild("image")
                .setTranslation(0,0)
                .set("z-index",10000)
                .set("blend-source","zero")
                .set("blend-destination-rgb","one")
                .set("blend-destination-alpha","one-minus-src-alpha")
                .set("src", "sit-mask.png");


The png is just a white texture, with some areas being transparent. The white areas will hide what have a lower z-index in the same group.

I have looked and experimented with the effect for display and I cannot find what should cause this.

As seen from the fragment shader, the canvas should just be a Texture2D lookup, so I don't get how the effect can mess with the internal canvas blending. Especially since the other effect does not do it.

Note: Posted this also to mailing-list, but got no reply yet.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1918
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.1
OS: Windows 10

Re: Effects and canvas (interior vs. interior-display)

Postby Thorsten » Thu Mar 14, 2019 5:45 pm

As seen from the fragment shader, the canvas should just be a Texture2D lookup, so I don't get how the effect can mess with the internal canvas blending.


Probably it's just not, probably a canvas isn't actually pre-rendered when it contains pipeline instructions, but the pipeline instructions are being passed down the line and overridden by the effect declaration.
Thorsten
 
Posts: 10693
Joined: Mon Nov 02, 2009 8:33 am

Re: Effects and canvas (interior vs. interior-display)

Postby Necolatis » Thu Mar 14, 2019 8:56 pm

Thorsten wrote in Thu Mar 14, 2019 5:45 pm:Probably it's just not, probably a canvas isn't actually pre-rendered when it contains pipeline instructions, but the pipeline instructions are being passed down the line and overridden by the effect declaration.


Okay, that makes sense, but then I don't get why interior effect works, it also just reads the canvas color via a Texture2D. Hmm, strange. Maybe its in how the effect is declared, but I tried tons of stuff to get it to work and failed.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1918
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.1
OS: Windows 10

Re: Effects and canvas (interior vs. interior-display)

Postby Thorsten » Fri Mar 15, 2019 6:12 am

The interior effect doesn't have any alpha operations in the shader code, the display effect has. Explicit alpha operations in the shader code are always treated differently by the GPU.

Another example is that a surface needs transparency before entering the fragment shader, one can not make a solid surface transparent inside the fragment shader, but if the transparency is 0.99 before, all works fine.

So there's some kind of flags for alpha ops which need to be set right.
Thorsten
 
Posts: 10693
Joined: Mon Nov 02, 2009 8:33 am

Re: Effects and canvas (interior vs. interior-display)

Postby Necolatis » Fri Mar 15, 2019 10:34 am

Well blending works fine in your HUD effect, and I tried setting gl_FragColor alpha to 1 in the display effect to no avail.

As for flags I have tried many combinations of these flags which did not help:

<rendering-hint>
<depth>
<alpha-test>
<blend>
<transparent>
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1918
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.1
OS: Windows 10

Re: Effects and canvas (interior vs. interior-display)

Postby Thorsten » Fri Mar 15, 2019 10:55 am

Then we're down to 'I don't have a clue either'.
Thorsten
 
Posts: 10693
Joined: Mon Nov 02, 2009 8:33 am

Re: Effects and canvas (interior vs. interior-display)

Postby Necolatis » Fri Mar 15, 2019 11:25 am

Holy crap, I figured it out.

You were right about alpha operations.

The thing is to not touch them. So

This will fail:
Code: Select all
fragColor.rgb = filter_combined(fragColor.rgb);

       gl_FragColor = vec4(fragColor.rgb,1.0);


This will work: (assuming nothing has been done on the alpha of fragColor, except maybe reading a Texture2D)
Code: Select all
fragColor.rgb = filter_combined(fragColor.rgb);

       gl_FragColor = fragColor;
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1918
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.1
OS: Windows 10

Re: Effects and canvas (interior vs. interior-display)

Postby Thorsten » Fri Mar 15, 2019 12:00 pm

I suspect the question is, can we get the fragment shader to do the alpha ops you want while it is at it?
Thorsten
 
Posts: 10693
Joined: Mon Nov 02, 2009 8:33 am


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests