Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2.  
  3. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  4.  
  5. Shader "MyPSX/psxVertexLit" {
  6. Properties{
  7. _MainTex("Base (RGB)", 2D) = "white" {}
  8. }
  9. SubShader{
  10. Tags { "RenderType" = "Opaque" }
  11. //Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
  12. LOD 200
  13.  
  14. Pass {
  15. //Blend SrcAlpha OneMinusSrcAlpha
  16. //Cull Off
  17. //ZWrite Off
  18.  
  19. Lighting On
  20. CGPROGRAM
  21.  
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. //#pragma surface surf BlinnPhong
  25. #pragma multi_compile_instancing
  26. //#pragma vertex wfiVertCol
  27. //#pragma fragment passThrough
  28.  
  29. #include "UnityCG.cginc"
  30.  
  31. struct v2f
  32. {
  33. UNITY_VERTEX_INPUT_INSTANCE_ID
  34. fixed4 pos : SV_POSITION;
  35. half4 color : COLOR0;
  36. half4 colorFog : COLOR1;
  37. float2 uv_MainTex : TEXCOORD0;
  38. half3 normal : TEXCOORD1;
  39. };
  40.  
  41. float4 _MainTex_ST;
  42. uniform half4 unity_FogStart;
  43. uniform half4 unity_FogEnd;
  44.  
  45.  
  46. v2f vert(appdata_full v)
  47. {
  48. UNITY_SETUP_INSTANCE_ID(v);
  49. v2f o;
  50.  
  51. //Vertex snapping
  52.  
  53. float4 snapToPixel = UnityObjectToClipPos(v.vertex);
  54. float4 vertex = snapToPixel;
  55. vertex.xyz = snapToPixel.xyz / snapToPixel.w;
  56. vertex.x = floor(256 * vertex.x) / 256;//250
  57. vertex.y = floor(256 * vertex.y) / 256;//250
  58. vertex.xyz *= snapToPixel.w;
  59.  
  60. o.pos = vertex;
  61.  
  62. //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)));
  63.  
  64. //Vertex lighting
  65. // o.color = float4(ShadeVertexLights(v.vertex, v.normal), 1.0);
  66. o.color = float4(ShadeVertexLightsFull(v.vertex, v.normal, 4, true), 1);
  67. o.color *= v.color;
  68.  
  69. //float distance = length(mul(UNITY_MATRIX_MV,v.vertex));
  70. float distance = length(UnityObjectToClipPos(v.vertex));
  71.  
  72. //Affine Texture Mapping
  73. // float4 affinePos = vertex; //vertex;
  74. o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
  75. // o.uv_MainTex *= distance + ((vertex.w/128) / distance / 2);//8 2
  76. // o.normal = distance + ((vertex.w/128) / distance / 2);//8 2
  77. //Fog
  78. float4 fogColor = unity_FogColor;
  79.  
  80. float fogDensity = (unity_FogEnd - distance) / (unity_FogEnd - unity_FogStart);
  81. o.normal.g = fogDensity;
  82. o.normal.b = 1;
  83.  
  84. o.colorFog = fogColor;
  85. o.colorFog.a = clamp(fogDensity,0,1);
  86.  
  87. //Cut out polygons
  88. if (distance > unity_FogStart.z + unity_FogColor.a * 255)
  89. {
  90. o.pos.w = 0;
  91. }
  92.  
  93. return o;
  94. }
  95.  
  96.  
  97.  
  98. sampler2D _MainTex;
  99.  
  100. float4 frag(v2f IN) : COLOR
  101. {
  102. half4 c = tex2D(_MainTex, IN.uv_MainTex)*IN.color;//tex2D(_MainTex, IN.uv_MainTex / IN.normal.r)*IN.color;
  103. half4 color = c*(IN.colorFog.a);
  104. color.rgb += IN.colorFog.rgb*(1 - IN.colorFog.a);
  105.  
  106.  
  107.  
  108. return color;
  109. }
  110. ENDCG
  111. }
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement