Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
- Shader "Custom/BumpedLambert" {
- Properties{
- _Color("Color", Color) = (1,1,1,1)
- _MainTex("Albedo (RGB)", 2D) = "white" {}
- _BumpMap("Bumpmap", 2D) = "bump" {}
- _CellSize("Сell Size (See Same On VoxelSettings)", Float) = 0.03125
- }
- SubShader {
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
- #pragma surface surf Lambert vertex:vert
- // Use shader model 3.0 target, to get nicer looking lighting
- #pragma target 3.0
- sampler2D _MainTex;
- sampler2D _BumpMap;
- struct Input {
- float2 uv_MainTex;
- float2 uv_BumpMap;
- float3 wNormal;
- float3 wPos;
- };
- fixed4 _Color;
- fixed4 _ColorOffset;
- float _CellSize;
- void vert(inout appdata_full v, out Input data)
- {
- UNITY_INITIALIZE_OUTPUT(Input, data);
- //data.uv_MainTex = TRANSFORM_TEX(v.texcoord1, _MainTex);
- //data.uv_BumpMap = TRANSFORM_TEX(v.texcoord2, _BumpMap);
- data.wPos = mul(unity_ObjectToWorld, v.vertex).xyz;
- data.wNormal = mul((float3x3)unity_ObjectToWorld, v.normal);
- }
- void surf (Input i, inout SurfaceOutput o) {
- float2 pos = frac(float2(
- i.wPos.x * (1.0 - i.wNormal.x) + i.wPos.z * i.wNormal.x, //Figure out texel location inside a cell.
- i.wPos.y * (1.0 - i.wNormal.y) + i.wPos.z * i.wNormal.y)) * _CellSize //Take in account face normal
- //+ float2(blockId + margin, floor(blockId) / gridSize + margin)); //Choose the actual tile
- + float2(floor(i.uv_MainTex.x / _CellSize)*_CellSize,
- floor(i.uv_MainTex.y / _CellSize)*_CellSize);
- fixed4 c = tex2D (_MainTex, pos) * _Color;
- o.Albedo = c.rgb;
- o.Normal = UnpackNormal(tex2D(_BumpMap, pos));
- o.Alpha = c.a;
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement