Hi, I have to convert an existing unity VR project (that works fine on android) to iOS, but every object with two specific shaders is rendered black. The two Shaders are "Blend" and "Over", and in XCode I can see this error: ERROR: 0:66: int can't be an in in the fragment shader ERROR: 0:78: Use of undeclared identifier 'xlv_TEXCOORD2' Note: Creation of internal variant of shader 'CustomRenderTexture/Blend' failed. WARNING: Shader Unsupported: 'CustomRenderTexture/Blend' - Pass '' has no vertex shader ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable) WARNING: Shader Unsupported: 'CustomRenderTexture/Blend' - Setting to default shader. ERROR: 0:52: '' :extension 'GL_EXT_gpu_shader4' is not supported ERROR: 0:47: int can't be an in in the fragment shader ERROR: 0:59: Use of undeclared identifier 'xlv_TEXCOORD2' Note: Creation of internal variant of shader 'CustomRenderTexture/Over' failed. WARNING: Shader Unsupported: 'CustomRenderTexture/Over' - Pass '' has no vertex shader ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable) WARNING: Shader Unsupported: 'CustomRenderTexture/Over' - Setting to default shader. I'm a total beginner when it comes to shaders. Do I maybe have to force shader building for iOS somewhere? Thanks in advance
This is the pass code for "Blend": Code (CSharp): CGPROGRAM #include "UnityCustomRenderTexture.cginc" #pragma vertex CustomRenderTextureVertexShader #pragma fragment frag #pragma target 3.0 float _BlendMode; float _Blend; sampler2D _ATex, _BTex; float4 _ATex_ST, _BTex_ST; float _PremultipliedBlend; fixed4 frag (v2f_customrendertexture IN) : Color { // sample the textures float2 uvA = TRANSFORM_TEX(IN.localTexcoord.xy, _ATex); float2 uvB = TRANSFORM_TEX(IN.localTexcoord.xy, _BTex); fixed4 colA = tex2D(_ATex, uvA); fixed4 colB = tex2D(_BTex, uvB); if(_BlendMode == 1) { // Add if(_PremultipliedBlend) { colA *= (1.0 - colB.a * _Blend); colB *= colB.a * _Blend; } return colA + colB; } else if(_BlendMode == 2) { // Substract if(_PremultipliedBlend) { colA *= (1.0 - colB.a * _Blend); colB *= colB.a * _Blend; } return colA - colB; } else { // Replace return lerp(colA, colB, _Blend); } } And this is the pass code for "Over": Code (CSharp): CGPROGRAM #include "UnityCustomRenderTexture.cginc" #pragma vertex CustomRenderTextureVertexShader #pragma fragment frag #pragma target 3.0 sampler2D _BGTex, _FGTex; float4 _BGTex_ST, _FGTex_ST; float _PremultipliedOver; fixed4 frag (v2f_customrendertexture IN) : Color { // sample the textures float2 uvBG = TRANSFORM_TEX(IN.localTexcoord.xy, _BGTex); float2 uvFG = TRANSFORM_TEX(IN.localTexcoord.xy, _FGTex); fixed4 colFG = tex2D(_FGTex, uvFG); fixed4 colBG = tex2D(_BGTex, uvBG); colBG.rgb *= 1.0 - colFG.a; if(_PremultipliedOver) { colFG.rgb *= colFG.a; } return colBG + colFG; } Both using Unity's CustomRenderTexture on version 2017.3
Entire "Blend" shader: Code (CSharp): Shader "CustomRenderTexture/Blend" { Properties { [KeywordEnum(Replace, Add, Substract)] _BlendMode ("Blend Mode", Float) = 0 _Blend ("Blend", Range (0, 1)) = 0 _ATex ("Texture A", 2D) = "black" {} _BTex ("Texture B", 2D) = "black" {} [MaterialToggle] _PremultipliedBlend("Blend Premultiplied", Float) = 1 } SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Lighting Off //Blend SrcAlpha OneMinusSrcAlpha Blend One Zero LOD 100 Pass { CGPROGRAM #include "UnityCustomRenderTexture.cginc" #pragma vertex CustomRenderTextureVertexShader #pragma fragment frag #pragma target 3.0 float _BlendMode; float _Blend; sampler2D _ATex, _BTex; float4 _ATex_ST, _BTex_ST; float _PremultipliedBlend; fixed4 frag (v2f_customrendertexture IN) : Color { // sample the textures float2 uvA = TRANSFORM_TEX(IN.localTexcoord.xy, _ATex); float2 uvB = TRANSFORM_TEX(IN.localTexcoord.xy, _BTex); fixed4 colA = tex2D(_ATex, uvA); fixed4 colB = tex2D(_BTex, uvB); if(_BlendMode == 1) { // Add if(_PremultipliedBlend) { colA *= (1.0 - colB.a * _Blend); colB *= colB.a * _Blend; } return colA + colB; } else if(_BlendMode == 2) { // Substract if(_PremultipliedBlend) { colA *= (1.0 - colB.a * _Blend); colB *= colB.a * _Blend; } return colA - colB; } else { // Replace return lerp(colA, colB, _Blend); } } ENDCG } } } Entire "Over" shader: Code (CSharp): Shader "CustomRenderTexture/Over" { Properties { _BGTex ("Background Texture", 2D) = "black" {} _FGTex ("Over Texture", 2D) = "black" {} [MaterialToggle] _PremultipliedOver("Premultiplied Over", Float) = 1 } SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Lighting Off //Blend SrcAlpha OneMinusSrcAlpha Blend One Zero LOD 100 Pass { CGPROGRAM #include "UnityCustomRenderTexture.cginc" #pragma vertex CustomRenderTextureVertexShader #pragma fragment frag #pragma target 3.0 sampler2D _BGTex, _FGTex; float4 _BGTex_ST, _FGTex_ST; float _PremultipliedOver; fixed4 frag (v2f_customrendertexture IN) : Color { // sample the textures float2 uvBG = TRANSFORM_TEX(IN.localTexcoord.xy, _BGTex); float2 uvFG = TRANSFORM_TEX(IN.localTexcoord.xy, _FGTex); fixed4 colFG = tex2D(_FGTex, uvFG); fixed4 colBG = tex2D(_BGTex, uvBG); colBG.rgb *= 1.0 - colFG.a; if(_PremultipliedOver) { colFG.rgb *= colFG.a; } return colBG + colFG; } ENDCG } } } The "UnityCustomRenderTexture.cginc" include is Unity's shader which you can view on Github (the first entry if you search for UnityCustomRenderTexture.cginc on Google) I didn't post the entire shader cause' I couldn't see any occurrences of integers in the section above. So the error will probably be in the "UnityCustomRenderTexture" shader, which is weird because i couldn't see any compatibility issues with iOS when i reasearched the problem. Maybe it helps too, if i post the entire error: 2018-11-24 13:27:10.775972+0100 vrScene[785:271276] [DYMTLInitPlatform] platform initialization successful 2018-11-24 13:27:11.027318+0100 vrScene[785:271165] -> registered mono modules 0xf32450 -> applicationDidFinishLaunching() 2018-11-24 13:27:11.399628+0100 vrScene[785:271165] Metal GPU Frame Capture Enabled 2018-11-24 13:27:11.400452+0100 vrScene[785:271165] Metal API Validation Disabled -> applicationDidBecomeActive() Renderer: PowerVR SGX 543 Vendor: Imagination Technologies Version: OpenGL ES 2.0 IMGSGX543-129 GLES: 2 GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_read_format GL_IMG_texture_comp ression_pvrtc OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context levelOpenGL ES 2.0 ; Context handle 383251264 Initialize engine version: 2017.3.1f1 (fc1d3344e6ea) WARNING: 0:4: extension 'GL_EXT_frag_depth' is not supported ERROR: 0:38: Use of undeclared identifier 'gl_FragDepthEXT' Note: Creation of internal variant of shader 'Hidden/Internal-MotionVectors' failed. WARNING: Shader Unsupported: 'Hidden/Internal-MotionVectors' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/Internal-MotionVectors' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Setting to default shader. WARNING: 0:4: extension 'GL_EXT_frag_depth' is not supported ERROR: 0:14: Use of undeclared identifier 'gl_FragDepthEXT' Note: Creation of internal variant of shader 'Hidden/BlitCopyWithDepth' failed. WARNING: Shader Unsupported: 'Hidden/BlitCopyWithDepth' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitCopyWithDepth' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySlice' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySlice' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySliceToDepth' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySliceToDepth' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySliceToDepth_MSAA' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/VR/BlitTexArraySliceToDepth_MSAA' - Setting to default shader. 2018-11-24 13:27:12.936318+0100 vrScene[785:271165] INFO [vr/gvr/capi/src/gvr.cc:115] Initialized GVR version 1.100.0 ERROR: 0:52: '' : extension 'GL_EXT_gpu_shader4' is not supported ERROR: 0:66: int can't be an in in the fragment shader ERROR: 0:78: Use of undeclared identifier 'xlv_TEXCOORD2' Note: Creation of internal variant of shader 'CustomRenderTexture/Blend' failed. WARNING: Shader Unsupported: 'CustomRenderTexture/Blend' - Pass '' has no vertex shader ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'CustomRenderTexture/Blend' - Setting to default shader. ERROR: 0:52: '' :extension 'GL_EXT_gpu_shader4' is not supported ERROR: 0:47: int can't be an in in the fragment shader ERROR: 0:59: Use of undeclared identifier 'xlv_TEXCOORD2' Note: Creation of internal variant of shader 'CustomRenderTexture/Over' failed. WARNING: Shader Unsupported: 'CustomRenderTexture/Over' - Pass '' has no vertex shader ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'CustomRenderTexture/Over' - Setting to default shader. Setting up 1 worker threads for Enlighten. UnloadTime: 5.219541 ms
It looks like it's trying to compile the shaders using OpenGL ES 2.0? Custom Render Textures require OpenGL ES 3.1 AEP or OpenGL ES 3.2, neither of which iOS devices support. Only Metal has the features necessary to support Custom Render Textures, and it's possible it still doesn't work there due to a bug. I'd make sure your iOS player build target is set to only use Metal, and if that doesn't work submit a bug to Unity.
Right, I tried to build with OpenGL ES 2.0. I try to build it with Metal API next. Thank you for your time and answers.