Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Closed] Opacity Mask Shadow with Pixel Depth Problem


I'm trying to achieve the same result of Uncharted 4 with the foliage so that the camera doesn't clip with it. I did a material with a pixel depth node (even try the perInstanceFadeAmount with a different problem). The result I want is there as the foliage is dithering as the camera get close but the problem is there's no shadow. As soon as I remove the pixel depth part the shadow is there? Is there a problem with using pixel depth and the shadow pass of the directional light?

the third image is the material function with the pixel depth and I multiply that to the opacity mask of the foliage

alt text alt text alt text

Any idea on the problem?


Product Version: Not Selected
dithering.jpg (69.3 kB)
shadownoshadow.jpg (91.4 kB)
pixeldepth.jpg (73.9 kB)
more ▼

asked Jul 13 '16 at 07:40 PM in Rendering

avatar image

Answers.Archive STAFF
1.8k 189 298 661

(comments are locked)
10|2000 characters needed characters left

The question has been closed Jul 13 '16 at 07:47 PM by AndrewHurley for the following reason:

The question is answered, right answer was accepted

1 answer: sort voted first

It seems like the shadow depth pixel shader is also multiplying the opacity mask by the pixel depth from the point of view of the light, and this is completely clipping the shadow away.

Instead of modifying the opacity mask, if you use the pixel depth to say tint the foliage a different color, does that work with the shadows? If so we'll have to find a way to exclude the pixel depth addition for the shadow depth pixel shader.

  • Jack

more ▼

answered Jul 13 '16 at 07:41 PM

avatar image

Answers.Archive STAFF
1.8k 189 298 661

avatar image Answers.Archive STAFF Jul 13 '16 at 07:41 PM +

You can add a Custom node to your material with the text "IsShadowDepthShader()" in it. That will return 1 when rendering shadow depths and 0 otherwise. You should only apply your pixel depth fade when not in the shadow depth pixel shader.

FWIW that function is defined in Common.usf and is declared like this, and seems to have been added to solve this exact problem:

 // Experimental way to allow adjusting the OpacityMask for shadow map rendering of masked materials.
 // Can be accessed with a Custom material node. If this turns out to be very useful we can expose as MaterialFunction
 // and potentially expose other queries as well (e.g. SkeletalMesh, HitProxy, ).
 // @return 0:no, 1:yes
 float IsShadowDepthShader()
     return 1;
     return 0;
avatar image Answers.Archive STAFF Jul 13 '16 at 07:41 PM

Great it works! Thanks!

(comments are locked)
10|2000 characters needed characters left

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question