Created
June 12, 2015 05:39
-
-
Save edwonedwon/9afc89e4bb313cb98810 to your computer and use it in GitHub Desktop.
shder forge in my dipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shader created with Shader Forge v1.16 | |
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/ | |
// Note: Manually altering this data may prevent you from opening it in Shader Forge | |
/*SF_DATA;ver:1.16;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,rpth:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,culm:0,bsrc:0,bdst:0,dpts:2,wrdp:False,dith:0,rfrpo:True,rfrpn:Refraction,ufog:True,aust:True,igpj:True,qofs:0,qpre:3,rntp:2,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:1982,x:33816,y:32723,varname:node_1982,prsc:2|diff-4985-OUT;n:type:ShaderForge.SFN_Tex2d,id:8531,x:33496,y:32681,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:node_8531,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:3a5a96df060a5cf4a9cc0c59e13486b7,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Code,id:4985,x:32916,y:33055,varname:node_4985,prsc:2,code:LwAvACAAdABoAGUAIABmAHIAYQBnAG0AZQBuAHQAIABzAGgAYQBkAGUAcgAgAGIAYQBzAGkAYwBhAGwAbAB5ACAAdABlAGwAbABzACAAdABoAGUAIABHAFAAVQAgAHcAaABhAHQAIAB0AG8AIABjAG8AbABvAHIAIAB0AGgAYQB0ACAAZQB4AGEAYwB0ACAAcABpAHgAZQBsACAAbwBuACAAcwBjAHIAZQBlAG4ACgAvAC8AIAB0AGgAZQAgAFUAVgAgAGkAcwAgAHcAaABhAHQAIAB0AGUAeAB0AHUAcgBlACAAYwBvAG8AcgBkAGkAbgBhAHQAZQAgAHkAbwB1ACAAYQByAGUAIABsAG8AbwBrAGkAbgBnACAAYQB0AAoACgAvAC8AIABmAGkAbgBkACAAbwB1AHQAIABoAG8AdwAgAGYAYQByACAAeQBvAHUAIABhAHIAZQAgAGYAcgBvAG0AIAB0AG8AdQBjAGgACgBmAGwAbwBhAHQAIABkAGkAcwB0AGEAbgBjAGUAVABvAFQAbwB1AGMAaAAgAD0AIABsAGUAbgBnAHQAaAAoACAAdQB2ACAALQAgAHAAbwBzACAAKQA7AAoACQAKAC8ALwAgAGkAcwAgAGkAbgBzAGkAZABlACwAIABjAG8AbABvAHIAIABiAGwAYQBjAGsACgBpAGYAIAAoACAAZABpAHMAdABhAG4AYwBlAFQAbwBUAG8AdQBjAGgAIAA8ACAAcgBhAGQAaQB1AHMAIAApAAoACQByAGUAdAB1AHIAbgAgAHYAZQBjADQAKAAwACwAMAAsADAALAAxACkAOwAKAAkACQAKAC8ALwAgAGUAbABzAGUAIABjAG8AbABvAHIAIAB3AGgAaQB0AGUACgByAGUAdAB1AHIAbgAgAHYAZQBjADQAKAAxACwAMQAsADEALAAxACkAOwAKAA==,output:3,fname:DrawCircle,width:732,height:334,input:1,input:0,input:1,input_1_label:pos,input_2_label:radius,input_3_label:uv|A-2830-OUT,B-9506-OUT,C-7532-UVOUT;n:type:ShaderForge.SFN_ValueProperty,id:4201,x:32464,y:33000,ptovrint:False,ptlb:x,ptin:_x,varname:node_4201,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:20;n:type:ShaderForge.SFN_ValueProperty,id:8992,x:32464,y:33075,ptovrint:False,ptlb:y,ptin:_y,varname:_x_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:10;n:type:ShaderForge.SFN_Append,id:2830,x:32631,y:33031,varname:node_2830,prsc:2|A-4201-OUT,B-8992-OUT;n:type:ShaderForge.SFN_ValueProperty,id:9506,x:32479,y:33229,ptovrint:False,ptlb:radius,ptin:_radius,varname:node_9506,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:5;n:type:ShaderForge.SFN_TexCoord,id:7532,x:32689,y:33198,varname:node_7532,prsc:2,uv:0;proporder:8531-4201-8992-9506;pass:END;sub:END;*/ | |
Shader "Shader Forge/IntersectGlow" { | |
Properties { | |
_Diffuse ("Diffuse", 2D) = "white" {} | |
_x ("x", Float ) = 20 | |
_y ("y", Float ) = 10 | |
_radius ("radius", Float ) = 5 | |
} | |
SubShader { | |
Tags { | |
"IgnoreProjector"="True" | |
"Queue"="Transparent" | |
"RenderType"="Transparent" | |
} | |
Pass { | |
Name "FORWARD" | |
Tags { | |
"LightMode"="ForwardBase" | |
} | |
Blend One One | |
ZWrite Off | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#define UNITY_PASS_FORWARDBASE | |
#include "UnityCG.cginc" | |
#pragma multi_compile_fwdbase | |
#pragma multi_compile_fog | |
#pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2 | |
#pragma target 3.0 | |
uniform float4 _LightColor0; | |
float4 DrawCircle( float2 pos , float radius , float2 uv ){ | |
// the fragment shader basically tells the GPU what to color that exact pixel on screen | |
// the UV is what texture coordinate you are looking at | |
// find out how far you are from touch | |
float distanceToTouch = length( uv - pos ); | |
// is inside, color black | |
if ( distanceToTouch < radius ) | |
return vec4(0,0,0,1); | |
// else color white | |
return vec4(1,1,1,1); | |
} | |
uniform float _x; | |
uniform float _y; | |
uniform float _radius; | |
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; | |
UNITY_FOG_COORDS(3) | |
}; | |
VertexOutput vert (VertexInput v) { | |
VertexOutput o = (VertexOutput)0; | |
o.uv0 = v.texcoord0; | |
o.normalDir = UnityObjectToWorldNormal(v.normal); | |
o.posWorld = mul(_Object2World, v.vertex); | |
float3 lightColor = _LightColor0.rgb; | |
o.pos = mul(UNITY_MATRIX_MVP, v.vertex); | |
UNITY_TRANSFER_FOG(o,o.pos); | |
return o; | |
} | |
float4 frag(VertexOutput i) : COLOR { | |
i.normalDir = normalize(i.normalDir); | |
/////// Vectors: | |
float3 normalDirection = i.normalDir; | |
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); | |
float3 lightColor = _LightColor0.rgb; | |
////// Lighting: | |
float attenuation = 1; | |
float3 attenColor = attenuation * _LightColor0.xyz; | |
/////// Diffuse: | |
float NdotL = max(0.0,dot( normalDirection, lightDirection )); | |
float3 directDiffuse = max( 0.0, NdotL) * attenColor; | |
float3 indirectDiffuse = float3(0,0,0); | |
indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light | |
float3 diffuseColor = DrawCircle( float2(_x,_y) , _radius , i.uv0 ).rgb; | |
float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor; | |
/// Final Color: | |
float3 finalColor = diffuse; | |
fixed4 finalRGBA = fixed4(finalColor,1); | |
UNITY_APPLY_FOG(i.fogCoord, finalRGBA); | |
return finalRGBA; | |
} | |
ENDCG | |
} | |
Pass { | |
Name "FORWARD_DELTA" | |
Tags { | |
"LightMode"="ForwardAdd" | |
} | |
Blend One One | |
ZWrite Off | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#define UNITY_PASS_FORWARDADD | |
#include "UnityCG.cginc" | |
#include "AutoLight.cginc" | |
#pragma multi_compile_fwdadd | |
#pragma multi_compile_fog | |
#pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2 | |
#pragma target 3.0 | |
uniform float4 _LightColor0; | |
float4 DrawCircle( float2 pos , float radius , float2 uv ){ | |
// the fragment shader basically tells the GPU what to color that exact pixel on screen | |
// the UV is what texture coordinate you are looking at | |
// find out how far you are from touch | |
float distanceToTouch = length( uv - pos ); | |
// is inside, color black | |
if ( distanceToTouch < radius ) | |
return vec4(0,0,0,1); | |
// else color white | |
return vec4(1,1,1,1); | |
} | |
uniform float _x; | |
uniform float _y; | |
uniform float _radius; | |
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; | |
LIGHTING_COORDS(3,4) | |
}; | |
VertexOutput vert (VertexInput v) { | |
VertexOutput o = (VertexOutput)0; | |
o.uv0 = v.texcoord0; | |
o.normalDir = UnityObjectToWorldNormal(v.normal); | |
o.posWorld = mul(_Object2World, v.vertex); | |
float3 lightColor = _LightColor0.rgb; | |
o.pos = mul(UNITY_MATRIX_MVP, v.vertex); | |
TRANSFER_VERTEX_TO_FRAGMENT(o) | |
return o; | |
} | |
float4 frag(VertexOutput i) : COLOR { | |
i.normalDir = normalize(i.normalDir); | |
/////// Vectors: | |
float3 normalDirection = i.normalDir; | |
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); | |
float3 lightColor = _LightColor0.rgb; | |
////// Lighting: | |
float attenuation = LIGHT_ATTENUATION(i); | |
float3 attenColor = attenuation * _LightColor0.xyz; | |
/////// Diffuse: | |
float NdotL = max(0.0,dot( normalDirection, lightDirection )); | |
float3 directDiffuse = max( 0.0, NdotL) * attenColor; | |
float3 diffuseColor = DrawCircle( float2(_x,_y) , _radius , i.uv0 ).rgb; | |
float3 diffuse = directDiffuse * diffuseColor; | |
/// Final Color: | |
float3 finalColor = diffuse; | |
return fixed4(finalColor * 1,0); | |
} | |
ENDCG | |
} | |
} | |
FallBack "Diffuse" | |
CustomEditor "ShaderForgeMaterialInspector" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment