Rain Again

The task is simple – add some kind of detail (PBR) in the rain. So this we have from the start.


Add a special option for materials to get wet (wood, asphalt and other rough surfaces become darker when it’s raining)


Change the ground shader, underfoot the same bare ground.


Slate in the rain becomes wet and darker but obviously  not shine as a metal.

float4 position_with_offset = float4( view_space_position + normal * 1.3f, 1.0f );
float4 projected_position = mul( view_to_shadow, position_with_offset );
float rain_mask = saturate( read_rain_mask( projected_position ) ); // rain mask, where rain effect visible
float roughness = gb.roughness;
float fresnel = gb.fresnel;
float metalness = saturate( ( dot( fresnel, 0.33 ) * 1000 - 500 ) );
float porosity = saturate( ( roughness - 0.5) / 0.1 );
float factor = lerp( 0.1, 1, metalness * porosity );
float3 to_eye = -view_space_position;
diffuse_result *= lerp ( 0.85, ( factor * 5 ), rain_mask );


Add some details and dof. Perhaps that’s it.


rain_1 rain_5




Looks better and this is well.

In-game result with tone mapping.

Different decals depends on smoothmap

When it’s raining we need to have a different drops depends on material. To do this we can use the smoothmap to control surface, more smoother surface we have, more differen drops we will have.

PuddleSmooth1 PuddleSmoothMap

This is the result without smoothmap using. We see the same type drops everywhere.


Here we set the smoothmap to to determine where surface is rough and where no. Also we need to make a dual texture.



And here is the finished result, now we can see that on the asphalt we have own drops and on the puddle own.