Hello everyone! I have two shaders: First one is CurvedWorld.shader which makes the world bend effect. The second one is Specular.shader which creates fake glossiness and metallic effects. I want to combine them into one shader so that objects that have to be glossy can also have the bending effect. If that's not possible, does anyone know of a shader that includes: Curved world effect, transparency, shininess/metallic effect and color tint? But it should also take in a diffuse texture. Can anyone help please? Thank you! Code (CSharp): Shader "Unlit/CurvedWorld" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _QOffset ("Offset", Vector) = (0,0,0,0) _Dist ("Distance", Float) = 100.0 _Alpha ("Alpha", Range(0.0,1.0)) = 1.0 } SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 100 ZWrite On Blend SrcAlpha OneMinusSrcAlpha Pass { Lighting Off CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _QOffset; float _Dist; float _Alpha; uniform float4 _MainTex_ST; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; }; v2f vert (appdata_base v) { v2f o; float4 vPos = mul (UNITY_MATRIX_MV, v.vertex); float zOff = vPos.z/_Dist; vPos += _QOffset*zOff*zOff; o.pos = mul (UNITY_MATRIX_P, vPos); o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); return o; } half4 frag (v2f i) : COLOR { return tex2D(_MainTex, i.uv) * float4(1,1,1,_Alpha); } ENDCG } } FallBack "Curved/Unlit Texture Alpha" } Code (CSharp): Shader "Custom/Specular" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 _LightDirection ("Light Direction", Vector) = (0,0,0,1) _lightSpread ("Light Spread", Range(0.01, 20)) = 2.0 _LightColor ("Light Color", Color) = (1,0,1,1) } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows vertex:vert nolightmap // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; float3 normal; float3 posWorld; }; half _Glossiness; half _Metallic; half _lightSpread; fixed4 _LightDirection; fixed4 _LightColor; fixed4 _Color; void vert(inout appdata_full v, out Input o) { UNITY_INITIALIZE_OUTPUT(Input, o); o.posWorld = mul(unity_ObjectToWorld, v.vertex); o.normal = normalize(mul(float4(v.normal, 0.0), unity_WorldToObject).xyz); } void surf (Input IN, inout SurfaceOutputStandard o) { float3 normalDirection = IN.normal; float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - IN.posWorld.xyz); float3 lightDirection = normalize(-_LightDirection.xyz); float spec = saturate(dot(normalDirection, lightDirection)) * pow(saturate(dot(reflect(-lightDirection, normalDirection), viewDirection)), _lightSpread); // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = spec * _LightColor + c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }
you can render each shader in a pass Pass in the same file. Order matters and you can set up various settings to handle the pixels from the first. You can do this using Surface shaders. Otherwise you can merge the code, just cram the vert parts and the frag parts at the bottom before your return but you'll make to figure out the nuance and some hardwares have limits on TEXCOORD that you can use like 8 most times. So youll have to use the .w in a float4 to compress some datas