osSetPenColor as documented allows us to set pen color by a hexadecimal value that includes a two character value for the transparency preceding the six digit hex color value. So 00 = transparent and FF = opaque, such that 00000000 is transparent black and FF000000 is opaque black. However this not the result inworld. The following script code:
string CommandList = ""; // Storage for our drawing commands
CommandList = osSetPenSize( CommandList, 1 ); // Set the pen width to 3 pixels
CommandList = osSetPenColor( CommandList, "00000000" ); // Set the pen color to transparent black
CommandList = osMovePen( CommandList, 0, 0 ); // Upper left corner at <28,78>
CommandList = osDrawFilledRectangle( CommandList, 256, 256 ); // 256x256 pixels
CommandList = osMovePen( CommandList,10,15);
CommandList = osSetPenColor(CommandList, "Red");
CommandList = osSetFontName(CommandList, "Impact");
CommandList = osSetFontSize(CommandList,80);
CommandList = osDrawText(CommandList,SLTclock);
CommandList = osMovePen(CommandList,15,140);
CommandList = osSetFontSize(CommandList,45);
CommandList = osDrawText(CommandList,"GRIDTIME");
// Now draw the rectangle
osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256",FALSE, 2, 0, 255, 0);
Results in an opaque background to the dynamic texture as seen here on the left compared to the one on the right that has a black background that is opaque.
Bug report: Dynamic Texture bug
- Mike Lorrey
- Posts: 368
- Joined: Sun Sep 04, 2016 5:40 pm
- Has thanked: 74 times
- Been thanked: 276 times
Bug report: Dynamic Texture bug
Last edited by Mike Lorrey on Sun Jan 27, 2019 9:57 pm, edited 1 time in total.
- Mike Lorrey
- Posts: 368
- Joined: Sun Sep 04, 2016 5:40 pm
- Has thanked: 74 times
- Been thanked: 276 times
- Mike Lorrey
- Posts: 368
- Joined: Sun Sep 04, 2016 5:40 pm
- Has thanked: 74 times
- Been thanked: 276 times
Re: Bug report: Dynamic Texture bug
ok found a solution. There's two bugs in the dynamic texture functions wrt alphas. Firstly, they won't do complete transparency, you have to have a value of at least 01 for the functions to execute properly.
Secondly, in addition to specifying the alpha in the osSetPenColor function,
in the osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256",FALSE, 2, 0, 255, 0);
you need to add an alpha spec to the dimensions modifiers, so "width:256,height:256,alpha:01"
Unfortunately, the opensim wiki is not well written and does not mention either of these caveats. There have been some mantis issues that have better explained why you need both alpha specs in the two separate functions.
Secondly, in addition to specifying the alpha in the osSetPenColor function,
in the osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256",FALSE, 2, 0, 255, 0);
you need to add an alpha spec to the dimensions modifiers, so "width:256,height:256,alpha:01"
Unfortunately, the opensim wiki is not well written and does not mention either of these caveats. There have been some mantis issues that have better explained why you need both alpha specs in the two separate functions.
- These users thanked the author Mike Lorrey for the post (total 2):
- Ilan Tochner • Sue Caxton
- John Mela
- Posts: 91
- Joined: Tue Feb 04, 2014 9:50 pm
- Has thanked: 139 times
- Been thanked: 127 times
- Contact:
Re: Bug report: Dynamic Texture bug
Mike, you have 255 for the alpha parameter in osSetDynamicTextureDataBlendFace. Our existing code (which works fine) uses 0 for that parameter, and "alpha:0" in extraParams.
- Mike Lorrey
- Posts: 368
- Joined: Sun Sep 04, 2016 5:40 pm
- Has thanked: 74 times
- Been thanked: 276 times
Re: Bug report: Dynamic Texture bug
Hi John, I already tried making that parameter 00, and, like setting zero on osPenColor alpha, and in the extraParams, it makes the function break. Unless you have 01 in the pen color alpha and 01 in the extraparams, or higher, you won't get any alpha. Zero value breaks the function, at least here in Kitely. I don't need to make the alpha parameter in osSDTDBF anything for this to work right, so its clear that this function is broken several ways.John Hopkin wrote: ↑Mon Jan 28, 2019 3:22 pmMike, you have 255 for the alpha parameter in osSetDynamicTextureDataBlendFace. Our existing code (which works fine) uses 0 for that parameter, and "alpha:0" in extraParams.
- John Mela
- Posts: 91
- Joined: Tue Feb 04, 2014 9:50 pm
- Has thanked: 139 times
- Been thanked: 127 times
- Contact:
Re: Bug report: Dynamic Texture bug
Have you tried using 0 instead of 255 for the alpha parameter in the function call (the penultimate parameter, before face)?
Here's the call I've been using - extraparams contains "alpha:0" (not "00", if that makes a difference):
This works fine in Kitely and in vanilla OpenSim 0.8.
Here's the call I've been using - extraparams contains "alpha:0" (not "00", if that makes a difference):
Code: Select all
osSetDynamicTextureDataBlendFace("", "vector", commands, extraparams, FALSE, 2, 0, 0, face);
- John Mela
- Posts: 91
- Joined: Tue Feb 04, 2014 9:50 pm
- Has thanked: 139 times
- Been thanked: 127 times
- Contact:
Re: Bug report: Dynamic Texture bug
Something else I noticed that's different between your and my code - I'm using 00FFFFFF for the background pen colour. That might be worth a try if the 0 alpha parameter doesn't help.