Thursday, 31 March 2016

Shader Fix & Weather Particles

As I wasn't getting any good results I began to search out shader blending modes from Unreal Engine to see how someone would go and blend together 3 materials together as I clearly wasn't getting any good results from my method and couldn't figure out why.

Unreal Engine 4 3-Way Material Blend

Using this method I went ahead and began to do the same way inside of using ShaderFX.
As I was using a texture blend through the linear interpolate rather than the vertex color I just made sure that was wired up the right way.

New Shader Blend using the 3-Way UE4 Material Blend

When I went to check if it worked I realized at this time the cubemap I had created I had left back on the computer at home when I was working on this testing. I did some more research into the reflection node using the Maya documentation and then found out that I could use a texture rather than a dds cubemap, wish I had found that out before I spent hours trying to work out the dds cubemap.
With the texture reflection map I could use a node called "Spherical Reflection UV" which would turn the texture into a reflection sphere.
I went onto the internet and found a jpeg for a HDRI image. I went for something which was a forest snow.

New Reflection set-up

 With the forest sky that I found, I released that when I had put it into Maya that the way I want the reflection was upside down, so if I look down at the texture the HDRI forest ground was reflection back rather than the canopy of the tree branches above. I went into Photoshop and made sure I flipped the Y axis to get the desired effect.

Forest Sky used before flipped in Y-Axis.

The next part in the shader was now to get a good enough blend going on with the snow and also with the rain.
In the past week or so I had some issues with getting the blend to come out nice, when I made a height map for the water it had a odd part which made the material just have black spots in part which was shown in the previous blog post.

I felt comfortable that the snow had a nice enough blend with it however with this new shader linear interpolate set up I just had to make the I used a invert one-minus node to bring in the blend correctly.

With the water I had more shader math so the blend came in using a height from the brick which was a different version I used for the snow blend. I then used a grunge noise from Substance Designer to add more to the water blend.
I then made sure to clamp the values so I didn't have any odd artifacts show up.

Top - Snow Blend | Bottom - Water Blend

After a few tests and changing some things the blend worked well. I then went ahead and exposed tons of values I would want to change through code or give the user (and lectures) the ability to change values without having to go into the shader itself to find it.
This also needed to be done because when this is handed in the chances of the textures even being linked is unlikely and the set person would have to set the link up with the texture again.
I also went and created a UV scale on which was multiplied with a float so I or a user could change the UV scale of the brick and water puddles.

Snow Transition


Water Transition

The next thing to do now was to create the particles themselves to show what weather the environment is in.
Firstly I started of with the rain. I used nDynamics for this and with the nParticles I set it to points. I then duplicated the floor tile texture and brought it above the floor material and then flip it and used emit from object surface.
For the rain I went down into the shading part of the nParticle and set points to streaks so it looks more like rain.
I then changed the floor with a passive collider and and gave it some bounce so when the rain hit it the water would bounce the drip as it would in real life.
I also had to go ahead and change the emitter particle rate because as default I set it to around 300 and it looked like to much rain to me and after a while the PC began to slow. To reduce the change of this happening I set it to 100 and made sure that when the rain did it bounce after a second or two it would then kill the particle.

Rain Particle

When it came to the snow I again used the points and did the same with the floor plane with making a duplicate, rising it above the floor itself, flipping it and having the particle emit from its surface.
I then went into the shading and change the points to sprites.
As I wanted a texture on the snow I looked through all the tabs in the emitter to change it to a gradient ball however, after searching each tab I couldn't find a way of adding a texture.
I then went to Google and in the past it was under the shading tab though now it wasn't there and I was unsure why that was the case. I even looked in other parts of the emitter but still had no luck.
After giving up trying to find it I thought of using my own method and going into the Hypershader, making a new Lambert and adding the gradient ball with its transparency and dragging it onto the snow emitter and voila! It applied the texture and I had my snow.
To get the transparency working I had to make sure the use lighting check box was ticked.
With the snow I also adding more variants to the lifespan of the snow, using a random range so that some of the snow could fade before it even hits the ground.
I also tried to make it look more like snow too with how the wind would effect it and how chaotic snow falling can be, however, it still seemed very uniform.

Snow Particle

Though I still wanted to get the snow looking a lot better, I thought that getting onto the scripting was now more important and I could do additional tweaks to the particles nearer the end if I have the time. The plan was also if I get the time also to have a small environment and maybe some different materials which have the same changes.

No comments:

Post a Comment