secondlife / jira-archive

2 stars 0 forks source link

[BUG-8235] Normal and specular maps do not render when diffuse map has no alpha channel and PRIM_ALPHA_MODE_MASK is used #15854

Open sl-service-account opened 9 years ago

sl-service-account commented 9 years ago

Steps to Reproduce

I am on the official Viewer Second Life 3.7.24 (297623), but i can also reproduce the bug in Experience Beta Viewer 3.8.0.298001.

The bug does not happen in Second Life version 3.7.21.296876 or Second Life version 3.7.21.296858

Actual Behavior

Scripts that i had created to control Material maps via LSL llSetPrimitiveParams ' PRIM_NORMAL' & 'PRIM_SPECULAR' are failing to load the material mapping as they one did before christmas.

This has now broken a new feature i had placed in some clothes where from a menu you could choose a zipped or unzipped look.

I do not know if this is a mac only bug.

Expected Behavior

I have created a script to demonstrate the issue and hopefully gather support for the issue

integer click = 1;

string NRM;
string SPEC;

string HAPPYNRM ="90548b03-4e83-ae17-df59-2799dd3a9c7f";
string HAPPYSPEC = "3063f95f-734b-dd49-4f2c-6ec0ace16780";

string SADNRM ="5a1a7e9e-d622-73fb-50c5-c7bfc8467000";
string SADSPEC = "adf6f322-7a28-b9be-0bd3-e859ead65235";
default
{
    state_entry()
    {   
    NRM = HAPPYNRM;
    SPEC = HAPPYSPEC;
         llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);
         llSetPrimitiveParams([
         PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,
         PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
         PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);
          llSay(0, "Materials SET.");
    }

    touch_start(integer total_number)
    { 
          if (click == 1)
               {
                  NRM = HAPPYNRM;
                  SPEC = HAPPYSPEC;
                  llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);
                  llSetPrimitiveParams([
                  PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,
                  PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
                  PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);
                  llSay(0, "Materials HAPPY.");
                  click = 2;
                }
         else if(click == 2)
              {
                  NRM = SADNRM;
                  SPEC = HAPPYSPEC;
                  llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);
                  llSetPrimitiveParams([
                  PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,
                  PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
                  PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);
                  llSay(0, "Materials SAD.");
                  click = 1;
                 }
    }
}

Place script in white Prim cube. It should on state entry load a happy face, then when you click the cube the face will toggle between sad and happy.

Other information

Attachments

Links

Related

Original Jira Fields | Field | Value | | ------------- | ------------- | | Issue | BUG-8235 | | Summary | Normal and specular maps do not render when diffuse map has no alpha channel and PRIM_ALPHA_MODE_MASK is used | | Type | Bug | | Priority | Unset | | Status | Accepted | | Resolution | Accepted | | Reporter | Loki Eliot (loki.eliot) | | Created at | 2015-01-16T12:19:21Z | | Updated at | 2015-02-02T12:46:03Z | ``` { 'Business Unit': ['Platform'], 'Date of First Response': '2015-01-16T08:22:04.601-0600', 'Severity': 'Unset', 'System': 'SL Viewer', 'Target Viewer Version': 'viewer-development', 'What just happened?': "Scripts that i had created to control Material maps via LSL llSetPrimitiveParams ' PRIM_NORMAL' & 'PRIM_SPECULAR' are failing to load the material mapping as they one did before christmas. \r\n\r\nThis has now broken a new feature i had placed in some clothes where from a menu you could choose a zipped or unzipped look. \r\n\r\nI do not know if this is a mac only bug.", 'What were you doing when it happened?': 'I am on the official Viewer Second Life 3.7.24 (297623), but i can also reproduce the bug in Experience Beta Viewer 3.8.0.298001. \r\n\r\nThe bug does not happen in Second Life version 3.7.21.296876 or Second Life version 3.7.21.296858', 'What were you expecting to happen instead?': 'I have created a script to demonstrate the issue and hopefully gather support for the issue\r\n\r\ninteger click = 1;\r\n\r\nstring NRM;\r\nstring SPEC;\r\n\r\nstring HAPPYNRM ="90548b03-4e83-ae17-df59-2799dd3a9c7f";\r\nstring HAPPYSPEC = "3063f95f-734b-dd49-4f2c-6ec0ace16780";\r\n\r\nstring SADNRM ="5a1a7e9e-d622-73fb-50c5-c7bfc8467000";\r\nstring SADSPEC = "adf6f322-7a28-b9be-0bd3-e859ead65235";\r\ndefault\r\n{\r\n state_entry()\r\n { \r\n NRM = HAPPYNRM;\r\n SPEC = HAPPYSPEC;\r\n llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);\r\n llSetPrimitiveParams([\r\n PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,\r\n PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,\r\n PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);\r\n llSay(0, "Materials SET.");\r\n }\r\n\r\n touch_start(integer total_number)\r\n { \r\n if (click == 1)\r\n {\r\n NRM = HAPPYNRM;\r\n SPEC = HAPPYSPEC;\r\n llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);\r\n llSetPrimitiveParams([\r\n PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,\r\n PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,\r\n PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);\r\n llSay(0, "Materials HAPPY.");\r\n click = 2;\r\n }\r\n else if(click == 2)\r\n {\r\n NRM = SADNRM;\r\n SPEC = HAPPYSPEC;\r\n llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);\r\n llSetPrimitiveParams([\r\n PRIM_ALPHA_MODE, ALL_SIDES, PRIM_ALPHA_MODE_MASK, 100,\r\n PRIM_NORMAL,ALL_SIDES,NRM,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,\r\n PRIM_SPECULAR,ALL_SIDES,SPEC,<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, <0.498, 0.859, 1.000>, 20, 0]);\r\n llSay(0, "Materials SAD.");\r\n click = 1;\r\n }\r\n }\r\n}\r\n\r\nPlace script in white Prim cube. It should on state entry load a happy face, then when you click the cube the face will toggle between sad and happy. ', } ```
sl-service-account commented 9 years ago

