I’d love to try this out - I’m just concerned about shader implementation. At the moment I’m using Shader Forge, creating an unlit/texture type shader. I’m definitely in the market for a way to add nice reflections!
this is the current simple shader I’m using:
// Shader created with Shader Forge Beta 0.33
// Shader Forge (c) Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:0.33;sub:START;pass:START;ps:flbk:,lico:1,lgpr:1,nrmq:1,limd:1,uamb:False,mssp:True,lmpd:False,lprd:False,enco:False,frtr:True,vitr:True,dbil:False,rmgx:True,rpth:1,hqsc:True,hqlp:False,blpr:0,bsrc:0,bdst:1,culm:0,dpts:2,wrdp:True,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0,f2p0:False;n:type:ShaderForge.SFN_Final,id:1,x:32719,y:32712|diff-2-RGB,spec-82-OUT,gloss-272-OUT,amdfl-291-OUT;n:type:ShaderForge.SFN_Tex2d,id:2,x:33154,y:32542,ptlb:MainTex,ptin:_MainTex,tex:59e1e8b0203f6564bb9ae1af71b35908,ntxv:2,isnm:False;n:type:ShaderForge.SFN_Vector1,id:82,x:33154,y:32724,v1:0;n:type:ShaderForge.SFN_Slider,id:272,x:33154,y:32813,ptlb:Gloss slider,ptin:_Glossslider,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Vector1,id:291,x:33154,y:32925,v1:1;proporder:2-272;pass:END;sub:END;*/
Shader "Shader Forge/unlit_texture_SF" {
Properties {
_MainTex ("MainTex", 2D) = "black" {}
_Glossslider ("Gloss slider", Range(0, 1)) = 0
}
SubShader {
Tags {
"RenderType"="Opaque"
}
Pass {
Name "PrePassBase"
Tags {
"LightMode"="PrePassBase"
}
Fog {Mode Off}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_PREPASSBASE
#include "UnityCG.cginc"
#pragma exclude_renderers xbox360 ps3 flash d3d11_9x
#pragma target 3.0
uniform float _Glossslider;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 posWorld : TEXCOORD0;
float3 normalDir : TEXCOORD1;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalDirection = i.normalDir;
return fixed4( normalDirection * 0.5 + 0.5, _Glossslider );
}
ENDCG
}
Pass {
Name "PrePassFinal"
Tags {
"LightMode"="PrePassFinal"
}
ZWrite Off
Fog {Mode Off}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_PREPASSFINAL
#include "UnityCG.cginc"
#pragma multi_compile_prepassfinal
#pragma exclude_renderers xbox360 ps3 flash d3d11_9x
#pragma target 3.0
uniform sampler2D _LightBuffer;
#if defined (SHADER_API_XBOX360) defined (HDR_LIGHT_PREPASS_ON)
sampler2D _LightSpecBuffer;
#endif
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _Glossslider;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
float4 projPos : TEXCOORD3;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.projPos = ComputeScreenPos (o.pos);
COMPUTE_EYEDEPTH(o.projPos.z);
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalDirection = i.normalDir;
////// Lighting:
half4 lightAccumulation = tex2Dproj(_LightBuffer, UNITY_PROJ_COORD(i.projPos));
#if defined (SHADER_API_GLES) || defined (SHADER_API_GLES3)
lightAccumulation = max(lightAccumulation, half4(0.001));
#endif
#ifndef HDR_LIGHT_PREPASS_ON
lightAccumulation = -log2(lightAccumulation);
#endif
#if defined (SHADER_API_XBOX360) defined (HDR_LIGHT_PREPASS_ON)
lightAccumulation.w = tex2Dproj (_LightSpecBuffer, UNITY_PROJ_COORD(i.projPos)).r;
#endif
/////// Diffuse:
float3 diffuse = lightAccumulation.rgb * 0.5;
////// Specular:
float node_82 = 0.0;
float3 specularColor = float3(node_82,node_82,node_82);
float3 specular = lightAccumulation.rgb*lightAccumulation.a * specularColor;
float3 finalColor = 0;
float3 diffuseLight = diffuse;
float node_291 = 1.0;
diffuseLight += float3(node_291,node_291,node_291); // Diffuse Ambient Light
float2 node_307 = i.uv0;
finalColor += diffuseLight * tex2D(_MainTex,TRANSFORM_TEX(node_307.rg, _MainTex)).rgb;
finalColor += specular;
/// Final Color:
return fixed4(finalColor,1);
}
ENDCG
}
Pass {
Name "ForwardBase"
Tags {
"LightMode"="ForwardBase"
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#pragma multi_compile_fwdbase_fullshadows
#pragma exclude_renderers xbox360 ps3 flash d3d11_9x
#pragma target 3.0
uniform float4 _LightColor0;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _Glossslider;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
LIGHTING_COORDS(3,4)
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalDirection = i.normalDir;
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
float3 halfDirection = normalize(viewDirection+lightDirection);
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float3 attenColor = attenuation * _LightColor0.xyz;
/////// Diffuse:
float NdotL = dot( normalDirection, lightDirection );
float3 diffuse = max( 0.0, NdotL) * attenColor;
///////// Gloss:
float gloss = _Glossslider;
float specPow = exp2( gloss * 10.0+1.0);
////// Specular:
NdotL = max(0.0, NdotL);
float node_82 = 0.0;
float3 specularColor = float3(node_82,node_82,node_82);
float3 specular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow) * specularColor;
float3 finalColor = 0;
float3 diffuseLight = diffuse;
float node_291 = 1.0;
diffuseLight += float3(node_291,node_291,node_291); // Diffuse Ambient Light
float2 node_308 = i.uv0;
finalColor += diffuseLight * tex2D(_MainTex,TRANSFORM_TEX(node_308.rg, _MainTex)).rgb;
finalColor += specular;
/// Final Color:
return fixed4(finalColor,1);
}
ENDCG
}
Pass {
Name "ForwardAdd"
Tags {
"LightMode"="ForwardAdd"
}
Blend One One
Fog { Color (0,0,0,0) }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDADD
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#pragma multi_compile_fwdadd_fullshadows
#pragma exclude_renderers xbox360 ps3 flash d3d11_9x
#pragma target 3.0
uniform float4 _LightColor0;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _Glossslider;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
LIGHTING_COORDS(3,4)
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalDirection = i.normalDir;
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
float3 halfDirection = normalize(viewDirection+lightDirection);
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float3 attenColor = attenuation * _LightColor0.xyz;
/////// Diffuse:
float NdotL = dot( normalDirection, lightDirection );
float3 diffuse = max( 0.0, NdotL) * attenColor;
///////// Gloss:
float gloss = _Glossslider;
float specPow = exp2( gloss * 10.0+1.0);
////// Specular:
NdotL = max(0.0, NdotL);
float node_82 = 0.0;
float3 specularColor = float3(node_82,node_82,node_82);
float3 specular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow) * specularColor;
float3 finalColor = 0;
float3 diffuseLight = diffuse;
float2 node_309 = i.uv0;
finalColor += diffuseLight * tex2D(_MainTex,TRANSFORM_TEX(node_309.rg, _MainTex)).rgb;
finalColor += specular;
/// Final Color:
return fixed4(finalColor * 1,0);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
any tips?