Add shaders
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
|
||||
|
||||
Shader "TripleBrick/IvyBgPlane" {
|
||||
Properties {
|
||||
_MainTex ("MainTex", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
GrabPass{ }
|
||||
Pass {
|
||||
Name "DEFERRED"
|
||||
Tags {
|
||||
"LightMode"="Deferred"
|
||||
}
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_DEFERRED
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile ___ UNITY_HDR_ON
|
||||
#pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _GrabTexture;
|
||||
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float4 screenPos : TEXCOORD3;
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex );
|
||||
o.screenPos = o.pos;
|
||||
return o;
|
||||
}
|
||||
void frag(
|
||||
VertexOutput i,
|
||||
out half4 outDiffuse : SV_Target0,
|
||||
out half4 outSpecSmoothness : SV_Target1,
|
||||
out half4 outNormal : SV_Target2,
|
||||
out half4 outEmission : SV_Target3 )
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float grabSign = -_ProjectionParams.x;
|
||||
#else
|
||||
float grabSign = _ProjectionParams.x;
|
||||
#endif
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
|
||||
i.screenPos.y *= _ProjectionParams.x;
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||
float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5;
|
||||
float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
|
||||
////// Lighting:
|
||||
////// Emissive:
|
||||
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
|
||||
float3 emissive = (_MainTex_var.rgb*sceneColor.rgb);
|
||||
float3 finalColor = emissive;
|
||||
outDiffuse = half4( 0, 0, 0, 1 );
|
||||
outSpecSmoothness = half4(0,0,0,0);
|
||||
outNormal = half4( normalDirection * 0.5 + 0.5, 1 );
|
||||
outEmission = half4( (_MainTex_var.rgb*sceneColor.rgb), 1 );
|
||||
#ifndef UNITY_HDR_ON
|
||||
outEmission.rgb = exp2(-outEmission.rgb);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD"
|
||||
Tags {
|
||||
"LightMode"="ForwardBase"
|
||||
}
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _GrabTexture;
|
||||
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float4 screenPos : TEXCOORD3;
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex );
|
||||
o.screenPos = o.pos;
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float grabSign = -_ProjectionParams.x;
|
||||
#else
|
||||
float grabSign = _ProjectionParams.x;
|
||||
#endif
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
|
||||
i.screenPos.y *= _ProjectionParams.x;
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||
float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5;
|
||||
float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
|
||||
////// Lighting:
|
||||
////// Emissive:
|
||||
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
|
||||
float3 emissive = (_MainTex_var.rgb*sceneColor.rgb);
|
||||
float3 finalColor = emissive;
|
||||
return fixed4(finalColor,1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user