Trail render turning out black on iPhone build

Hi there,
Just having this really frustrating issue where my instantiated trail render seems to be turning out black when I build to the iPhone.
Here’s the version in the unity editor -

But the iPhone build turns out like this -

This is my shader

Shader "Petes/Solid Transparent Color" {

Properties {
	_Color ("Solid Color (A = Opacity)", Color) = (0,0,0,1)	
}

Subshader {
	Tags {Queue = Transparent}
	ZWrite Off
	Blend SrcAlpha OneMinusSrcAlpha 
	
	Color [_Color]	
	Pass {}
}

}

Any ideas? Im at a loss. I’m on 3.3.
Thanks
Pete

I’d suggest you to look at Mobile assets that comes with Unity. There’s a shader inside Mobile/Transparent/Vertex Color, for transparency
See these devices are limited and so are the shaders

I didn’t think I could get much more basic than that shader.
The thing is, it always worked before. Just now it’s having these issues. :frowning:

I’m not having the problem. You want to upload the project maybe?

Yeah, it’d be cool if you could have a look, I’d really want to push forward with making my own custom shaders.
Heres a unity package that contains everything in my project - I’m building from unity 3.3 with Xcode 3.2.5
You should just be able to extract to you project and “build and run” to see the issue.

Thanks
Pete.

520916–18465–$Shader Issue.unitypackage (13.5 KB)

I tested it with both OpenGL ES modes. 1.1 was fine, but 2.0 yielded the issue you mentioned. (The graphics emulation modes do not reflect this problem.) Unfortunately, I don’t know or use 2.0 yet, so I can’t help you at this time, if you need to use it, which I’m assuming is the case. But I think this should be one of the easiest possible programmable shaders to write. I’d appreciate it, if you do come upon the correct GLSL or Cg shader somehow, if you could post it here, so I can learn from it.

So as I’m building an armv7 only app, this forces it to be set to 2.0?
Is there some way I could build armv7 with 1.1 or are they linked?

They’re linked. What else does armv7 do for you?

It gets confusing :slight_smile:
I don’t want to do a fat build, but if you choose, armv6 only, Xcode warns that you are required to include an armv7 build. My app also struggles a bit on older devices so I have a uirequireddevice - armv7 setting in the plist to keep it on post 3GS devices only.

Using the universal binary does not enforce opengl es 2.0 actually.
you can disable it in the xcode project, the first define in there is “use opengles 20 if available”, just change it from 1 to 0 and it will always be on opengl es 1.1 even on armv7

I would guess that the shader when compiled to CG code ends up wrong on ES 2.0, you could check that by adding a small cgprogram block which does not really something but which includes the #pragma debug so you get to see the resulting shader code

Hey, thanks! I’ll just force it to be off for this build.
I don’t want to use the 2.0 stuff yet, I really don’t know enough about it.
I think I will eventually build with armv6 only though, it just means that if apple forces armv7 builds I’ll have to do fat ones at that point.

ARMV6 only is a pretty bad decision and I’m unsure apple isn’t going to reject it from yesterday onward as I’m unsure on how well the ARMV6 emulation works on the dual cpu iPad2 (likely A9 cpu) at all on iOS 4.3 which has no ARMV6 support anymore at all. You might lose major performance at worst.

Never forget, ARMV6 assumes VFP presence for example which ARMV7 does not have as hardware, it emulates it on the cpu. also with armv6 only, the Neon chip present on the ARMV7 devices so far are not touched which makes you lose optimizations that you might want to use - unity optimizes stuff like skinned animation etc to make use of these highly optimized chips.

If you are going to cut a generation, then cut ARMV6 and only use ARMV7 with set iOS 4.0 as deployment target (and add the corresponding requirement entry in the plist to limit it to armv7), cause ARMV7 is 70-80% of all devices, ARMV6 native are only 20-30%

Its also a good preparation for iOS5 when you are going to do anyway as the ARMV6 application approval will pretty surely say goodbye at latest by then (some instinct tells me that apple might pull that off earlier if the reception and focus on 4.3 is not large nough by itself)

Cool, thanks for the advice. I’ll stick to 7.

They still don’t reject arm6 only builds. Had an app approved yesterday night. Still, the limitations of the MBX Lite graphics chip are the stuff of nightmares. Can’t wait until their market share drops to a significantly low-level so as to be negligible.

I learned the basics of GLSL today. Here’s a shader that works for both OpenGL ES versions. Let me know if you need help converting any other fixed functions shaders.

Shader "Petes/Solid Transparent Color" {

Properties {
	_Color ("Solid Color (A = Opacity)", Color) = (0,0,0,1)	
}

Category {
	Tags {Queue = Transparent}
	ZWrite Off
	Blend SrcAlpha OneMinusSrcAlpha

	SubShader {
		Pass {
			GLSLPROGRAM
			#ifdef VERTEX		
			void main() {
				gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
			}
			#endif
			
			#ifdef FRAGMENT
			uniform vec4 _Color;
			
			void main() {
				gl_FragColor = _Color;
			}
			#endif
			ENDGLSL
		}
	}
	
	SubShader {
		Color[_Color]
		Pass {}
	}
}

}
1 Like

hehe sweet one :slight_smile:

Its unpleasant that GLSL in Unity for iOS is a bit painfull cause Unity has macros to offer functionality that GLSL on ES 2.0 wouldn’t have and that they are barely to not documented at all