JonathanBarrett92 / GE1-2020-2021

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DT228/DT211/DT282/DT508 Games Engines 1 2020-2021

Video

Resources

Contact me

Previous years courses

Assessment Schedule

  • Week 5 - CA proposal & Git repo - 10%
  • Week 13 - CA Submission & Demo - 40%

Week 2 - Trigonometry & Co-routines, materials & shaders

Lab

  • Become familiar with Unity
  • Use trigonometry and the unit circle to make a generative thing
  • Modify a shader

Instructions

This is a screenshot of the first part of what you guys can make today:

Mandala

And this is a video of part two, which involves modifying a shader to generate the colours:

Video

  • First make sure your fork is updated so you get the latest branches from the upstream.
  • Switch to the lab1starter branch:
git checkout lab1starter

Part A

  • Open the scene trigscene and check out the hierarchy and the position and orientation of the camera & the generator.
  • Add a new script to the Generator gameobject called Generator
  • Add public fields for rings - the number of rings to create and for the prefab to use.
  • Drag the prefab from the project onto the field in the Unity editor
  • Now here is the challenge! Write code in the Start method to instantiate instances of the prefab in rings, centred at 0,0,0 on the X-Y plane This will be a nested for loop. But I suggest you try and create one ring first (in a loop) and then enclose that loop in an outer loop to create multiple rings.
  • You will see that the inside ring had 5 objects and the subsequent rings increase the number of objects so that the spacing on each ring is equal. You can use the circumference of a circle equation to calculate the number of objects each circle should contain.
  • Add a script to the prefab so that it rotates around the Y axis. You should add a field for the rotation speed.
  • See if you can figure out how set colours on each loop so that the colours span the hue colour space from 0-1

Part B

  • Create a material called ColorMaterial and assign the shader Custom/ColorShader to the material.
  • Assign the material to the prefab by dropping it on the prefab.
  • Open up the file ColorShader.shader and look for the function void surf (Input IN, inout SurfaceOutputStandard o)
  • You should assign the variable hue to a value between 0 and 1 based on the distance of the vertex from the origin.
  • You have some input variables to work with which are: IN.worldPos.x and IN.worldPos.y (the vertex x and y) and some functions you can use sqrt, pow, abs. And the modulus operator %
  • You can also use the built in variable _Time that gives the time in seconds since the program started. It's a float.
  • If all goes well, you should be able to create the effect in the video.

Week 1 - Introduction

Lecture

Learning Outcomes

  • Install Unity & git for Windows
  • Sign up for the class Facebook page
  • Find the Unity tutorials

Instructions

About

License:MIT License


Languages

Language:ShaderLab 81.2%Language:C# 18.8%