- Home /
Question by
williampigmeu · Jul 10, 2015 at 08:48 PM ·
shaderlightingcutoutunlit
Add alpha cutout and lighting to custom unlit shader
Hello, I'm currently using a shader to render PS1-style graphics (affine mapping and fixed point vertices), but it is an unlit shader, and I would really like to have per-vertex lighting and alpha cutout for the textures, but I have no idea on how to achieve that.
Shader "PSX"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
//_Color("Color", Color) = (0.5, 0.5, 0.5, 1)
_GeoRes("Resolution", Float) = 40
}
SubShader
{
Pass
{
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
struct v2f
{
float4 position : SV_POSITION;
float3 texcoord : TEXCOORD;
};
sampler2D _MainTex;
float4 _MainTex_ST;
//float4 _Color;
float _GeoRes;
v2f vert(appdata_base v)
{
v2f o;
float4 wp = mul(UNITY_MATRIX_MV, v.vertex);
wp.xyz = floor(wp.xyz * _GeoRes) / _GeoRes;
float4 sp = mul(UNITY_MATRIX_P, wp);
o.position = sp;
float2 uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.texcoord = float3(uv * sp.w, sp.w);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float2 uv = i.texcoord.xy / i.texcoord.z;
return tex2D(_MainTex, uv);
}
ENDCG
}
}
}
Comment
Sorry... But, do I have to be any more specific on the question?
Your answer
![](https://koobas.hobune.stream/wayback/20220611230733im_/https://answers.unity.com/themes/thub/images/avi.jpg)