Skip to main content
removed fluff & clarified question a bit
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

Hi I'm writing my own shader in mobile, but was wondering if it uses default GPU or CPU skinning feature in Unity3D? 

I'd like to use GPU skinning and already enabled GPU skinning. Is there any way to determine which (GPU or CPU) was actually used?

My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }

Hi I'm writing my own shader in mobile, but was wondering if it uses default GPU or CPU skinning feature in Unity3D? I'd like to use GPU skinning and already enabled GPU skinning. My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }

I'm writing my own shader in mobile, but was wondering if it uses default GPU or CPU skinning feature in Unity3D? 

I'd like to use GPU skinning and already enabled GPU skinning. Is there any way to determine which (GPU or CPU) was actually used?

My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }
deleted 271 characters in body; edited title
Source Link
kkl
  • 43
  • 4

Does Unity3D custom shader work withuse its default GPU or CPU skinning automatically?

Hi I'm writing my own shader in mobile, but was wondering if I will break theit uses default GPU or CPU skinning feature in Unity3D since it's using vertex shader also? I'd like to use GPU skinning and already enabled GPU skinning. My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }

According to here, if using custom shader with instancing, we need to add the instancing shader in our custom shader. Does it apply for GPU skinning too?

Does Unity3D custom shader work with its GPU skinning automatically?

Hi I'm writing my own shader in mobile, but was wondering if I will break the default GPU skinning feature in Unity3D since it's using vertex shader also? My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }

According to here, if using custom shader with instancing, we need to add the instancing shader in our custom shader. Does it apply for GPU skinning too?

Does Unity3D custom shader use its default GPU or CPU skinning automatically?

Hi I'm writing my own shader in mobile, but was wondering if it uses default GPU or CPU skinning feature in Unity3D? I'd like to use GPU skinning and already enabled GPU skinning. My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }
Source Link
kkl
  • 43
  • 4

Does Unity3D custom shader work with its GPU skinning automatically?

Hi I'm writing my own shader in mobile, but was wondering if I will break the default GPU skinning feature in Unity3D since it's using vertex shader also? My shader is as below:

 Shader "Mobile Custom/Specular Map" {
 Properties {
     _ShininessColor("Shininess Color", Color) = (1,1,1,1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _SpecMap ("Specular Map", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 250
     Cull Back
 
     CGPROGRAM
     #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap halfasview interpolateview noshadow nofog nometa nolppv noshadowmask
 
     inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) {
         fixed diff = max (0, dot (s.Normal, lightDir));
         fixed nh = max (0, dot (s.Normal, halfDir));
         fixed spec = pow (nh, s.Specular * 128) * s.Gloss;
 
         fixed4 c;
         c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
         UNITY_OPAQUE_ALPHA(c.a);
         return c;
     }
 
     sampler2D _MainTex;
     sampler2D _SpecMap;
     uniform float4 _ShininessColor;
     half _Shininess;
 
     struct Input {
         float2 uv_MainTex;
     };
 
     void surf (Input IN, inout SurfaceOutput o) {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb;
         o.Gloss = tex2D(_SpecMap, IN.uv_MainTex) * _ShininessColor;
         o.Alpha = tex.a;
         o.Specular = _Shininess;
     }
     ENDCG
 }
 
 FallBack "Mobile/VertexLit"
 }

According to here, if using custom shader with instancing, we need to add the instancing shader in our custom shader. Does it apply for GPU skinning too?