Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 04:46:51 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Shaders: Masking a Directional Light?
Pages: [1]
Print
Author Topic: Shaders: Masking a Directional Light?  (Read 1082 times)
spooky
Level 0
*


View Profile
« on: March 28, 2015, 08:57:46 AM »

So I asked this on Unity Answers and it took 23 hours to get approved by a moderator and then got zero attention before falling off the front page. I'm not sure if this question would be better suited to the Creative board, but I consider it a technical question since the answer likely lies in HLSL.

There is a feature in some engines including Source and the Mental Ray render called a 'Sky Portal' which masks the directional light to a rect/polygon. I'm looking for a way replicate this in effect in Unity.

I'm building old BSP style maps using ProBuilder, and for efficiency and ease of editing I am using only using one-sided geometry in the construction of my maps; however I want to have a shadow-casting directional light which is visible only through windows and an 'exterior' courtyard's open sky. Currently this causes wrong lighting because back faces do not cast shadows, as expected.

I had an idea about how this might work, but I don't know enough about shaders or how rendering works to implement it. Basically I need to flip the shadow map so that by default the entire directional light is occluded. The sky portal object could then have a special shader which causes it to cast an 'anti-shadow' which would then be shadowed normally by the objects in the scene.

Any suggestions?
Logged
Will Vale
Level 4
****



View Profile WWW
« Reply #1 on: April 01, 2015, 08:30:09 PM »

I think you can fix this by using a shadow casting directional light, but turning off back face culling when drawing the shadow map.

HTH

Will
Logged
Will Vale
Level 4
****



View Profile WWW
« Reply #2 on: April 11, 2015, 02:01:36 PM »

Ticking that box makes Unity do what I suggested (render double sided == turn off backface culling) - cool that they made it so easy though!

W
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic