Jump to content
  • Advertisement
Sign in to follow this  
Neutrinohunter

Shadow Mapping Transparency (Making Shadows Not As Black)

This topic is 3894 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've noticed particularly in the latest methods of Shadow Mapping, (CSM,PSSM, TSM etc) that they can seem to blend the shadow map with the surrounding environment and I wondering how it is done. For geometry based methods, you just set the transparency of the geometry you want to run at a certain amount and set up the approriate blend functions, but I am assuming this doesn't work with Image Based methods. If this is incorrect, please enlighten me :) I couldn't find much on the internet about it,except that most demos that I see that people have created the shadow is always pitch black. I'm not using shaders for my current shadowing mapping implementation because the station I'm working on doesn't support shaders that well and I can't program in Shaders yet :P Thanks, Neutrinohunter

Share this post


Link to post
Share on other sites
Advertisement
Thats weird, I was using them all ready. I've read that spec and it doesn't mention anything, about when the texture comparison passes or should it be failing I'm looking at *scratches head*

When R > D where D is the stored value and R is the distance from the light, the pixel is shadowed, therefore aren't I using the opposite test?

Oh I solved the artefact problem which we discussed in an earlier topic, the problem was caused by shadow leakage and that I wasn't using radians for a call to tan() :). Now it looks fine, except for the transparency I think.

I should also mention that I fixed the FBO problem as well, which was a problem with a float to int conversion which I and the debugger missed :O

Looking over Pauls tutorial at paulsproject.net, it does look like I've made a mistake. I'll have a look over it, so far I get an image like this:



Neutrinohunter

[Edited by - Neutrinohunter on February 17, 2008 7:41:43 PM]

Share this post


Link to post
Share on other sites
Well, as far as I know about this extension, you need to set light parameters (I presume you've set them) - ambient (I think it has to be non-zero), diffuse, etc.
...

For shadow mapping you've to call this:

// Set compare mode for shadow mapping hardware
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
// We're gonna pass when it's less or equal (so we'll fail, whern it's greater)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);

// When we'll fail, we're gonna set 0.5f as shadow ambience lighting
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.5f);

Anyway dunno how it's when you've got just color and no textures (I tested that just with textures), so this could be in that (but I don't know that surely).

Share this post


Link to post
Share on other sites
Mmm, thats strange. Thats exactly what I'm doing Vilem, weird. I do have a GL Invalid Enumerant Error which could be the problem, I'll look into the lighting, I do have ambience and diffuse set up I'm sure.

Thanks
neutrinohunter

Share this post


Link to post
Share on other sites
I have the above. Is this needed?

glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);

Am setting the lighting as such:


GLfloat ambience [] = {0.4, 0.4, 0.4, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, ambience);
GLfloat diffuse [] = {0.4,0.4,0.4, 1.0};
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
GLfloat specular [] = {0.3,0.2,0.3, 1.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);



Are there any other lighting operands which need to be called? And thanks Vilem, you have been fantastic with all your help so far. Hows the paper coming along?

Neutrinohunter

Share this post


Link to post
Share on other sites
Maybe I've got something - just played a little with GL_ARB_shadow and GL_ARB_shadow_ambient (and with SGIX variants!). There are 2 errors, which I found:

1) You can't combine GL_ARB_shadow and GL_SGIX_shadow_ambient, or GL_SGIX_shadow and GL_ARB_shadow_ambient.

2) This is important, you've to set this glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.5f); as glTexParameterf (that "f" in the end is very very important, cause it's telling that value will be float, if you'd use glTexParameteri with "i" in the end it wouldn't work).

EDIT: I presume you've got GL_ARB_shadow_ambient supported by hardware, cause this could make issues too.

Share this post


Link to post
Share on other sites
To that paper - well I've written just several lines, now preparing demo to demonstrate effect of PCML shadow maps ;) - anyway I have to work primarily on the engine, I'm writing that paper in my "free-time".

Share this post


Link to post
Share on other sites
PCML Shadows? Never heard of them, I'll google to see if I can find anything on them.

Well I'm using GL_ARB_Shadow, GL_ARB_shadow_ambient and using FBO's to render to.

All of which are supported by my GeForce 6200 GC. My loading of the texture is as such, which seems to work fine but I'm guessing it could be a parameter i'm missing or conflicting?

[source lang="cpp] glGenTextures(1, &ShadowTexture);
//glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, ShadowTexture);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
#if defined(GL_ARB_SHADOW)
std::cout << "ARB Shadow Available" << std::endl;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
#endif

#if defined(GL_ARB_shadow_ambient)
std::cout << "GL_ARB_shadow_ambient Available" << std::endl;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3f);
#endif

std::cout << "Frame Buffer Object Available" << std::endl;
glGenFramebuffersEXT(1, &ShadowFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ShadowFBO);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D, ShadowTexture, 0);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);



Did you test with a texture on the floor? Because I'll change that if thats the case.

Neutrinohunter

Share this post


Link to post
Share on other sites
PCML shadow maps are my algorythm (shortcut = PCMLSM). Anyway I've gotta look on that code....

That code should run properly, I haven't noticed any issues on my Radeon HD 2900 XT with these extensions, could you please send me program (executable for Windows XP - win32, maybe even source, if you're able to send it (email - vilem.otte@post.cz) - can't exactly tell, where could be issue - it was long time ago, when I used just Fixed function and no shaders). Anyway I tested with and without texture, so there souldn't be problem.

[Edited by - Vilem Otte on February 18, 2008 4:04:09 PM]

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!