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.

Monday, 28 March 2016

Shader and Cubemap

ShaderFX to me is different to some of the other shaders I'm more used to. The results are always strange which makes me wish I tried doing this in Unity and creating it using CG code which I have a little knowledge of.

I did try a mess with the idea of using to use the Substance plug-in for Maya and released it would most likely not work as well as I would want and might need a few more tweaks to get it working.

I began to learn a lot about how to get something looking better inside of ShaderFX, I created the shader as the last week results were not what I wanted.I also added an ambient light and directional light to the scene to help stop that darkening of the material when I rotate around the scene.
After re-creating the shader I had something that would now transition between dry and a snow state.


Material Dry State

Material Snow State

New Shader for the Material.

Now that I had the basic material change from dry to snow now it's time to do the water. I went around and created a reflection map (cube map) so that when the water comes into play you would see a reflection of an environment, just to help bring the realism and not just have it a color and look a little odd for this project. 

Reflection Cube Map

Cubemap

The cube map took me a while to figure out because it had to be in a dds file format and I had never done that before so I had to use a NVIDA plug in to create this. I also did try a AMD Cubemap gen tool as well but I wasn't getting the results I wanted from that. 

After I had worked out how to create this I then went onto creating the additional lerp to bring in the water as well.  
I also brought in an additional height map so that the transitions would look different from how each of the textures come into the brick. 

Updated shader with additional Lerp

Around this time I was beginning to worry as some other modules were becoming demanding but I also have been having so many issues with how the shader is looking for this material transition that I've gone over longer than I wanted to with creating this texture.

Though I added the new lerp it was creating some bad artifacts, for example now the texture had black spots. 

These would only ever go away when I brought in the water, however all that did was change the color of the snow and if I took the snow away the water wouldn't stay.

Black spots go when water lerp is set to more than or equal to 1.

When the snow lerp is set to 0 even the water goes.




Sunday, 20 March 2016

Creating the Material

This week I wanted to get started on the material/shader for this project to create the snow and water weather effects.
The plan is to use ShaderFX as mentioned before because the node based system seemed pretty easy to use and the previous experience from Unreal's Shaders should help me.

To get a better understanding of how ShaderFX works I decided to watch a few videos to get a brief overlook.




After I watched this I went about to think about making the shader.
As I had limited time to do this I planned on using some of my own textures and texture I found from elsewhere just because I don't have the time to make the textures all themselves.

This texture was created and found by the people at Game Textures which can be found and downloaded at https://share.allegorithmic.com/libraries/31


This snow texture was created by myself. 

As for the water, I was just going to have that as a simple vector color which would be black with a tint of blue and make sure my roughness was pretty high to get reflective water.

I began working on the shader and exposing parameters so in the future I could drive them in the code later on. 


ShaderFX only works with Viewport 2.0 and for some reason the rendering gave of an odd effect and the shader really needed some work as I wasn't getting the effect I wanted and I am not sure why it wasn't doing that because I've done shaders before and this is normally the way to do it. I also tried another way but I couldn't get the look I wanted. When you would rotate the camera you would the texture would just go....black.


I was also having issues on getting the snow to look the way I wanted. When the material transition to it being snowing, it would brighten up the texture giving it an ugly effect and it wouldn't cover the entire material.

I tried making 2 other shaders to see other ways of making it though I had the same problems.



I began thinking of other ways I could achieve this, first i was wondering if I could switch to Unity and try and create something in that engine and using C# and/or CG to create the shader to get it working.
I also looked at using the Substance Designer plug-in for the project with can run in Maya though I wasn't 100% sure how I could call the functions inside of Python.
After looking at some talks from GDC I think it somehow is possible but there isn't any documentation for it, I couldn't even find much in regards to making this effect in Unity, the only ones I found were in Unreal Engine.
Later this week my hard-drive choose to delete most of my university work. Lucky enough I manage to recover a lot of the modules and I manage to get the textures back however my scene for Scripting & dynamics was gone so I would have to re-create the material. 
It also didn't help that this week I was ill and didn't get as much done because of that.

The next week I'm going to try to either make a better shader using the ShaderFX or try using the Substance plug-in and to use the Substance Designer to make the material transition and expose paramaters that I could hopefully change via Python