Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "COMBsm/DX11/Transparent" {
- Properties{
- _BumpMap("Normal Map", 2D) = "bump" {}
- //_Metallic("Metallic", Range(0,1)) = 0.0
- }
- SubShader
- {
- Tags
- { "Queue" = "AlphaTest" "IgnoreProjector" = "False" "RenderType" = "Transparent" }
- /////////////////////////////////////////////////////////
- /// First Pass
- /////////////////////////////////////////////////////////
- Pass
- {
- // Only render alpha channel
- ColorMask A
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 3.0
- uniform StructuredBuffer<uint> _Buff1;
- uniform StructuredBuffer<uint> _Buff2;
- float4x4 matr[25];
- uint vprm = 24;
- // note: no SV_POSITION in this struct
- struct v2f
- {
- float2 uv : TEXCOORD0;
- };
- v2f vert(
- float4 vertex : POSITION, // vertex position input
- uint id : SV_VertexID,
- out float4 outpos : SV_POSITION // clip space position output
- )
- {
- v2f o;
- uint cbid = (uint)id / (uint)vprm;
- uint p = _Buff1[cbid];
- float4x4 mt = matr[p >> 24];
- vertex *= 1 - (bool)(_Buff2[cbid / 32] & (1 << (cbid % 32)));
- uint iX = p & 0xFF, iY = (p >> 8) & 0xFF, iZ = (p >> 16) & 0xFF;
- float x = iX; if (iX >= 128) x -= 256;
- float y = iY; if (iY >= 128) y -= 256;
- float z = iZ; if (iZ >= 128) z -= 256;
- float4 pos = float4(x, y, z, 0);
- outpos = UnityObjectToClipPos(mul(mt,vertex) + pos.xyz);
- return o;
- }
- sampler2D _MainTex;
- fixed4 frag(v2f i, UNITY_VPOS_TYPE screenPos : VPOS) : SV_Target
- {
- fixed4 c = fixed4(0,0,0,1);// tex2D(_MainTex, i.uv)*_Color;
- return c;
- }
- ENDCG
- }
- /////////////////////////////////////////////////////////
- /// Second Pass
- /////////////////////////////////////////////////////////
- //Tags { "Queue" = "Transparent" "IgnoreProjector" = "False" "RenderType" = "Transparent" }
- Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
- Blend SrcAlpha OneMinusSrcAlpha
- LOD 200
- CGPROGRAM
- #pragma surface surf Lambert alpha:fade vertex:vert //noshadows
- #pragma target 5.0
- sampler2D _MainTex;
- sampler2D _BumpMap;
- sampler2D _EmissionMap;
- struct appdata {
- float4 vertex : POSITION;
- float4 texcoord : TEXCOORD0;
- float4 texcoord1 : TEXCOORD1;
- float4 texcoord2 : TEXCOORD2;
- float4 tangent : TANGENT;
- float3 normal : NORMAL;
- //float4 color : COLOR;
- uint id : SV_VertexID;
- };
- struct Input {
- float2 uv_BumpMap;
- };
- #ifdef SHADER_API_D3D11
- uniform StructuredBuffer<uint> _Buff1;
- uniform StructuredBuffer<uint> _Buff2;
- #endif
- float4x4 matr[25];
- uint vprm = 24;
- void vert(inout appdata v) {
- uint id = v.id;
- uint cbid = (uint)id / (uint)vprm;
- v.vertex *= 1 - (bool)(_Buff2[cbid / 32] & (1 << (cbid % 32)));
- uint p = _Buff1[cbid];
- float4x4 mt = matr[p >> 24];
- float a = float(128);
- uint iX = p & 0xFF, iY = (p >> 8) & 0xFF, iZ = (p >> 16) & 0xFF;
- float x = iX; if (iX >= 128) x -= 256;
- float y = iY; if (iY >= 128) y -= 256;
- float z = iZ; if (iZ >= 128) z -= 256;
- float4 pos = float4(x, y, z, 0);
- v.vertex.xyz = mul(mt, v.vertex) + pos.xyz;
- v.normal = mul(mt, v.normal);
- v.tangent = mul(mt, v.tangent);
- }
- void surf(Input IN, inout SurfaceOutput o) {
- o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
- o.Albedo = float3(0.8, 0.5, 1);
- o.Alpha = 0.5;
- o.Emission = float3(0.5,0.5,0.5);
- }
- ENDCG
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement