Sign in to follow this  
ThiEF_Jr

Decal and Per-Pixel Lighting

Recommended Posts

Hi all Im writing engine for render with Per-Pixel Lighting technique. But i have some proble. How can i draw decal in my engine. I render decal by draw a quad lie on target surface and adjust Z-Bias for eliminate z-fighting problem. It work on scene without lighting. If i want draw decal with lighting i must - Render Scene with ambient - Render Decal with ambient For all lights - Draw Shadow Volume - Draw Scene with light End For all light - Draw Shadow Volume - Draw Decal with light End. ....... It's mean i must draw shadow volume 2 time !?!?! Have any better solution for my problem ? Thx for reply :)

Share this post


Link to post
Share on other sites
Um... I'm not sure why decals would justify their own entirely different pass. Is there any resons why you can't simply do it like this?

- Render Scene with ambient
- Render Decal with ambient

For all lights
- Draw Shadow Volume
- Draw Scene with light
- Adjust Z-Bias + other Decal specific settings
- Draw Decals with light
End

Although, now that I think about it, Shouldn't the shadow volume rendering come LAST? The shadow volume has no visible geometry by itself, it only exists to shade the geometry that's already been rendered. That MAY be why you felt you had to draw it twice: because the first pass was having no effect?

So in the end I think it SHOULD be:

- Render Scene with ambient
- Render Decal with ambient

For all lights
- Draw Scene with light
- Adjust Z-Bias + other Decal specific settings
- Draw Decals with light
- Undo Z-Bias, etc...
- Draw Shadow Volumes
End

Share this post


Link to post
Share on other sites
Decals are tricky to get lit, shadowed and fogged correctly. There are some details of how I do it in my dev journal linked below.

Share this post


Link to post
Share on other sites
Quote:
Original post by Toji
Although, now that I think about it, Shouldn't the shadow volume rendering come LAST? The shadow volume has no visible geometry by itself, it only exists to shade the geometry that's already been rendered. That MAY be why you felt you had to draw it twice: because the first pass was having no effect?

That's how it was done 3 years before when shadows were darkening the scene, instead of lights lighting the scene ;)
Now we want to hilight only what the light can see, which means everything that is out of the shadow volumes. That's why the shadow volume must be rendered first.

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