Hey all,
I’m currently working on a voxel shader and I have chunks with meshes that can be renderen already.
I want to use a custom shader. The shader has to render the vertices with the colors set for them. This works.
But I also want to have some shadows cast by higher blocks. For example:
[] <- This block has to cast a shadow on the top of
[] <- this block
Does anyone know how I can achieve this effect?
This is the shader:
Shader "VoxelShader" {
Properties {
_Color ("Main Color", COLOR) = (1,1,1,1)
}
SubShader {
Pass {
Fog { Mode Off }
CGPROGRAM
// Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct appdata members vertex,color)
#pragma exclude_renderers d3d11 xbox360
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
// Upgrade NOTE: excluded shader from Xbox360; has structs without semantics (struct appdata members vertex,color)
#pragma exclude_renderers xbox360
#pragma vertex vert
// vertex input: position, color
struct appdata {
float4 vertex;
float4 color;
};
struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
};
v2f vert (appdata v) {
v2f o;
o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
o.color = v.color;
return o;
}
ENDCG
}
}
}