Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "MyPSX/psxVertexLit" {
- Properties{
- _MainTex("Base (RGB)", 2D) = "white" {}
- }
- SubShader{
- Tags { "RenderType" = "Opaque" }
- //Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
- LOD 200
- Pass {
- //Blend SrcAlpha OneMinusSrcAlpha
- //Cull Off
- //ZWrite Off
- Lighting On
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- //#pragma surface surf BlinnPhong
- #pragma multi_compile_instancing
- //#pragma vertex wfiVertCol
- //#pragma fragment passThrough
- #include "UnityCG.cginc"
- struct v2f
- {
- UNITY_VERTEX_INPUT_INSTANCE_ID
- fixed4 pos : SV_POSITION;
- half4 color : COLOR0;
- half4 colorFog : COLOR1;
- float2 uv_MainTex : TEXCOORD0;
- half3 normal : TEXCOORD1;
- };
- float4 _MainTex_ST;
- uniform half4 unity_FogStart;
- uniform half4 unity_FogEnd;
- v2f vert(appdata_full v)
- {
- UNITY_SETUP_INSTANCE_ID(v);
- v2f o;
- //Vertex snapping
- float4 snapToPixel = UnityObjectToClipPos(v.vertex);
- float4 vertex = snapToPixel;
- vertex.xyz = snapToPixel.xyz / snapToPixel.w;
- vertex.x = floor(256 * vertex.x) / 256;//250
- vertex.y = floor(256 * vertex.y) / 256;//250
- vertex.xyz *= snapToPixel.w;
- o.pos = vertex;
- //v.vertex.x += 0.05 * (step(0.5, sin(_Time.y * 2.0 + v.vertex.y * 1.0)) * step(6.99, sin(_Time.y*60 * 0.5)));
- //Vertex lighting
- // o.color = float4(ShadeVertexLights(v.vertex, v.normal), 1.0);
- o.color = float4(ShadeVertexLightsFull(v.vertex, v.normal, 4, true), 1);
- o.color *= v.color;
- //float distance = length(mul(UNITY_MATRIX_MV,v.vertex));
- float distance = length(UnityObjectToClipPos(v.vertex));
- //Affine Texture Mapping
- // float4 affinePos = vertex; //vertex;
- o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
- // o.uv_MainTex *= distance + ((vertex.w/128) / distance / 2);//8 2
- // o.normal = distance + ((vertex.w/128) / distance / 2);//8 2
- //Fog
- float4 fogColor = unity_FogColor;
- float fogDensity = (unity_FogEnd - distance) / (unity_FogEnd - unity_FogStart);
- o.normal.g = fogDensity;
- o.normal.b = 1;
- o.colorFog = fogColor;
- o.colorFog.a = clamp(fogDensity,0,1);
- //Cut out polygons
- if (distance > unity_FogStart.z + unity_FogColor.a * 255)
- {
- o.pos.w = 0;
- }
- return o;
- }
- sampler2D _MainTex;
- float4 frag(v2f IN) : COLOR
- {
- half4 c = tex2D(_MainTex, IN.uv_MainTex)*IN.color;//tex2D(_MainTex, IN.uv_MainTex / IN.normal.r)*IN.color;
- half4 color = c*(IN.colorFog.a);
- color.rgb += IN.colorFog.rgb*(1 - IN.colorFog.a);
- return color;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement