struct VS_OUT { float4 hPosition : POSITION; float4 cPosition : TEXCOORD1; float2 texCoord : TEXCOORD0; float r : TEXCOORD2; float4 center : TEXCOORD3; }; VS_OUT HPS_Smoke_S_VS (float4 position : POSITION, float4 texCoord : TEXCOORD0, uniform float4x4 worldView, uniform float4x4 Proj, uniform float4x4 worldViewProj) { VS_OUT OUT; float2 offset = texCoord.zw; float4 cPosition; cPosition = mul(worldView, position); OUT.center = cPosition; cPosition.xy += offset; OUT.cPosition = cPosition; OUT.r = abs(texCoord.z); OUT.hPosition = mul( Proj, cPosition ); OUT.texCoord = texCoord.xy; return OUT; } float4 HPS_Smoke_S_PS(VS_OUT IN, uniform float4x4 Proj, uniform sampler2D Texture ) : COLOR { float4 Color = 0; float f = 0; float b = 1; float alpha = 0; float d = length( IN.cPosition.xyz - IN.center.xyz); if( d < IN.r ) { float w = sqrt( IN.r * IN.r - d * d ); float4 fPosition = IN.cPosition; float4 bPosition = IN.cPosition; fPosition.z -= w; bPosition.z += w; fPosition = mul(Proj, fPosition); bPosition = mul(Proj, bPosition); f = (fPosition.z / fPosition.w + 1.0) / 2.0; b = (bPosition.z / bPosition.w + 1.0) / 2.0; alpha = pow(w / IN.r, 4) * 0.5; } else discard; Color.r = b; Color.g = 1 - f; Color.a = alpha; //Color.a = tex2D(Texture, IN.texCoord).a * 0.2; return Color; }