0
Fixed

Shader works for me, but not for others.

Kasra Kalami vor 10 Jahren aktualisiert vor 10 Jahren 17
Hi ive made a shader and I can view it and all but when compiling it as openGL it turns out black for others in my group. Can't really figure out the problem. Hope you can help me.

Antwort

Antwort
Fixed
That's most likely why. If you're on Windows, Unity defaults to DirectX, but you're not compiling any DX compatible shaders. Just check d3d9 and it should work on all machines again :)
Wird überprüft
Are you using the same platform? Are you using the same quality settings?
Using a mac building for android, they are using a pc building for android. 
Do you have d3d9 in the shader as well, in addition to the OpenGL ones?
nope just OpenGL and OpenGL ES 2.0. Thanks for the quick replies :)
Antwort
Fixed
That's most likely why. If you're on Windows, Unity defaults to DirectX, but you're not compiling any DX compatible shaders. Just check d3d9 and it should work on all machines again :)
+1
Thanks man, Ill try it tomorrow at work!
Works on Windows, but not on android using a Samsung s3. And now I have the same problem when changing the graphics emulator from OpenGL ES 2.0 to no graphics emulated and back again to OpenGL ES 2.0, it turns black. But as soon as I open shader forge it starts working again.
That's very strange, and sounds more like an issue on Unity's end rather than Shader Forge
Okey so I found the problem after several hours of testing and it didn't have anything to do with when compiling it. Im currently working on a car game where the car can be bulged and dirty. For this I used a texture mask where r=channel represents the front of the car and b,g,a are the right,left and back sides of the car. Im using slider to see the effects on these and everything works fine and I can see the results. But for some reason this is not supported in OpenGL ES 2.0 when I do graphics emulation in unity. Blending between textures works fine, but using masks to define where is the problem. Is this an issue you know about?
Managed to fix it now by using the other textures(diffuse, specc, normal) alpha channels as masks, instead of one mask texture. Ugly fix but it worked :) Tack för hjälpen!
It sounds as if you simply forgot to assign the mask in the material inspector. Although I suppose there could be a texture limit you're hitting as well
Okey so the problem still exists when trying it on Android. As I mentioned earlier I'm using a texture mask to get the bulge on the car. Inside the shader code theres 2 functions, a vertex shader function called "Vert()", and a fragment shader function called "frag()". The problem seems to be that you can't use textures inside the "Vert()" function like you can in normal OpenGL, and directX. But this is not supported in OpenGL ES. There are 2 functions (Tex2d() and Tex2dLod()) that can't be used inside vert() function (in OpenGL ES), what they do, is that they convert the image into colors based on UV.

Does the shader code contain #pragma glsl ?
Tex2D doesn't work in vert on OpenGL, but Tex2Dlod should. Which one is it using?
Using Text2dLod, works on our computers but not on the Android devices.