Author Topic: NGUI 2.3.6, Unity 4.1.5f1, Directx 11, not rendering anything on *some* systems  (Read 4901 times)

chrisfirefox

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 9
    • View Profile
Dear ArenMook,

we used NGUI, which is a great way of interpreting the 3D Gameobjects of Unity for 2D User Interfaces and a charm to make UI with I must say, to make all of our User Interfaces for our recently release rpg game. We ran into a problem already described here that sometimes in DirectX 11 mode the UI isn't drawn at all, which is especially bad as we also use NGUI for the fadein to our intro - making the screen stay blank for the users with this problem. We found out that this can either be fixed by updating Graphics cards drivers - but not always - or using the -force-d3d9 - Parameter of Unity to start. Which in turn makes some of our Posteffects so dead slow that the game becomes unplayable.

Do you have a suggestion how to tackle this problem? There is several things I won't be able to do immediately:
- Upgrade Unity - not an option as this might cause *really* unforseen problems
- Upgrade NGUI - if I do that, I'm afraid that some of my adaptions will get lost, and cause more problems as this is an RPG with a *lot* of different Windows, and we are currently not really up for additional unforseen trouble
- Remove DX11 support - I tried that and the game got slower. As the optimization is still not that good, and several players already complained about bad performance, I wouldn't like to add to this problem complex

Maybe there is something you stumbled over some quick fix since your last reply to whatever causes this strange problem, I would really appreciate some help in getting to the base of this, thank you!

kind regards
Chris

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
2.3.6 is very old, and I honestly don't even remember if it supported DX11 correctly back then. As I also recall, Unity may have issues on DX11 with fixed-function type "shaders" that NGUI is using by default. Changing them to actual shaders will likely resolve your issue.
  1. Shader "Unlit/Transparent Colored"
  2. {
  3.         Properties
  4.         {
  5.                 _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
  6.         }
  7.        
  8.         SubShader
  9.         {
  10.                 LOD 100
  11.  
  12.                 Tags
  13.                 {
  14.                         "Queue" = "Transparent"
  15.                         "IgnoreProjector" = "True"
  16.                         "RenderType" = "Transparent"
  17.                 }
  18.                
  19.                 Cull Off
  20.                 Lighting Off
  21.                 ZWrite Off
  22.                 Fog { Mode Off }
  23.                 Offset -1, -1
  24.                 Blend SrcAlpha OneMinusSrcAlpha
  25.  
  26.                 Pass
  27.                 {
  28.                         CGPROGRAM
  29.                                 #pragma vertex vert
  30.                                 #pragma fragment frag
  31.                                
  32.                                 #include "UnityCG.cginc"
  33.        
  34.                                 struct appdata_t
  35.                                 {
  36.                                         float4 vertex : POSITION;
  37.                                         float2 texcoord : TEXCOORD0;
  38.                                         fixed4 color : COLOR;
  39.                                 };
  40.        
  41.                                 struct v2f
  42.                                 {
  43.                                         float4 vertex : SV_POSITION;
  44.                                         half2 texcoord : TEXCOORD0;
  45.                                         fixed4 color : COLOR;
  46.                                 };
  47.        
  48.                                 sampler2D _MainTex;
  49.                                 float4 _MainTex_ST;
  50.                                
  51.                                 v2f vert (appdata_t v)
  52.                                 {
  53.                                         v2f o;
  54.                                         o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  55.                                         o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  56.                                         o.color = v.color;
  57.                                         return o;
  58.                                 }
  59.                                
  60.                                 fixed4 frag (v2f i) : COLOR
  61.                                 {
  62.                                         fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
  63.                                         return col;
  64.                                 }
  65.                         ENDCG
  66.                 }
  67.         }
  68. }