${VFXPerPassInclude} ${VFXGeneratedBlockFunction} struct vs_input { VFX_DECLARE_INSTANCE_ID }; #pragma vertex vert VFX_VARYING_PS_INPUTS vert(uint id : SV_VertexID, vs_input i) { VFX_VARYING_PS_INPUTS o = (VFX_VARYING_PS_INPUTS)0; UNITY_SETUP_INSTANCE_ID(i); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); uint index = (id >> 2) + VFX_GET_INSTANCE_ID(i) * 2048; ${VFXLoadAttributesOrCull} ${VFXProcessBlocks} if (!attributes.alive) return o; o.VFX_VARYING_UV.x = float(id & 1) * 2.0f - 1.0f; o.VFX_VARYING_UV.y = float(id & 2) - 1.0f; ${VFXLoadSize} float uSize = size3.x * 0.5f; float camDist = length(GetViewVFXPosition() - attributes.position); float scale = 1.0f - (1.0f - unity_OrthoParams.w) * uSize / camDist; float3 vPos = attributes.position; vPos += attributes.axisX * (o.VFX_VARYING_UV.x * uSize * scale); vPos += attributes.axisY * (o.VFX_VARYING_UV.y * uSize * scale); vPos -= attributes.axisZ * uSize; #ifdef VFX_VARYING_SPHERECENTER o.VFX_VARYING_SPHERECENTER = TransformPositionVFXToWorld(attributes.position); #endif #ifdef VFX_VARYING_SPHERERADIUS o.VFX_VARYING_SPHERERADIUS = uSize; #endif o.VFX_VARYING_POSCS = TransformPositionVFXToClip(vPos); ${VFXVertexCommonProcess} ${VFXVertexAdditionalProcess} return o; } ${VFXFragmentCommonFunctions} void VFXClipSphereAndGetDepthOffsetAndNormal(out float depthOffset, out float3 normalWS ,VFX_VARYING_PS_INPUTS i) { float lsqr = dot(i.VFX_VARYING_UV, i.VFX_VARYING_UV); clip(1.0f - lsqr); float nDepthOffset = 1.0f - sqrt(1.0f - lsqr); // normalized depth offset float3 camToPosDir = normalize(i.VFX_VARYING_POSWS - VFXGetViewWorldPosition()); float3 posWS = i.VFX_VARYING_POSWS + (camToPosDir * (nDepthOffset * i.VFX_VARYING_SPHERERADIUS)); float4 posCS = VFXTransformPositionWorldToClip(posWS); depthOffset = posCS.z / posCS.w; normalWS = normalize(posWS - i.VFX_VARYING_SPHERECENTER); } ${VFXBegin:VFXVertexAdditionalProcess}${VFXEnd}