123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "Custom/CircleEffect"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {} //include a texture as a property
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off //ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vertexToFragment
- #pragma fragment giveColor
-
- #include "UnityCG.cginc"
- //info from vertex on the mesh
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- //info for fragment function
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
- v2f vertexToFragment (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
-
- sampler2D _MainTex;
- float4 _MainTex_TexelSize;
- float _blackRatio = 1;
- float _viewRadius = .25;
- float _leftEye = 0;
- float _rightEye = 0;
-
- float4 gridOverPixel(sampler2D tex, float2 uv, float4 size) //average values surrounding pixel together and return the result
- {
- float4 newFragColor = 0;
-
- newFragColor += tex2D(tex, uv+float2(0, 0)); //this should be the same
- //we can just use sin and cos
- return newFragColor;
-
-
- }
- //returns color in float 4 variable given our v2f
- float4 giveColor (v2f i) : SV_Target
- {
- float4 col = gridOverPixel(_MainTex, i.uv, _MainTex_TexelSize);
- float2 coord = i.uv;
- coord -= float2(.5,.5);
- // if(_leftEye == 1){
- // if(sqrt((coord.y * coord.y) + (coord.x - .5) * (coord.x - .5)) > _viewRadius){
- // return col * _blackRatio;
- // }
- // }
- // if(_rightEye == 1){
- // if(sqrt((coord.y * coord.y) + (coord.x + .5) * (coord.x + .5)) > _viewRadius){
- // return col * _blackRatio;
- // }
- // }
- if(sqrt((coord.y * coord.y) + (coord.x) * (coord.x )) > _viewRadius){
- return col * _blackRatio;
- }
- // if(_leftEye == 1){
- // if(sqrt((coord.y * coord.y) + (coord.x + .5) * (coord.x + .5)) > _viewRadius){
- // return col * _blackRatio;
- // }
- // }
-
- // if(_leftEye == 1){
- // if(coord.)
- // }
-
- // if(coord.x * coord.x + coord.y * coord.y > _viewRadius){
- // if(_leftEye == 0 || coord.x < 0){
- // if(_rightEye == 0 || coord.x > 0){
- // return col * (_blackRatio);
- // }
- // }
-
- // }
- return col;
- //so this returns the rgb
- //i.uv.x and i.uv.y returns the color for that position
- //return float4(0, 0, 0, 1);
- }
- ENDCG
- }
- }
- }
|