UE4 Intro To Materials - Page 9


Index



Lamp Material


  1. Now lets create a new material for the lamp. Let’s make it a master material and make an instance for the lamp proper. Create a new Material in the Materials folder and call it M_Spotlight_Lamp_Master.
Create new sprite with button

  1. Now double click the newly created Master Material and:
  • Add 4 Texture Sample Parameter 2D nodes
  • Call them Diffuse Texture, Metallic Mask, Roughness Mask, Normal Mask.
  • Group them accordingly
  • Connect each to the Base Color, Metallic, Roughness and Normal nodes on the master node.
  • Press Apply and Save
  • Go to game and assign the newly made material
  • Press the F key and check out your newly imported model with it initial material pass
Create new sprite with button

  1. Now go back to the Material and add another Sample Textue Parameter 2D and assign M_Spotlight_AO. Call the group AO. Attach the node to the AO node.
Create new sprite with button

  1. Add another Sample Texture Parameter 2D, call it Emissive, assign T_Spotlight_I and add an appropriate group name. Connect the output pin to the Emissive Color input on the main Material node.
Create new sprite with button

  1. Go into the game and look at the front of the light. See that it glows.
Create new sprite with button

  1. Now illumination on a bright light source like a stage light gets very bright. And in Unreal to have a real bloom on the light you need a value higher than 1. Lets Add a Scalar Parameter and call it Illumination Scalar that can be adjusted and multiply the mask. Set the default to 6 and connect the nodes:
Create new sprite with button

  1. Now go to the game and light bulb is now even brighter. Now you notice that it doesn’t cast a light as this is not an in game light it just reflects the emissive qualities in the material.
Create new sprite with button

  1. Lets parent Base Lamp to the Bracket. This way moving the Bracket parent will move the base with it. This will stop up from accidentally separating the model. Wherever the bracket goes the lamp follows.
Create new sprite with button

  1. Now go to the Place mode in the main menu and select Lights. Drag a Spotlight and place it over the lamp in the scene:
Create new sprite with button

  1. Parent the spotlight to the Lamp. This way when you move the bracket it will move all the geo and light and leave them in the right spot.
Create new sprite with button

  1. Now click on the newly created spotlight in the scene and click on it. You should see the rays and they don’t match the light. They point straight down. Lets fix this.
Create new sprite with button

  1. Use the Rotation tool to position the light to match visually. Also use the Translate tool to make sure it is located in the middle of the light.
Create new sprite with button

  1. Since we have the game in full daytime with no interiors lets shade this area a bit. Go to StaticMeshes | Supplied and drag and drop **SM_Outside_Wall_EW and rotate it to be on the ceiling above the lamp in room 4 like so:
Create new sprite with button

  1. Go into Top view and adjust it it place so it is perfectly aligned in the corner.
Create new sprite with button

  1. Go to Materials | Supplied and add drag and drop the M_Vasic_Wall material over this ceiling piece in the level.
Create new sprite with button

  1. Name the new static mesh and put it in the appropriate folder in the World Outliner. Prss the Build button re rebuild the lighting.
Create new sprite with button

  1. Play the level and look at the light cast in the game.
Create new sprite with button

  1. Now what if I want to create another lamp but change the color to red. What would I do? First we need a variable to change the color of the emissive light source. So add a Vector Parameter to the M_Spotlight_Master material:
Create new sprite with button

  1. Now add another Multiply Node. Connect the output of the first multiply into A of the second. Output the newly created Vector Paramter into the B node. Output the second multiply into the Emissive node of the master material node:
Create new sprite with button
  1. Call this node Spotlight Color and put it in group Emissive.
Create new sprite with button

  1. Now go back to the Content Browser and right click on M_Spotlight_Master and select Create Material Instance. Call it MI_Spotlight_Red:
Create new sprite with button

  1. Double click this new material instance and adjust the color to a nice shade of red:
Create new sprite with button

  1. Now go back to the game. Select the Bracket, Lamp and Light in the World Outliner. Now we can easily make a copy by press alt (option on the mac) and dragging the transltation arrow. This will make a copy. Then assign the newly created MI_Spotlight_Red to this copy. Then look at it. Oh, the glow has changed but not the light. Go to the newly created spotlight and in the Details panel change the Light Color to red.
Create new sprite with button

  1. Now run in game and look at your two lights!
Create new sprite with button

  1. That is it for this room. Lets Save All, Build the lighting and open GitHub Desktop. Commit the last set of changes and push them to the server. We are now done with room 4!
Create new sprite with button



<- Previous   Home    Continue ->