• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by frostbyte85 · Sep 10, 2015 at 05:46 PM · androidshaderiosrenderingspecular

Specular bug on iOS/Android using Standard shader

I am experiencing some strange artifacts when I use the Standard shader (specular or metallic workflow, doesn't matter) on mobiles. It happens on both metal and gles3 renderers and I think that it's relevant to this post: http://forum.unity3d.com/threads/bug-specular-highlights-on-mobile.296914/

Here is what it looks like on device:

alt text

This is what it looks in the editor as a comparison: alt text I did a framegrab when using the gles3 renderer and the fragment shader is the following:

 void main()
 {
     t16_0.x = dot(vs_TEXCOORD1.xyz, vs_TEXCOORD1.xyz);
     t16_0.x = inversesqrt(t16_0.x);
     t16_9.xyz = (-vs_TEXCOORD1.xyz) * t16_0.xxx + _WorldSpaceLightPos0.xyz;
     t16_1.xyz = t16_0.xxx * vs_TEXCOORD1.xyz;
     t16_0.x = dot(t16_9.xyz, t16_9.xyz);
     t16_2 = max(t16_0.x, 0.00100000005);
     t16_0.x = inversesqrt(t16_2);
     t16_0.xyz = t16_0.xxx * t16_9.xyz;
     t16_27 = dot(_WorldSpaceLightPos0.xyz, t16_0.xyz);
     t16_2 = max(t16_27, 0.0);
     t16_27 = t16_2 * t16_2;
     t10_11.xy = texture(_MetallicGlossMap, vs_TEXCOORD0.xy).xw;
     t16_28 = (-t10_11.y) + 1.0;
     t16_3.x = t16_28 * t16_28;
     t16_27 = t16_27 * t10_11.y + t16_3.x;
     t16_27 = t16_27 * unity_LightGammaCorrectionConsts.z;
     t16_2 = t16_27 * t16_2 + 9.99999975e-05;
     t16_27 = dot(vs_TEXCOORD4.xyz, vs_TEXCOORD4.xyz);
     t16_27 = inversesqrt(t16_27);
     t16_3.xyz = vec3(t16_27) * vs_TEXCOORD4.xyz;
     t16_0.x = dot(t16_3.xyz, t16_0.xyz);
     t16_29 = max(t16_0.x, 0.0);
     t16_0.x = log2(t16_29);
     t16_9.x = (-t16_28) + 1.0;
     t16_18 = log2(t16_28);
     t16_18 = t16_18 * 0.75;
     t16_18 = exp2(t16_18);
     t16_18 = t16_18 * 7.0;
     t16_9.x = t16_9.x * 0.967999995 + 0.0299999993;
     t16_9.x = log2(t16_9.x);
     t16_9.x = 10.0 / t16_9.x;
     t16_9.x = max(t16_9.x, -255.936996);
     t16_27 = t16_9.x * t16_9.x;
     t16_9.x = t16_9.x * t16_9.x + 1.0;
     t16_0.x = t16_0.x * t16_27;
     t16_0.x = exp2(t16_0.x);
     t16_0.x = t16_0.x * t16_9.x;
     t16_2 = t16_0.x / t16_2;
     t16_0.x = max(t16_2, 0.0);
     t16_0.x = min(t16_0.x, 100.0);
     t10_4.xyz = texture(_DetailAlbedoMap, vs_TEXCOORD0.zw).xyz;
     t16_5.xyz = t10_4.xyz * unity_ColorSpaceDouble.xyz;
     t10_2.x = texture(_DetailMask, vs_TEXCOORD0.xy).w;
     t16_9.x = (-t10_2.x) + 1.0;
     t16_5.xyz = t16_5.xyz * t10_2.xxx + t16_9.xxx;
     t10_4.xyz = texture(_MainTex, vs_TEXCOORD0.xy).xyz;
     t16_4.xyz = t10_4.xyz * _Color.xyz;
     t16_6.xyz = t16_5.xyz * t16_4.xyz;
     t16_5.xyz = t16_4.xyz * t16_5.xyz + (-unity_ColorSpaceDielectricSpec.xyz);
     t16_5.xyz = t10_11.xxx * t16_5.xyz + unity_ColorSpaceDielectricSpec.xyz;
     t16_9.x = (-t10_11.x) * unity_ColorSpaceDielectricSpec.w + unity_ColorSpaceDielectricSpec.w;
     t16_6.xyz = t16_9.xxx * t16_6.xyz;
     t16_9.x = (-t16_9.x) + 1.0;
     t16_9.x = t16_9.x + t10_11.y;
     t16_9.x = clamp(t16_9.x, 0.0, 1.0);
     t16_7.xyz = (-t16_5.xyz) + t16_9.xxx;
     t16_0.xyw = t16_0.xxx * t16_5.xyz + t16_6.xyz;
     t16_0.xyw = t16_0.xyw * _LightColor0.xyz;
     t16_3.w = 1.0;
     t16_8.x = dot(unity_SHAr, t16_3);
     t16_8.y = dot(unity_SHAg, t16_3);
     t16_8.z = dot(unity_SHAb, t16_3);
     t16_8.xyz = t16_8.xyz + vs_TEXCOORD5.xyz;
     t10_2.x = texture(_OcclusionMap, vs_TEXCOORD0.xy).y;
     t16_28 = (-_OcclusionStrength) + 1.0;
     t16_28 = t10_2.x * _OcclusionStrength + t16_28;
     t16_8.xyz = vec3(t16_28) * t16_8.xyz;
     t16_6.xyz = t16_6.xyz * t16_8.xyz;
     t16_30 = dot(t16_3.xyz, _WorldSpaceLightPos0.xyz);
     t16_2 = max(t16_30, 0.0);
     t16_0.xyw = t16_0.xyw * vec3(t16_2) + t16_6.xyz;
     t16_30 = dot(t16_3.xyz, (-t16_1.xyz));
     t16_2 = max(t16_30, 0.0);
     t16_30 = (-t16_2) + 1.0;
     t16_30 = t16_30 * t16_30;
     t16_30 = t16_30 * t16_30;
     t16_5.xyz = vec3(t16_30) * t16_7.xyz + t16_5.xyz;
     t16_30 = dot(t16_1.xyz, t16_3.xyz);
     t16_30 = t16_30 + t16_30;
     t16_1.xyz = t16_3.xyz * (-vec3(t16_30)) + t16_1.xyz;
     t10_2 = textureLod(unity_SpecCube0, t16_1.xyz, t16_18);
     t16_18 = t10_2.w * unity_SpecCube0_HDR.x;
     t16_1.xyz = t10_2.xyz * vec3(t16_18);
     t16_1.xyz = vec3(t16_28) * t16_1.xyz;
     SV_Target0.xyz = t16_1.xyz * t16_5.xyz + t16_0.xyw;
     SV_Target0.w = 1.0;
     return;
 }

It looks like an exp2(log(a)) optimisation is applied instead of a pow(nh, specularPower), could that be an issue? Has anyone else been experiencing these issues?

Many thanks and sorry for the low-res screenshots, I hope they illustrate the issue correctly.

specular.png (17.5 kB)
screen-shot-2015-09-10-at-114724.png (22.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Cascho01 · Jan 21, 2016 at 07:59 PM

Same here

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by JelmerV · Aug 24, 2017 at 09:13 AM

Do you think this is the same bug/problem? Any updates btw? I am considering disabling specular highlights and creating a plane based sunflare to imitate specular highlights.... I am using a reflection probe anyway...

https://forum.unity3d.com/threads/standard-shaders-specular-on-ios-has-artifacts.489816/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Radial Blur for Android/iOS 0 Answers

Set default number/emails in a new text message/email sent via unity 0 Answers

Why is shader behavior different between Android and iOS? 1 Answer

Mobile problems with reflective/vertexlit shader. 0 Answers

Transparency working in the editor but not when I build 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges