Sign in to follow this  

Snowflake as an example of particle system - rectangular texture vs shape of snowflake

This topic is 2130 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

Hi,
Does anybody know how to understand the text from a book which is at the end of this post???
I have a problem. Like You see in the attached picture:
[url="http://img21.imageshack.us/img21/3780/snowflakea.jpg"]http://img21.imageshack.us/img21/3780/snowflakea.jpg[/url]
snowflake has rectangular shape instead of shape like snowflake should have.

The image file of snowflake is as all image files rectangular with black background. However I read in a book that setting render states in some specific way will cause that the black background file will be invisible.
It is the way from book:
[i]void Psystem::preRender()
{
pDev->SetRenderState(D3DRS_LIGHTING, FALSE);
pDev->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pDev->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pDev->SetRenderState(D3DRS_POINTSIZE, d3d::FtoDw(size));
pDev->SetRenderState(D3DRS_POINTSIZE_MIN, d3d::FtoDw(0.0f));[/i]

[i]// control the size of the particle relative to distance
pDev->SetRenderState(D3DRS_POINTSCALE_A, d3d::FtoDw(0.0f));
pDev->SetRenderState(D3DRS_POINTSCALE_B, d3d::FtoDw(0.0f));
pDev->SetRenderState(D3DRS_POINTSCALE_C, d3d::FtoDw(1.0f));[/i]

[i][b]// use alpha from texture
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);[/b]
}[/i]

This is the text from a book:
[i]Note that we have enabled alpha blending so that the currently set
texture’s alpha channel specifies the transparency of the texture’s
pixels. We use this for a variety of effects; one in particular is to
obtain particles that are not rectangular shaped, as the texture is.
For instance, to obtain a round “snowball-looking” particle, we use
a plain white texture with an alpha channel that is black with a
white circle. Thus, only a round white circle will be displayed
rather than a rectangular white texture.[/i]

[b]So, the snowflake should be set on black background and alpha channel should be set to black or the color of background isn't important? Because I don't understand this text from a book:[/b]
[b][i]to obtain a round “snowball-looking” particle, we use a plain white texture with an alpha channel that is black with a white circle.[/i][/b]

The question is also how to make for example alpha channel of .jpg file to the black:/

Share this post


Link to post
Share on other sites
If you're just using JPG then you don't have an alpha channel, so the easiest thing to do is use a TGA or PNG instead since they support alpha channels. Another way is using a second texture stage, use the color as the alpha (so color = Texture0.rgb, alpha = Texture1.max(rgb) or something of the sort), or even use the color of the texture as the alpha and only have a white color (so color = white, alpha = Texture0.max(rgb) ).

Share this post


Link to post
Share on other sites
[quote name='xycsoscyx' timestamp='1329522923' post='4914057']
Another way is using a second texture stage, use the color as the alpha (so color = Texture0.rgb, alpha = Texture1.max(rgb) or something of the sort).
[/quote]

Mmmm... so in this solution I should have two textures loaded D3DXCreateTextureFromFile. One is which describe the snowflake and the other one which define with the aid of rgb alpha channel, am I right?

Share this post


Link to post
Share on other sites

This topic is 2130 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this