Jump to content
  • Advertisement
Sign in to follow this  
yava

RenderMonkey - HLSL - Partical System

This topic is 2925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hy!
I have a a problem with RenderMonkey. I try to write effect - Particle System.
So, then i do it in direct code without RenderMonkey - it's OK. But now I need create large system with 10 params - so it's fo RenderMonkey. And then I use POINTSPRITEENABLE - it's not work.
Show me, please, work example of effect with POINTSPRITE.
Why it's not work?


float4x4 worldViewProj;

float up;
float down;
float jump;
float dist;

struct VS_INPUT
{
float3 position : POSITION;
float4 color0 : COLOR0;
float size : PSIZE0;
};

struct VS_OUTPUT
{
float4 position : POSITION;
float4 color0 : COLOR0;
float size : PSIZE0;
float2 TextureUV : TEXCOORD0;

};

VS_OUTPUT RenderSceneVS( VS_INPUT IN )
{
VS_OUTPUT OUT;

float step = IN.size*jump;

float4 v = float4( IN.position.x,IN.position.y,IN.position.z,1.0f );
if(v.y + step > up) v.y += step - up;
else v.y+= step;



OUT.position = mul( v, worldViewProj );
OUT.color0 = IN.color0;


float3 pf = IN.position;
float3 p = mul( float3(1,0,0), worldViewProj );
float dst = distance(pf,p);
if(dst<10) OUT.size = IN.size;
else if((dst>10)*(dist<50))OUT.size = IN.size/1.5;
else if(dist>50) OUT.size = IN.size/2;

OUT.TextureUV = float2(0,0);

return OUT;
}

VS_OUTPUT RenderSceneVS2( VS_INPUT IN )
{
VS_OUTPUT OUT;

float step = IN.size*jump;

float4 v = float4( IN.position.x,IN.position.y,IN.position.z,1.0f );
if(v.y + step > up) v.y += step - up;
else v.y+= step;

v.x = v.x + sin(step);
v.y = v.y + cos(step);


OUT.position = mul( v, worldViewProj );
OUT.color0 = IN.color0;

float3 pf = IN.position;
float3 p = mul( float3(1,0,0), worldViewProj );
float dst = distance(pf,p);
if(dst<10) OUT.size = IN.size;
else if((dst>10)*(dist<50))OUT.size = IN.size;
else if(dist>50) OUT.size = IN.size;


OUT.TextureUV = float2(0,0);

return OUT;
}



texture g_MeshTexture;

sampler testTexture =
sampler_state
{
Texture = <g_MeshTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};


struct PS_OUTPUT
{
float4 color : COLOR;
};



PS_OUTPUT RenderScenePS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
OUT.color = tex2D( testTexture, IN.TextureUV ) ; // Add texel color to vertex color

return OUT;
}




technique ParticlesFlowDirect
{
pass P0
{
DESTBLEND = ONE;
ZWRITEENABLE = FALSE;
ZENABLE = TRUE;
DESTBLENDALPHA = ONE;
SRCBLEND = SRCALPHA;
ALPHABLENDENABLE = TRUE;
CULLMODE = CCW;
POINTSPRITEENABLE = TRUE;
POINTSCALEENABLE = TRUE;

VertexShader = compile vs_2_0 RenderSceneVS();
PixelShader = compile ps_2_0 RenderScenePS(); // trivial pixel shader (could use FF instead if desired)
}
}


technique ParticlesFlowRandom
{
pass P0
{
DESTBLEND = ONE;
ZWRITEENABLE = FALSE;
ZENABLE = TRUE;
DESTBLENDALPHA = ONE;
SRCBLEND = SRCALPHA;
ALPHABLENDENABLE = TRUE;
CULLMODE = CCW;
POINTSPRITEENABLE = TRUE;
POINTSCALEENABLE = TRUE;

VertexShader = compile vs_2_0 RenderSceneVS2();
PixelShader = compile ps_2_0 RenderScenePS(); // trivial pixel shader (could use FF instead if desired)
}
}



[Edited by - yava on December 9, 2010 7:17:26 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!