Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Lab 11 Report.docx
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab 11/Assets/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11/Assets/Materials/RimMaterial.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 11/Assets/Materials/RimMaterial.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11/Assets/Materials/RimMaterial1.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 11/Assets/Materials/RimMaterial1.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab 11/Assets/Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11/Assets/Scenes/MainScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 11/Assets/Scenes/MainScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab 11/Assets/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions Lab 11/Assets/Shaders/RimShader.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// RimShader.shader
Shader "Custom/RimShader"
{
Properties //Properties block that the user can adjust
{ //Interfaces with Unity Inspector
_Color("Color",Color) = (1.0, 1.0, 1.0, 1.0)
_SpecColor("Specular Color", Color) = (1,1,1,1)
_Shininess("Shininess", Float) = 10
_RimColor("Rim Color", Color) = (1,1,1,1)
_RimPower("Rim Power",Range(0.1,10)) = 3.0
}
SubShader
{
Pass
{
Tags{ "LightMode" = "ForwardBase" }

CGPROGRAM
#pragma vertex vertexProgram
#pragma fragment fragmentProgram

//user defined variables
uniform float4 _Color;
uniform float4 _SpecColor;
uniform float _Shininess;
uniform float4 _RimColor;
uniform float _RimPower;

//Unity defined Variables
uniform float4 _LightColor0;

struct vertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};

struct vertexOutput
{
float4 pos : SV_POSITION;
float4 posWorld : TEXCOORD0;
float3 normalDir : TEXCOORD1;
};

vertexOutput vertexProgram(vertexInput input)
{
vertexOutput output;

output.posWorld = mul(_Object2World, input.vertex);
output.normalDir = normalize(float3(mul(float4(input.normal, 0.0), _World2Object).xyz));
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);


return output;
}

float4 fragmentProgram(vertexOutput input) : COLOR
{
float3 normalDirection = normalize(input.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - float3(input.posWorld.xyz));

float3 lightDirection;
float attenuation = 1.0;
lightDirection = normalize(float3(_WorldSpaceLightPos0.xyz));

//Lighting
float3 ambientLight = UNITY_LIGHTMODEL_AMBIENT.rgb;

//Lighting - Diffuse
//This is one line or multiple lines. If you prefer it one-line, delete the uncommented lines.
//If you prefer it multiple lines, delete the commented lines
//~~~~~~~~~~~~~~~ ONE-LINE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//float3 diffuseLighting = attenuation * float3(_LightColor0.rgb) * max(0.0, dot(normalDirection, lightDirection));

//~~~~~~~~~~~~~~~ MULTIPLE LINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float3 diffuseLighting = dot(normalDirection, lightDirection);
diffuseLighting = max(0.0, diffuseLighting);
diffuseLighting = float3(_LightColor0.rgb) * diffuseLighting;
diffuseLighting = attenuation * diffuseLighting;

//Lighting - Specular
//This is one line or multiple lines. If you prefer it one-line, delete the uncommented lines.
//If you prefer it multiple lines, delete the commented lines
//~~~~~~~~~~~~~~~ ONE-LINE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//float3 specularLighting = max(0.0, dot(normalDirection, lightDirection)) * attenuation * float3(_LightColor0.rgb) * float3(_SpecColor.rgb) * pow(max(0.0, dot(reflect(-lightDirection, normalDirection), viewDirection)), _Shininess);

//~~~~~~~~~~~~~~~ MULTIPLE LINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float3 specularLighting = reflect(-lightDirection, normalDirection);
specularLighting = dot(specularLighting, viewDirection);
specularLighting = max(0.0, specularLighting);
specularLighting = pow(specularLighting, _Shininess);

//This controls the colouring of the specular light,
//As well as stopping it from going to the backside of the object
//AND adding the specular lighting falloff.
float3 specularColouring = dot(normalDirection, lightDirection);
specularColouring = max(0.0, specularColouring);
specularColouring = attenuation * specularColouring;
specularColouring = float3(_SpecColor.rgb) * specularColouring;

specularLighting = specularColouring * specularLighting;

//Rim Lighting
float3 actualRim = 1 - saturate(dot(normalize(viewDirection), normalDirection));
float3 rimLighting = attenuation * _LightColor0.rgb * _RimColor *
saturate(dot(normalDirection, lightDirection)) * pow(actualRim, _RimPower);

//Final Lighting
float3 finalLight = rimLighting;

//Test Lighting

return float4(finalLight, 1.0);
}

ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Lab 11/Assets/Shaders/RimShader.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions Lab 11/Assets/Shaders/RimShader1.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// RimShader1.shader
Shader "Custom/RimShader1"
{
Properties //Properties block that the user can adjust
{ //Interfaces with Unity Inspector
_Color("Color",Color) = (1.0, 1.0, 1.0, 1.0)
_SpecColor("Specular Color", Color) = (1,1,1,1)
_Shininess("Shininess", Float) = 10
_RimColor("Rim Color", Color) = (1,1,1,1)
_RimPower("Rim Power",Range(0.1,10)) = 3.0
}
SubShader
{
Pass
{
Tags{ "LightMode" = "ForwardBase" }

CGPROGRAM
#pragma vertex vertexProgram
#pragma fragment fragmentProgram

//user defined variables
uniform float4 _Color;
uniform float4 _SpecColor;
uniform float _Shininess;
uniform float4 _RimColor;
uniform float _RimPower;

//Unity defined Variables
uniform float4 _LightColor0;

struct vertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};

struct vertexOutput
{
float4 pos : SV_POSITION;
float4 posWorld : TEXCOORD0;
float3 normalDir : TEXCOORD1;
};

vertexOutput vertexProgram(vertexInput input)
{
vertexOutput output;

output.posWorld = mul(_Object2World, input.vertex);
output.normalDir = normalize(float3(mul(float4(input.normal, 0.0), _World2Object).xyz));
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);


return output;
}

float4 fragmentProgram(vertexOutput input) : COLOR
{
float3 normalDirection = normalize(input.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - float3(input.posWorld.xyz));

float3 lightDirection;
float attenuation = 1.0;
lightDirection = normalize(float3(_WorldSpaceLightPos0.xyz));

//Lighting
float3 ambientLight = UNITY_LIGHTMODEL_AMBIENT.rgb;

//Lighting - Diffuse
//This is one line or multiple lines. If you prefer it one-line, delete the uncommented lines.
//If you prefer it multiple lines, delete the commented lines
//~~~~~~~~~~~~~~~ ONE-LINE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//float3 diffuseLighting = attenuation * float3(_LightColor0.rgb) * max(0.0, dot(normalDirection, lightDirection));

//~~~~~~~~~~~~~~~ MULTIPLE LINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float3 diffuseLighting = dot(normalDirection, lightDirection);
diffuseLighting = max(0.0, diffuseLighting);
diffuseLighting = float3(_LightColor0.rgb) * diffuseLighting;
diffuseLighting = attenuation * diffuseLighting;

//Lighting - Specular
//This is one line or multiple lines. If you prefer it one-line, delete the uncommented lines.
//If you prefer it multiple lines, delete the commented lines
//~~~~~~~~~~~~~~~ ONE-LINE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//float3 specularLighting = max(0.0, dot(normalDirection, lightDirection)) * attenuation * float3(_LightColor0.rgb) * float3(_SpecColor.rgb) * pow(max(0.0, dot(reflect(-lightDirection, normalDirection), viewDirection)), _Shininess);

//~~~~~~~~~~~~~~~ MULTIPLE LINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float3 specularLighting = reflect(-lightDirection, normalDirection);
specularLighting = dot(specularLighting, viewDirection);
specularLighting = max(0.0, specularLighting);
specularLighting = pow(specularLighting, _Shininess);

//This controls the colouring of the specular light,
//As well as stopping it from going to the backside of the object
//AND adding the specular lighting falloff.
float3 specularColouring = dot(normalDirection, lightDirection);
specularColouring = max(0.0, specularColouring);
specularColouring = attenuation * specularColouring;
specularColouring = float3(_SpecColor.rgb) * specularColouring;

specularLighting = specularColouring * specularLighting;

//Rim Lighting
float3 actualRim = 1 - saturate(dot(normalize(viewDirection), normalDirection));
float3 rimLighting = attenuation * _LightColor0.rgb * _RimColor *
saturate(dot(normalDirection, lightDirection)) * pow(actualRim, _RimPower);

//Final Lighting
float3 finalLight = (rimLighting + ambientLight + diffuseLighting + specularLighting) * float3(_Color.rgb);

//Test Lighting

return float4(finalLight, 1.0);
}

ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Lab 11/Assets/Shaders/RimShader1.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11/ProjectSettings/AudioManager.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/DynamicsManager.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/EditorSettings.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/InputManager.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/NavMeshAreas.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/NetworkManager.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/Physics2DSettings.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/ProjectSettings.asset
Binary file not shown.
2 changes: 2 additions & 0 deletions Lab 11/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m_EditorVersion: 5.1.2f1
m_StandardAssetsVersion: 0
Binary file added Lab 11/ProjectSettings/QualitySettings.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/TagManager.asset
Binary file not shown.
Binary file added Lab 11/ProjectSettings/TimeManager.asset
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab 11B/Assets/Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11B/Assets/Scenes/MainScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 11B/Assets/Scenes/MainScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab 11B/Assets/Scenes/OnYourOwn.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 11B/Assets/Scenes/OnYourOwn.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab 11B/Assets/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading