- Home /
Need help with shader not working!
Hello everyone
I was trying to compile and modify Car Paint shader for android (probably want to run it on PC too) But I'm facing a strange problem - It just won't work
When I tried it in Unity 4.5 It all went purple and said that shader has errors or is not supported by my graphics card. it also said that no subshaders can run on this videocard. (seriously? I never had any problems like that and I have a powerful enough PC that's for sure)
Then I tested inin Unity 5 and...It's just not working. It does not tells me if there are any errors and doesn't seem to compile it. I get black material and none of the changes are giving any effect to it.
there's the shader
Shader "TEST/Car_Paint" {
Properties {
_kMetallicCoverage ("Metallic Coverage", Range(0,0)) = 0
_kMetallicShininess ("Metallic Shininess", Range(0,0)) = 0
_kClearCoatF0 ("Clear Coat Specular Intensity (f0)", Range(0,0)) = 0
_kClearCoatShininess ("Clear Coat Shininess", Range(0,0)) = 0
_kFresnelPower ("Fresnel Power", Range(1,1)) = 0
_kMetallicBoost ("Metallic Colour Boost", Range(1,1)) = 0
_kDiffuseTint ("Diffuse Tint (RGB)", Color) = (0,0,0,0)
_kMetallicTint ("Metallic Tint (RGB)", Color) = (0,0,0,0)
_kLiveryUVScale ("Livery UV Scale", Range(0.5,0.5)) = 0
_MainTex ("UV0 Livery Albedo_RGB", 2D) = "defaulttexture" {}
_AuxTex1 ("UV0 Livery F0_R Shiny_G Opacity_B", 2D) = "defaulttexture" {}
_DiffAmbientMap ("Diff Ambient Map", CUBE) = "defaulttexture" {}
_SpecAmbientMap ("Spec Ambient Map", CUBE) = "defaulttexture" {}
_SpecLoopAmbientMap ("Spec Loop Ambient Map", CUBE) = "defaulttexture" {}
}
SubShader {
Pass {
Tags { "RenderType"="Opaque" }
Program "vp" {
SubProgram "gles " {
"!!GLES
#ifdef VERTEX
attribute vec4 _glesVertex;
attribute vec4 _glesColor;
attribute vec3 _glesNormal;
attribute vec4 _glesMultiTexCoord0;
void main ()
{
highp vec4 tmpvar_1;
tmpvar_1.w = 0.0;
tmpvar_1.xyz = normalize(_glesNormal);
gl_Position = (((_glesVertex + tmpvar_1) + _glesColor) + _glesMultiTexCoord0);
}
#endif
#ifdef FRAGMENT
void main ()
{
gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0);
}
#endif"
}
SubProgram "gles3 " {
"!!GLES3#version 300 es
#ifdef VERTEX
in vec4 _glesVertex;
in vec4 _glesColor;
in vec3 _glesNormal;
in vec4 _glesMultiTexCoord0;
void main ()
{
highp vec4 tmpvar_1;
tmpvar_1.w = 0.0;
tmpvar_1.xyz = normalize(_glesNormal);
gl_Position = (((_glesVertex + tmpvar_1) + _glesColor) + _glesMultiTexCoord0);
}
#endif
#ifdef FRAGMENT
layout(location=0) out mediump vec4 _glesFragData[4];
void main ()
{
_glesFragData[0] = vec4(1.0, 1.0, 1.0, 1.0);
}
#endif"
}
}
Program "fp" {
SubProgram "gles " {
"!!GLES"
}
SubProgram "gles3 " {
"!!GLES3"
}
}
}
}
Fallback "Diffuse"
}
I hope someone could help me with this problem,I searched a lot but didn't found any working way to fix it...
I am currently using monodevelop 4.0.1 and Free copy of Unity 5
Answer by Hyper00 · Dec 13, 2015 at 02:57 PM
ifdef VERTEX //начало Вершинный шейдер
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; //ftransform(); } #endif //Вершинный шейдер - Конец
посмотри сам вершинный шейдер под OpenGL работает отлично! Но не будет работать он под Андроид)))) я как раз столкнулся с обратной проблемой! ты кстати мне помог... спасибо тебе большое)))
gl_Vertex = attribute vec4 _glesVertex; проблема что в опенГЛ нужен gl_Vertex для ПК
Answer by tanoshimi · Dec 11, 2015 at 02:04 PM
Your shader only has GLES subshader (see where it says subprogram "gles"
). So are you running Unity in OpenGL mode? If not, no subshaders can run on this videocard, which is pretty much what the error told you.
I've heard that I need to write -force-opengl in the comment section of the unity shortcut but I think that it's not running on the OpenGL.
Should I run Unity trought the C$$anonymous$$D ins$$anonymous$$d? And how is it going to effect on my future builds? [UPDATE]
Just tried Running Unity 5 in OpenGL. No effect and no errors. Wha does it means? It doesn't tell me about Videocard in Unity5 Just found one more detail. It says thet it's a precompiled shader and it does not have compiled code
Your answer
Follow this Question
Related Questions
[Solved] False "variable not assigned" error 3 Answers
jungle terrain problem 0 Answers
Shader Error GLSL error 0 Answers