-
Notifications
You must be signed in to change notification settings - Fork 2
Shader Trouble Shotting
JungSu Kim edited this page Jan 26, 2016
·
1 revision
- 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;
- UNITE Conference
- Unity5 Features
- Unity 2D
- Unity AI
- Unity Animation
- Unity AR(Augmented Reality)
- Unity Assets
- Unity Build
- Unity Cache Server
- Unity Crypto
- Unity Debug
- Unity Easing
- Unity Editor
- Unity Effects
- Unity External Device
- Unity Game Decompile
- Unity Game Logic
- Unity Graphics
- Unity Hardware
- Unity HoloLens
- Unity Library
- Unity Lighting
- Unity Live2D
- Unity Networking
- Unity Optimization
- Unity Particle System
- Unity Physics
- Unity Precedural
- Unity Profiler
- Unity Rendering
- Unity Service
- Unity Shader
- Unity Testing
- Unity Variation
- Unity Windows
- Unity Things