struct VertexOut { float4 VertexPosition :POSITION; float2 TexCoord :TEXCOORD; float4 Position :TEXCOORD1; float4 EyePosition :TEXCOORD2; float2 BbSizeAngleCos :TEXCOORD3; float4 LightSpacePos :TEXCOORD4; }; // // Vertex program for displaying particle system with rectangle rendertexture // VertexOut VertexProgram( float4 Position :POSITION, float4 Texcoord: TEXCOORD, uniform float4x4 LightModelViewProj, uniform float3 LightPosition, uniform float3 EyePosition, uniform float4x4 ModelViewProj :state.matrix.mvp, uniform float4x4 ModelViewMatrix:state.matrix.modelview ) { VertexOut Out; float3 LightToPoint=normalize(Position.xyz-LightPosition); float3 PointToEye=normalize(EyePosition-Position.xyz); Out.BbSizeAngleCos.y=dot(LightToPoint,PointToEye); Out.LightSpacePos=mul(LightModelViewProj, Position); Out.LightSpacePos.xyz=Out.LightSpacePos.xyz/Out.LightSpacePos.w; Out.LightSpacePos.xyz=(Out.LightSpacePos.xyz+1)/2; Out.VertexPosition=mul(ModelViewProj, Position); Out.TexCoord=Texcoord.xy; Out.Position=Out.VertexPosition; Out.BbSizeAngleCos.x=Texcoord.z; Out.EyePosition=mul(ModelViewMatrix, Position); Out.Position.xyz=(Out.Position.xyz/Out.Position.w+1)/2; return Out; } // // Fragment program for displaying particle system with rectangle rendertexture // void FragmentProgram( VertexOut In, uniform samplerRECT Texture, uniform samplerRECT FrontTexture, uniform samplerRECT BackTexture, uniform samplerRECT ObjTexture, uniform samplerRECT Illum1, uniform samplerRECT Illum2, uniform samplerRECT Illum3, uniform samplerRECT Illum4, uniform float Transparency, uniform float Symmetry, uniform float Albedo, uniform float4x4 LightModelViewProjInv, uniform float4x4 ProjMatrixInv:state.matrix.projection.inverse, uniform float4x4 ProjMatrix:state.matrix.projection, float4 out Color:COLOR ,float out Depth:DEPTH ) { Color=float4(1,1,1,1); /* float2 illumUV=In.LightSpacePos.xy; float z=In.LightSpacePos.z; float3 start; float3 end; float3 temp; float g2=pow(Symmetry,2); float phase=3*(1-g2)*(1+pow(In.BbSizeAngleCos.y,2))/2/(2+g2)/pow((1+g2+2*Symmetry*In.BbSizeAngleCos.y),1.5); float reflect=phase*Albedo*(1-Transparency); */ float objdepth=texRECT(ObjTexture,In.Position.xy*512).r; float backdepth=texRECT(BackTexture,In.TexCoord*512).r; float frontdepth=texRECT(FrontTexture,In.TexCoord*512).r; if(frontdepth==1) { Color.a=0; Depth=1; } else { float4 frontpos=In.EyePosition+float4(0,0,In.BbSizeAngleCos.x*(0.5-frontdepth),0); float frontdepth2=frontpos.z; frontpos=mul(ProjMatrix,frontpos); frontpos.z=(frontpos.z/frontpos.w+1)/2; Depth=frontpos.z; float4 backpos=In.EyePosition+float4(0,0,In.BbSizeAngleCos.x*(0.5-backdepth),0); float backdepth2=backpos.z; float d=backdepth2-frontdepth2; float o=objdepth-frontdepth2; Color.a=backdepth-frontdepth; Color.a*=saturate(o/d); /* if(z<0.25) { start=float3(1,1,1); end=texRECT(Illum1,illumUV*256).xyz; temp=lerp(start,end,z*4); } if(z<0.5&&z>=0.25) { start=texRECT(Illum1,illumUV*256).xyz; end=texRECT(Illum2,illumUV*256).xyz; temp=lerp(start,end,(z-0.25)*4); } if(z>=0.5&&z<0.75) { start=texRECT(Illum2,illumUV*256).xyz; end=texRECT(Illum3,illumUV*256).xyz; temp=lerp(start,end,(z-0.5)*4); } if(z>=0.75) { start=texRECT(Illum3,illumUV*256).xyz; end=texRECT(Illum4,illumUV*256).xyz; temp=lerp(start,end,(z-0.75)*4); }*/ } //Color*=float4(temp,reflect*texRECT(Texture,In.TexCoord*256).r); //Color*=float4(temp,reflect); }