Transmission Shader for Window Panes

User avatar
acornbringer

PostSun Aug 06, 2017 6:22 pm

Hello!

I'm creating a shader to emulate the transmission of light through different colored and different opacity window panes. Right now I have a color texture atlas of various windows along with a black and white version of the texture to use as a gloss and transmission map so I can stop gloss and transmission from effecting arias of the map like the muntins and grunge on the windows. The effect looks pretty good right now but I'm not sure how to approach more specific features of the shader I would like to have.

- The first thing I'm unsure about is if It's possible to have transmission working with transparency. It would be nice to have some of the windows somewhat transparent instead of completely soled. As far as I can tell, having opacity on the shader disables the transmission.

- Something else I'm wondering about is a more accurate way to create transmission. In other examples I have seen of the effect (forst's Advanced Foliage Shader and Lux), the transmitted light changes depending on viewing angle. For example, the effect on the object's surface will be stronger if the light source is directly behind the object in between the camera but will lessen as the camera moves to an angle. However, with my current shader, if I have a quad with transmission and a sun directional light, the effect on the surface of the quad will seem just as strong from an angle as it is if I'm looking at the sun through the object.

- Another thing I'm curious about is if it's possible to have shadows cast through the glass be effected by the texture maps. So instead of a big square shadow, the shadow could show the glass colors and bits the light shouldn't pass through. What I have now is a duplicated object with an opacity clip material that just shows the window muntins with out the glass but it would be cool to have the glass color effect the shadow as well.

I look foreword to any incite on these questions! Thanks :)
User avatar
acornbringer

PostMon Aug 14, 2017 11:43 am

Hi again!

I spent a little while looking into getting shadows to show up on transparent materials and discovered that it's not something being supported by Unity. Also, I noticed that with most examples I found from other games, they don't seem to support that functionality either. I've seen it done with water shades before but there's probably a lot more going on with that than just a single material shader - like maybe a screen post-effect. I suppose if I ad transparency and refraction to the shader, nobody will notice if shadows aren't appearing on the surface. However, one of my goals with this shader was to have shadows transmitting to the other side.

I'm still curious about how it might be possible to get the effect I mentioned in my last post for the transmission so it considers the camera angle to the directional light. If anyone has incite on that or any of my points, I'd be happy to hear from you!

Thanks :)
User avatar
acornbringer

PostTue Nov 14, 2017 6:47 pm

Been a while since last posted this but I figured I would update it in case anyone is curious.

If I create a shader with Alpha Blended blending but change the sort order to Opaque Geometry (2000), I will have a transparent shader that accepts shadows.

It seems a little janky so I'm not sure what the repercussions are for using a shader like this but its the closest I've gotten to getting this to work.
User avatar
nuFF3
Location: Hell

PostTue Nov 14, 2017 9:49 pm

If you want transparency and shadows you'd have to do it through multipass, but since shader forge does not support multiple passes; you have to use rendertextures.

Create another camera, name is "transparency camera" or something, have it be a child of your main camera.
Create a new 'rendertexture', make sure the 'rendertexture' is in the same aspect ratio as your final renderer (doesn't need to be the same resolution).
Hook the 'rendertexture' up to your new "transparency camera".
In your shader, create a 'texture2d' node, name it "transparency" or something.
Create a 'Screen Position' node, set it to 'Scene UV', hook that up to your "transparency" 'texture2d' node's UV inputs.
Now you have a transparent material that has the ability to receive shadows.
User avatar
acornbringer

PostWed Nov 15, 2017 11:23 am

nuFF3 wrote:Now you have a transparent material that has the ability to receive shadows.


Excellent! Thanks for the outline :)
I'll have to give this a shot next time I get back into my window shader.

Return to “Questions”



Who is online

Online users: No registered users and 1 guest