string description = "ParticleRendering"; /************* UN-TWEAKABLES **************/ //float4x4 wM < string UIWidget="None"; >; float4x4 vM < string UIWidget="None"; >; float4x4 pM < string UIWidget="None"; >; float4x4 vP; float3 colourTint; float3 camPos; float4 inverseParams; // Note these default values are all ignored anyway by the PS3 float3 offsets[4] = { { -0.5f, -0.5f, 0.0f }, { -0.5f, 0.5f, 0.0f }, { 0.5f, 0.5f, 0.0f }, { 0.5f, -0.5f, 0.0f } }; #include "..\\Basic_Utils.cgfx" #include "VFX_Utils.cgfx" /*********** Tweakables **********************/ float intensity < string UIWidget = "slider"; float UIMin = 0.0; float UIMax = 10.0; float UIStep = 0.01; > = 1.0; /************* Textures ******************/ texture cm : Diffuse < string ResourceType = "2D"; >; sampler2D baseColourMap = sampler_state { Texture = ; MinFilter = None; MipFilter = None; MagFilter = None; WrapS = ClampToEdge; WrapT = ClampToEdge; }; /************* DATA STRUCTS **************/ /* data from application vertex buffer */ struct appdata { float4 position : POSITION; float4 tangent : TEXCOORD0; float4 scale : TEXCOORD1; float4 texCoord : TEXCOORD2; }; /* data passed from vertex shader to pixel shader */ struct vertexOutput { float4 position : POSITION; float3 texCoord : TEXCOORD0; float3 colour : TEXCOORD1; }; /*********** vertex program ******/ vertexOutput simpleVP(appdata IN) { vertexOutput OUT = (vertexOutput)0; OUT.position = mul( vM, float4( IN.position.xyz, 1.0f)); // Get the vertex's Index int index = GetIndex(IN.position.w); // Get vertex's offsets half3 offset = offsets[index]; // Get the Opacity float opacity = GetOpacity(IN.position.w, index); // Get the Tangent (normalised in code) half3 tangent = IN.tangent.xyz; // Get the Scale half3 scale = IN.scale.xyz; // Get the Normal in view space half3 normal = camPos.xyz - IN.position.xyz; normal.xyz = mul(vM, normal.xyz); normal.xyz = normalize(normal.xyz); // Get the binormal half3 binormal = GetBiNormal(normal.xyz, tangent); // Calculate the offsets offset *= scale; offset = ((binormal * offset.x) + (tangent * offset.y) + (normal.xyz * offset.z)); OUT.position.xyz += offset; OUT.position = mul(pM, OUT.position); //OUT.position.xyz += IN.offset.xyz; //OUT.position = mul( pM, OUT.position); OUT.texCoord.xy = IN.texCoord.xy; OUT.texCoord.z = opacity; OUT.colour.r = IN.tangent.w; OUT.colour.gb = IN.texCoord.zw; OUT.colour.rgb *= colourTint; return OUT; } /********* fragment program ********/ float4 simpleFP(vertexOutput IN) : COLOR { float4 colour = half4(tex2D(baseColourMap, IN.texCoord.xy).rgb, 1); //colour.rgb *= colourTint; colour.rgb *= IN.colour.rgb; colour.rgb *= IN.texCoord.z; colour.rgb *= intensity; // Encode to RGBdiv8 colour = colour/max(max(colour.r, colour.g), max(colour.b, 1.1f)); return colour; } /*************/ technique basic < string layer = "Transparent" ; > { pass p0 { VertexProgram = compile arbvp1 simpleVP(); FragmentProgram = compile fp40 simpleFP(); DepthTestEnable = false; DepthMask = false; BlendEnable = true; BlendFuncSeparate = int4( DstAlpha , SrcAlpha , DstAlpha , Zero ) ; CullFaceEnable = false; } } /***************************** eof ***/