Jump to content

  • Log In with Google      Sign In   
  • Create Account


Deferred decals normal problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Petwoip   Members   -  Reputation: 128

Like
0Likes
Like

Posted 26 February 2013 - 05:39 PM

I've been working on a deferred decal system. So far I have finished the projection part, meaning I can click something in the scene and it will properly project a decal onto the surface of the object.

 

There are a couple other things I wish to add to this system: normal clipping and normal mapped decals. Normal clipping is when I discard fragments that are stretched across a sharp angle. Seen here. A way to solve this is to discard fragments that have a large difference between the normal in the G-Buffer and the decal's normal. This would require reading the G-buffer's normal texture.

 

In order to do decal normal mapping, I need to blend the decal's normal (from a normal map) with the G-buffer's normal. The requires writing to the G-buffer's normal texture.

I hope it's clear that in order to support these two features, I need to read and write to the normal texture in the same shader pass. Sadly, this is undefined behavior, so I'm wondering if there is some other way to implement these features.


Edited by Petwoip, 26 February 2013 - 05:39 PM.


Sponsor:

#2 AgentC   Members   -  Reputation: 1261

Like
0Likes
Like

Posted 27 February 2013 - 06:18 AM

For the normal clipping test, you could copy the normal rendertarget into another texture after the G-buffer geometry pass. It should not be a large performance hit.


Every time you add a boolean member variable, God kills a kitten. Every time you create a Manager class, God kills a kitten. Every time you create a Singleton...

Urho3D (engine)  Hessian (C64 game project)


#3 Hodgman   Moderators   -  Reputation: 28613

Like
0Likes
Like

Posted 27 February 2013 - 07:08 AM

As above, making a copy of the normal buffer to read from, before the decal pass is the most straightforward.

Some other ideas:

* you can read the depth buffer instead, and use ddx/ddy to calculate the change in depth, which can be converted into an approximation of the normal (just the per-triangle-face normal, not the normal-mapped normal).

* you can render your decals in two passes. In the first pass you read from the normal buffer and discard where invalid, but only output to a stencil mask. Then in the 2nd pass, draw your decal again only to pixels present in the stencil mask.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS