Jump to content
  • Advertisement
Sign in to follow this  
GremlinX

Question about DX 9 SDK Shader

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

I am using the shader from the DirectX 9 SDK called "ShadowVolume.fx" from the shadow volume c++ tutorial. It works great, and looks great but I have 2 questions. First, whenever I try to render a texture that has a transparency layer, I get this darkened, translucent patch instead of being transparent. Here is a picture to illustrate this better: As you can see, you should be able to see right through the fence but it looks like it isn't being blended properly. My 2nd question is, how would I add specular highlighting to this scene? Would I add it into this shader, or create a new shader? Thanks for your help

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I'm not a shader programmer yet, but when you create your device, you are creating one without an alpha channel(X8R8G8B8).I saw this in your picture. Im pretty sure that it you want alpha blending, you need a alpha channel.

Hope this help,
ProgrammingNerd

Share this post


Link to post
Share on other sites
The strange thing is that alpha-blending does work in other places. Like that dusty looking orange/brown cloud, it is all blended nicely. I tried changing the backbuffer to "D3DFMT_A8R8G8B8" to see if that fixes it, but stil no go.
That pixel shader to do the shadows requires that you draw everything 2 times, would that cause issues with alpha-blending?

Share this post


Link to post
Share on other sites
Is this the DirectX sample that uses a "darkening quad" to shadow the scene at the end? If so, then what you're getting on the fence is probably the fact that the fence is in shadow (a shadow receiver) -- although the fence isn't casting a shadow on the ground, so it's un-clear what's shading it.

An alternative could be that your material has a non-0 value for emissive alpha.

To get specular in there, you can add it into the shader.


Note that the "darkening quad" version of stencil shadows is horrible, in that it generates lots of artifacts. Shaded backsides of objects get double-darkened; overlapping lights get darkened, etc. Instead, the right thing to do is to render one pass per light, where you first set up the stencil buffer, and then render the objects, masking the light only where the stencil buffer says there's light.

Share this post


Link to post
Share on other sites
"Instead, the right thing to do is to render one pass per light, where you first set up the stencil buffer, and then render the objects, masking the light only where the stencil buffer says there's light."
This sounds like what is going on in the SDK shader. It sets up the stencil shader, then I render all my objects, then I render the shadow meshes, then I render the objects again, and voila - shadows.

"An alternative could be that your material has a non-0 value for emissive alpha."
I'm not sure where I would set this. Do I set the material values inside the shader, or in my program?

Thanks

Share this post


Link to post
Share on other sites
In regards to the specular lighting, I have found many different articles regarding specular lighting and shaders, and they all seem to be very different. Can anyone point me in the direction of a good article on how to do this using HLSL and the DX Effects framework?

Also, if I want to have a few different things happen to each object that gets rendered, say specular, shadow volumes, bump mapping, environment mapping... etc, would I be better of putting each thing into it's own shader, or combine them into 1 big one?

Thanks!

[Edited by - GremlinX on September 15, 2005 10:27:48 AM]

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!