Sign in to follow this  
genesys

shaders with transparency

Recommended Posts

Hi! I've got a Problem! I just started coding HLSL shaders with Rendermonkey. Now i'm trying to create billboards with transparent parts . . . but i don't get transparency to work! Can someone explain me how to achieve that plz? THX!

Share this post


Link to post
Share on other sites
What do you have so far? What does it do? It is a bit of a long shot to start talking from scratch.

Here's a basic introduction into the principles of transparency.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Hum . . . i'm creating directX shaders with rendermonkey . . . now i've got it after copy pasting the Render State node of one of the example scenes into my renderpass (before i tried to make a render state from scratch and changed all the parameters so that they were the same like in the example scene - but that didn't work)

The problem is, that i don't really understand what those render states are. Why can't i define transparency in the shader itself??

I won't use FX files because my gameengine doesn't support it . . . I just use the created HLSL code - but if the transparency is defined in the render state, i can't take it into my gameengine . . . *confused*

Share this post


Link to post
Share on other sites
You can output a specific alpha/transperency value for a certain pixel in your pixel shader. That's what you can do from HLSL.

But it is the framebuffer blending component that decides what to do with the output - and that's a fixed function component that is setup and controlled by the render states. To do basic blending you should:

1) Turn on blending:
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

2) Set the src and dst blend factors
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

- Kasper

Share this post


Link to post
Share on other sites

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