public void DrawShadow(Model model, Matrix world)
{
device.Clear(ClearOptions.Stencil, Color.Black, 0, 0);
dsstate.StencilEnable = true;
dsstate.DepthBufferEnable = true;
dsstate.ReferenceStencil = 0;
dsstate.StencilFunction = CompareFunction.Equal;
dsstate.StencilPass = StencilOperation.Increment;
foreach (ModelMesh mesh in model.Meshes) {
foreach (Effect effect in mesh.Effects)
{
effect.CurrentTechnique = effect.Techniques["Shadow"];
effect.Parameters["World"].SetValue(world*shadow);
effect.Parameters["AlphaTestDirection"].SetValue(-1f);
effect.Parameters["View"].SetValue(FreeCamera.ActiveCamera.View);
effect.Parameters["Projection"].SetValue(FreeCamera.ActiveCamera.Projection);
}
mesh.Draw();
}
dsstate.StencilEnable = false;
}
[/quote]
http://imageshack.us...07/shadowa.jpg/
A few more questions. How can i render the shadow of the leafs that i rendered using a 2 pass approach? I mean, using the correct alpha values.
And is this method efficient for rendering the shadows? I mean, i`ll set the DepthStencilState only once per draw, not for every model, of course, but the DrawShadow() code above was just for testing 1-2 objects.
drawing Shadows with the DepthStencilState. Need just a bit of help. [XNA 4.0]
I`m trying to render shadows using the stencilBuffer. And... doesn`t seem to work. Have a look at my code.
there is shadow on the screenshot
Yes, actually... there are more than 1 shadows. And that`s the problem. Zoom in the picture.
Every poly, i think, has a shadow. And they are overlapping. I want just 1 shadow, having the contour/shape of the tree.
http://www.iimmgg.co...7d6e791518fac40
See the 1st half of the picture? there`s only 1 shape, 1 silhouette, 1 contour.
On the second one, there are many. And they are overlapping. You can easily see that.
The 1st half is actually just like the 2nd, except i use 1 for alpha, not 0.3 or whatever. The 2nd has many semi-transparent parts, one over the other. Thing is , i want just 1 shadow, like in the 1st part, that i can make semi-transparent.
See the 1st half of the picture? there`s only 1 shape, 1 silhouette, 1 contour.
On the second one, there are many. And they are overlapping. You can easily see that.
The 1st half is actually just like the 2nd, except i use 1 for alpha, not 0.3 or whatever. The 2nd has many semi-transparent parts, one over the other. Thing is , i want just 1 shadow, like in the 1st part, that i can make semi-transparent.
i see it now. you may need shaders to manage this. i dont know if there is any fixed function tricks to resolve it.
http://www.iimmgg.co...7d6e791518fac40
See the 1st half of the picture? there`s only 1 shape, 1 silhouette, 1 contour.
On the second one, there are many. And they are overlapping. You can easily see that.
The 1st half is actually just like the 2nd, except i use 1 for alpha, not 0.3 or whatever. The 2nd has many semi-transparent parts, one over the other. Thing is , i want just 1 shadow, like in the 1st part, that i can make semi-transparent.
I'm just a noob, but can't you just make it like the first one, render it to a texture for example, and then apply that texture with alpha on the ground?
I think the idea would be to make it completely black, and then put alpha on the final result.
[quote name='andreilng' timestamp='1306200407' post='4814837']
http://www.iimmgg.co...7d6e791518fac40
See the 1st half of the picture? there`s only 1 shape, 1 silhouette, 1 contour.
On the second one, there are many. And they are overlapping. You can easily see that.
The 1st half is actually just like the 2nd, except i use 1 for alpha, not 0.3 or whatever. The 2nd has many semi-transparent parts, one over the other. Thing is , i want just 1 shadow, like in the 1st part, that i can make semi-transparent.
I'm just a noob, but can't you just make it like the first one, render it to a texture for example, and then apply that texture with alpha on the ground?
I think the idea would be to make it completely black, and then put alpha on the final result.
[/quote]
That`s what is was trying, except not rendering to a texture, but using the stencil. My pixel shader for the shadow simply returns black.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement