General Question Sketchpad on transparent screen

Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
Dear Developer Community,

I tried the following design for some days already but I can't find a solution. I have designed a screen with transparent glass as a Texture. For test purpose I put some text in this texture with alpha (100%). After creating the .msh file with blender I can see the screen correctly in my vessel. transparent glass with opaque text in the screen.

Now I would like to use the Sketchpad on this texture. If I paint anything (for example a Line) through the screen with a 100% alpha channel brush/pen I get only the line at the places where the Text in the original texture appears. On the rest of the transparent screen I can't paint and can't place a text. Is there any solution for that issue?

I also tried to Blt a new texture on the screen, but that also didn't work.

Does anyone of you have a suggestion or solution?

In the image you can see my transparent screen in front of a reactor. The text "Test Text" is 100%alpha channel in the texture and the rest of the texture transparent (0%alpha). When I draw with the sketchpad a line (in red) from position 0,0, to 100,100 the line in red is only through the text in the image.
This is logical because in the texture the alphachannel is only 100% where the text exists. I have no idea how I could come further.

Maybe anyone has a different approach for that.

Best regards
Jason

transscreen.JPG
 
Last edited:
Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
One other idea was not to use a texture. By using just transparent material I don't know how to paint on a material because I need a SURFACEHANDLE to use it with the skretchpad
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,877
Reaction score
2,131
Points
203
Location
between the planets
If I paint anything (for example a Line) through the screen with a 100% alpha channel brush/pen I get only the line at the places where the Text in the original texture appears.
That's because you're not painting to the actual alpha channel of the texture, so even though sketchpad paints something on the texture, the place stays transparent. Can sketchpad paint to the alpha channel? Honestly, I don't know. It's definitely not what it's been designed to do. What you could try is to paint to another texture, and then blit the result over to the transparent one. I'm not at all sure Orbiter supports a transparency key for blitting, though, and you'd probably carry the alpha channel for the entire rectangle over. Hmmm, this is a tricky one.
It has to be possible, though. Huds do that, so it should be applicable to other situations. I think your best bet is to take a look at the deltaglider source code and see how the HUD drawing there works (for the virtual cockpit, not the 2D panel).
 
Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
Hi jedidia,

That's because you're not painting to the actual alpha channel of the texture, so even though sketchpad paints something on the texture, the place stays transparent
That's the point I didn't understand correctly. Thanks for clarifying. Now it's clear, why I cant paint on a transparent texture.
Can sketchpad paint to the alpha channel?
Yes it can. I tried it several times. If the texture is not transparent (not my case) you can paint e.g. half transparent lines / recs ...

What you could try is to paint to another texture, and then blit the result over to the transparent one.
I also tried that already. With no success. But:
and you'd probably carry the alpha channel for the entire rectangle over. Hmmm, this is a tricky one.
Thats a good point I will try.

Thanks for the suggestions

Jason
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,877
Reaction score
2,131
Points
203
Location
between the planets
Yes it can. I tried it several times. If the texture is not transparent (not my case) you can paint e.g. half transparent lines / recs ...
Half transparent as in the texture is visible through the line, or the texture actually becomes transparent in the places you painted over? Because the first merely means that the sketchpads alpha is considered when blending its output with the texture, not that it is modifying the original textures Alpha-channel (which is what you would need).

As I said, it's probably best to have a look at the delta-glider source code. They're doing it somehow, so it has to be possible.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,666
Reaction score
795
Points
128
You can change the blend mode by using Sketchpad::SetBlendState() API function. The "COPY" should work in your case.

C++:
enum BlendState {
ALPHABLEND = 0x1,                ///< AlphaBlend source.color to destination.color, will retain destination alpha unchanged (if exists).
COPY = 0x2,                        ///< Copy source color and alpha to destination
COPY_ALPHA = 0x3,                ///< Copy source.alpha to destination.alpha, will retain destination color unchanged
COPY_COLOR = 0x4,                ///< Copy source.color to destination.color, will retain destination alpha unchanged
FILTER_LINEAR = 0x00,            ///< Use "linear" filter in CopyRect and similar functions
FILTER_POINT = 0x10,            ///< Use "point" filter in CopyRect and similar functions
FILTER_ANISOTROPIC = 0x20
};
 
Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
Hi jedidia:
Half transparent as in the texture is visible through the line, or the texture actually becomes transparent in the places you painted over? Because the first merely means that the sketchpads alpha is considered when blending its output with the texture, not that it is modifying the original textures Alpha-channel (which is what you would need).

For example. If the original texture is 100% opaque then I could define a color with alpha channel (e.g. 50%). Now if I paint the line over the texture it is 50% transparent as defined in the alpha channel. So the sketchpad merges both, the new color with the alpha channel in the original texture, so I belief.
Other example: the original texture is 50% transparent and the new defined color is also 50% transparent (e.g. red). Then it is shown with 25% transparency. And if the original texture is 100% transparent (0% alpha) then I cant paint over it. If I understood correctly, the alpha channel in the original texure stays unchanged.

But all this alpha channels work only with the D3D9 client. With the standard oribter built in graphics I couldn't get transparent textures.
 
Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
You can change the blend mode by using Sketchpad::SetBlendState() API function. The "COPY" should work in your case.

C++:
enum BlendState {
ALPHABLEND = 0x1,                ///< AlphaBlend source.color to destination.color, will retain destination alpha unchanged (if exists).
COPY = 0x2,                        ///< Copy source color and alpha to destination
COPY_ALPHA = 0x3,                ///< Copy source.alpha to destination.alpha, will retain destination color unchanged
COPY_COLOR = 0x4,                ///< Copy source.color to destination.color, will retain destination alpha unchanged
FILTER_LINEAR = 0x00,            ///< Use "linear" filter in CopyRect and similar functions
FILTER_POINT = 0x10,            ///< Use "point" filter in CopyRect and similar functions
FILTER_ANISOTROPIC = 0x20
};
Hi jarmonik:

thank you for this FANTASTIC solution. But SetBlendState() is not an orbiter sketchpad API function.

If I use oapi::Sketchpad:: ... the SetBlendState() is not available. If I define a oapi::Sketchpad *skp and use it with skp->... the SetBlendState is also not available. Do I need to use the Win32 or DX11 features?

Jason
 
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,666
Reaction score
795
Points
128
It's recommended to use Open Orbiter for development https://github.com/orbitersim/orbiter/releases/tag/latest Note: x64 is NOT supported yet, even if the package exists.
Also the feature only works with D3D9Client enabled. If you want to use Orbiter 2016 then you can include Sketchpad2.h and cast the Sketchpad pointer to Sketchpad3* pSkp3 = (Sketchpad3*)pSkp; This step is not required in Open Orbiter.
 
Joined
Feb 11, 2012
Messages
11
Reaction score
3
Points
18
Location
on Earth
It's recommended to use Open Orbiter for development https://github.com/orbitersim/orbiter/releases/tag/latest Note: x64 is NOT supported yet, even if the package exists.
Also the feature only works with D3D9Client enabled. If you want to use Orbiter 2016 then you can include Sketchpad2.h and cast the Sketchpad pointer to Sketchpad3* pSkp3 = (Sketchpad3*)pSkp; This step is not required in Open Orbiter.
Thanks Jarmonik for all your help. I will check this out the next days.
 
Top