Fresnel Issue

Hey guys, I’ve got a question regarding reflections. So I’ve been working on setting up some fresnel based sparkles in my grass shader, which is working well, but the sparkles only appear whenever the player character is facing the sun. Is there any way to fix this issue? The sparkle set up is just a fresnel with a scalar value plugged up to the roughness attribute.

Fresnel is just a basic falloff calculation. You’re making the grass less rough, or in a way, “shinier” on the edges. This type of material is not physically correct and probably won’t give you good results.

If you want to simulate grass with water droplets that sparkle, you can do this with a grass texture that has water droplets on it, a roughness map that makes the water have smooth reflections, and a normal map that bulges the light around water droplets, and as a nice finishing touch, a bump offset to all these textures where the droplets are to render water distortion. The only caveat here is you have to make a tradeoff between using a nice subsurface shader for the grass or give a metallic reflection to the water to make it sharper. I’ll see if I can make a mock-up of this.

Before you do that, you must realize that I have plugged up the fresnel to the roughness for a reason: our game is heavily stylized and the material not being physically correct is not an issue whatsoever. There is no need for you to mock up an example.

Screenshot of the material network?

I’m away from my PC right now, but it’s literally just Fresnel multiplied by a scalar parameter and that goes into the roughness slot. I had tried a screen position node added to that small network and it got some of the shininess to work whenever facing away from the sun, but it wasn’t on the scale that I wanted.

Is your grass material on a flat plane? I would suggest modeling grass with bends and curves so it can catch light from more than just one direction. That can help wonders.

1 Like

No, we modeled grass. I didn’t want to post a photo as we’re trying to be a little secretive of our work, but I guess I will anyway.

This is an old photo, but it’ll give the idea of how we’re making our sparkles work. Obviously it’s toned way down now, but you get the point.

That’s really cool! Unfortunately, I’m not really sure what you’re doing to get that, effect, so I can only offer some suggestions on what they problem might be.

There is a possibility it has to do with fresnel not typically accepting two-sided shaders. I forgot how exactly I solved this in UE3, but it had to do with the TwoSidedSign material node and the Normal input of the Frenel function. I won’t be able to solve it right now, but when I have the chance I’ll try to see what the deal is.

OK, sorry, the issue is not what I thought it was. The fresnel calculation now works properly on two-sided materials.

I’m pretty sure the solution is with the screen position node or something similar as I’ve had a small modicum of success with it already. Basically the whole issue is that if you look at the picture I posted, imagine doing a 180 with the character and all the shininess isn’t there because the camera isn’t facing the sun. It’s utterly ridiculous, which is of course why I’m trying to fix it. The problem is that my knowledge of nodes like camera pos, screen pos, absolute world pos leaves much to be desired.

There’s so many ways to achieve this effect. Are you mapping a shimmering texture flat against the screen (like it’s mounted on the camera), and then using a texture mask on the grass to cut it out? Screen Position should map things according to the screen and stays attached to the camera no matter how much the camera moves, so spinning around shouldn’t change anything. World Position will map things using the world vectors and it stays mapped within the world, so spinning around won’t change that either. I’m not sure what camera position is used for, though. Maybe the problem is with that?

I know you’re probably hesitant to share your material tree, but without knowing where the board is, we could be throwing all our darts out the window. If it helps you any, I made a nice shimmering snow effect for a class project using only screen position with a shimmering noise texture and a similar texture mask mapped like a normal texture. This was the solution suggested to make sparkling snow on UDN’s material examples page back with UDK.

854514ef77edb9acc7a400e15de607e3934e6594.jpeg

In the picture showing the grass, the sparkles were done with this set up (minus the screen position node) plugged into roughness. The screen pos node does help when I turn around, it’s just not on the same scale as it is in the earlier picture.