Shader Trouble Shotting - zzragida/UnityDocs GitHub Wiki
Issue 1. Compilation Failure BloomOptimized Effect
- Device: Nexus 5
- GPU : Adreno 330
๋ฉ์ธ์ง
11-04 13:15:23.520 21792 21899 D Unity : GLES: Const arrays detected in a shader, these will crash Adreno 3xx shader compiler. Failing compilation. 11-04 13:15:23.520 21792 21899 D Unity : Note: Creation of internal variant of shader 'Hidden/FastBloom' failed.
์์ธ๋ด์ฉ
-
Standard Asset์ BloomOptimzed Image Effect๋ฅผ Camera์ ์ ์ฉ
-
BloomOptimzed์ ์ฌ์ฉ์ค์ธ Hidden/FastBloom.shader๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ์คํ์์ ์ ์๋ฌ๊ฐ ๋ฐ์ํจ
-
์์ธ
- Qualcomm Adreno Shader ์ปดํ์ผ๋ฌ๊ฐ ์ ฐ์ด๋ ์ฝ๋๋ฅผ ์ต์ ํํ ๋ Const Array๋ฅผ ์ปดํ์ผํ์ง ๋ชปํ๋ ์ํฉ์
- ์์) static const half4 curve4[7] = { half4(0,0,0,0), half4(1,1,1,1) ...};
-
ํด๊ฒฐ๊ณผ์
- Unity์์ ํด๋น ์ ฐ์ด๋๋ฅผ OpenGLES Core๋ก ์ปดํ์ผํด์ ์ปดํ์ผ๋ ์ฝ๋๋ฅผ ๋ถ์ํด ๋ด
- ๋คํํ ์ ๋ํฐ์์ // XXX ADRENOCONSTARRAYBUG <= ์ด๋ฐ ์ฃผ์์ ๋จ๊ฒจ์ค
-
ํด๊ฒฐ์ฑ
-
Const Array๋ก ์ ๊ทผํด์ ์ฌ์ฉ๋๋ Loop ์ฝ๋๋ฅผ ์์ ํจ
// Before: Adreno Const Array Bug
static const half4 curve4[7] = { half4(0.0205,0.0205,0.0205,0),
half4(0.0855,0.0855,0.0855,0),
half4(0.232,0.232,0.232,0),
half4(0.324,0.324,0.324,1),
half4(0.232,0.232,0.232,0),
half4(0.0855,0.0855,0.0855,0),
half4(0.0205,0.0205,0.0205,0) };
void func()
{
// ...
for( int l = 0; l < 7; l++ )
{
half4 tap = tex2D(_MainTex, coords);
half4 temp = curve4[l];
color += tap * temp;
coords += netFilterWidth;
}
}
// After : Adreno Const Array Bug Fix
static const half4 curve4_0 = half4(0.0205, 0.0205, 0.0205, 0);
static const half4 curve4_1 = half4(0.0855, 0.0855, 0.0855, 0);
static const half4 curve4_2 = half4(0.232, 0.232, 0.232, 0);
static const half4 curve4_3 = half4(0.324, 0.324, 0.324, 1);
static const half4 curve4_4 = half4(0.232, 0.232, 0.232, 0);
static const half4 curve4_5 = half4(0.0855, 0.0855, 0.0855, 0);
static const half4 curve4_6 = half4(0.0205, 0.0205, 0.0205, 0);
half4 color = 0;
half4 tap = tex2D(_MainTex, coords);
color += tap * curve4_0;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_1;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_2;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_3;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_4;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_5;
coords += netFilterWidth;
tap = tex2D(_MainTex, coords);
color += tap * curve4_6;
coords += netFilterWidth;