Lucia Nightfire commented at 2015-01-16T14:22:05Z, updated at 2015-01-16T14:26:28Z

Did some testing with a mod version of Loki's script and found that unless an alpha texture was already applied to the prim, no change to alpha mode, normal or specularity is rendered even though other viewers such as Firestorm see the change. Taking the prim into inventory and rezzing doesn't show materials either. Manually changing a material will show that change though.

Heres the mod script I used:


Bi_Polar(integer i)
{
    llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
    llSetPrimitiveParams([PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,1.0,
        PRIM_ALPHA_MODE,ALL_SIDES,PRIM_ALPHA_MODE_MASK,100,
        PRIM_NORMAL,ALL_SIDES,llList2String([happy_normal,sad_normal],i),<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
        PRIM_SPECULAR,ALL_SIDES,llList2String([happy_spec,sad_spec],i),<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,<0.498,0.859,1.0>,20,0]);
    llOwnerSay(llList2String(["Happy","Sad"],i));
}
integer cycle;
string happy_normal ="90548b03-4e83-ae17-df59-2799dd3a9c7f";
string happy_spec = "3063f95f-734b-dd49-4f2c-6ec0ace16780";
string sad_normal = "5a1a7e9e-d622-73fb-50c5-c7bfc8467000";
string sad_spec = "adf6f322-7a28-b9be-0bd3-e859ead65235";
default
{
    state_entry()
    {
        Bi_Polar(cycle);
    }
    on_rez(integer i)
    {
        llResetScript();
    }
    touch_end(integer i)
    {
        if (llDetectedKey(0) == llGetOwner())
        {
            Bi_Polar(cycle = !cycle);
        }
    }
}

Tested with Second Life 3.8.0 (298001) Jan 12 2015 14:37:37 (Second Life Release)

sl-service-account commented 9 years ago

Ansariel Hiller commented at 2015-01-16T18:46:58Z, updated at 2015-01-16T19:04:42Z

Possible cause: http://hg.secondlife.com/viewer-release/commits/462c875eb97778ff145678d209440ffcf95446df

So questions:

  1. Is alpha blending mode for materials set?
  2. And if alpha blending mode is set, does the texture used for the normal or specular map have an alpha channel? Because if not (as in having only 3 channels), the recent change to the viewer will apparently do nothing. So if it has 3 channels, try to do it with a texture containing an alpha channel.
sl-service-account commented 9 years ago

Ansariel Hiller commented at 2015-01-16T19:27:21Z

I would even say this is intended behavior as in enforcing a constraint that would be done by the viewer if you set the materials using the build tools. See Maestro's comment in BUG-6187: "This bug is more of a problem with the upcoming LSL support for materials, as the sim has no knowledge of which textures contain an alpha channel, and cannot automatically update the diffuse alpha mode (as the viewer typically does)."

sl-service-account commented 9 years ago

Maestro Linden commented at 2015-01-27T00:08:12Z

I took a quick look at this with 'Second Life 3.7.24 (297623) Dec 19 2014 17:13:20 (Second Life Release)', and narrowed down the issue a bit. The issue seems that if the alpha mode is set to PRIM_ALPHA_MODE_MASK but no alpha channel is present in the diffuse texture, the normal and specular maps don't render. If the object starts off with a diffuse map that contains an alpha channel (e.g. "water particle 1' from Library), then the normal and specular maps both render.

If the script is modified to use PRIM_ALPHA_MODE_NONE (as the build tool would use when adding a material to the the default 'plywood' texture), then the normal and specular maps appear properly, regardless of whether the diffuse map has an alpha channel.

Manually changing a material will show that change though. This probably happens because the build tool always sets the alpha mode to PRIM_ALPHA_MODE_NONE when there is no alpha channel in the diffuse map.

sl-service-account commented 9 years ago

Loki Eliot commented at 2015-02-01T20:40:56Z, updated at 2015-02-01T20:41:11Z

OK yes, so i just need to be more specific in my scripting and define the appropriate alpha mode when changing a texture from a non alpha texture to a texture with an alpha. Its more scripting work, but at i can work with it now i know whats happening. ;-)