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 10 Report.docx
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab 10/Assets/Materials.meta

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

Binary file added Lab 10/Assets/Materials/SpecularMaterial.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 10/Assets/Materials/SpecularMaterial.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 10/Assets/Scenes.meta

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

Binary file added Lab 10/Assets/Scenes/MainScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 10/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 10/Assets/Shaders.meta

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

75 changes: 75 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SpecularShader.shader
Shader "Custom/SpecularShader" { // Basic shader for Lab 10
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_SpecColour("Specular Color", Color) = (1,1,1,1)
_Shininess("Shininess", float) = 10
}
SubShader {
Pass{

CGPROGRAM
#pragma vertex vertexFunction
#pragma fragment fragmentFunction

//user defined variables
uniform float4 _Color;
uniform float4 _SpecColour;
uniform float _Shininess;

//unity defined variables
uniform float4 _LightColor0;

//input struct
struct inputStruct
{
float4 vertexPos : POSITION;
float3 vertexNormal : NORMAL;

};

//output struct
struct outputStruct
{
float4 pixelPos: SV_POSITION;
float4 pixelCol : COLOR;
};

//vertex program
outputStruct vertexFunction(inputStruct input)
{
outputStruct toReturn;
float3 lightDirection;
float attenuation = 1.0;

lightDirection = normalize(_WorldSpaceLightPos0.xyz);

float3 normalDirection = normalize(mul(float4(input.vertexNormal, 0.0), _Object2World).xyz);
float3 viewDirection = normalize(float3(float4(_WorldSpaceCameraPos.xyz, 1.0) -
mul(_Object2World, input.vertexPos).xyz));
float3 diffuseReflection = attenuation * _LightColor0.xyz * max(0.0, dot(normalDirection, lightDirection));
float3 specularReflection = reflect(-lightDirection, normalDirection);
specularReflection = dot(specularReflection, viewDirection);
specularReflection = max(0.0, specularReflection);
specularReflection = max(0.0, dot(normalDirection, lightDirection)) * specularReflection;
specularReflection = pow(max(0.0, specularReflection), _Shininess);
specularReflection = max(0.0, dot(normalDirection, lightDirection)) * specularReflection;
float3 finalLight = specularReflection + diffuseReflection + UNITY_LIGHTMODEL_AMBIENT;

toReturn.pixelCol = float4(finalLight * _Color, 1.0);
toReturn.pixelPos = mul(UNITY_MATRIX_MVP, input.vertexPos);
return toReturn;
}

//fragment program
float4 fragmentFunction(outputStruct input) : COLOR
{
return input.pixelCol;
}
ENDCG
}
}

//Fallback
//FallBack "Diffuse"
}
9 changes: 9 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader.shader.meta

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

75 changes: 75 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader1.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SpecularShader1.shader
Shader "Custom/SpecularShader1" { // Lab 10 Shader for On Your Own #1 (a)
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_SpecColour("Specular Color", Color) = (1,1,1,1)
_Shininess("Shininess", float) = 10
}
SubShader {
Pass{

CGPROGRAM
#pragma vertex vertexFunction
#pragma fragment fragmentFunction

//user defined variables
uniform float4 _Color;
uniform float4 _SpecColour;
uniform float _Shininess;

//unity defined variables
uniform float4 _LightColor0;

//input struct
struct inputStruct
{
float4 vertexPos : POSITION;
float3 vertexNormal : NORMAL;

};

//output struct
struct outputStruct
{
float4 pixelPos: SV_POSITION;
float4 pixelCol : COLOR;
};

//vertex program
outputStruct vertexFunction(inputStruct input)
{
outputStruct toReturn;
float3 lightDirection;
float attenuation = 1.0;

lightDirection = normalize(_WorldSpaceLightPos0.xyz);

float3 normalDirection = normalize(mul(float4(input.vertexNormal, 0.0), _Object2World).xyz);
float3 viewDirection = normalize(float3(float4(_WorldSpaceCameraPos.xyz, 1.0) -
mul(_Object2World, input.vertexPos).xyz));
float3 diffuseReflection = attenuation * _LightColor0.xyz * max(0.0, dot(normalDirection, lightDirection));
float3 specularReflection = reflect(-lightDirection, normalDirection);
specularReflection = dot(specularReflection, viewDirection);
specularReflection = max(0.0, specularReflection);
specularReflection = max(0.0, dot(normalDirection, lightDirection)) * specularReflection;
specularReflection = pow(max(0.0, specularReflection), _Shininess);
specularReflection = max(0.0, dot(normalDirection, lightDirection)) * specularReflection;
float3 finalLight = specularReflection + diffuseReflection + UNITY_LIGHTMODEL_AMBIENT;

toReturn.pixelCol = float4(finalLight * _Color.rgb * attenuation * _SpecColour.rgb, 1.0);
toReturn.pixelPos = mul(UNITY_MATRIX_MVP, input.vertexPos);
return toReturn;
}

//fragment program
float4 fragmentFunction(outputStruct input) : COLOR
{
return input.pixelCol;
}
ENDCG
}
}

//Fallback
//FallBack "Diffuse"
}
9 changes: 9 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader1.shader.meta

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

75 changes: 75 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader2.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SpecularShader2.shader
Shader "Custom/SpecularShader2" { // Lab 10 Shader for On Your Own #2 (b and c)
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_SpecColour("Specular Color", Color) = (1,1,1,1)
_Shininess("Shininess", float) = 10
}
SubShader {
Pass{

CGPROGRAM
#pragma vertex vertexFunction
#pragma fragment fragmentFunction

//user defined variables
uniform float4 _Color;
uniform float4 _SpecColour;
uniform float _Shininess;

//unity defined variables
uniform float4 _LightColor0;

//input struct
struct inputStruct
{
float4 vertexPos : POSITION;
float3 vertexNormal : NORMAL;
};

//output struct
struct outputStruct
{
float4 pixelPos: SV_POSITION;
float3 normalDirection : TEXCOORD0;
float4 pixelWorldPos : TEXCOORD1;
};

//vertex program
outputStruct vertexFunction(inputStruct input)
{
outputStruct toReturn;

toReturn.normalDirection = normalize(mul(float4(input.vertexNormal, 0.0), _Object2World).xyz);
toReturn.pixelWorldPos = mul(_Object2World, input.vertexPos);
toReturn.pixelPos = mul(UNITY_MATRIX_MVP, input.vertexPos);
return toReturn;
}

//fragment program
float4 fragmentFunction(outputStruct input) : COLOR
{
float3 lightDirection;
float attenuation = 1.0;

lightDirection = normalize(_WorldSpaceLightPos0.xyz);

float3 viewDirection = normalize(float3(float4(_WorldSpaceCameraPos.xyz, 1.0) - input.pixelWorldPos.xyz));
float3 diffuseReflection = attenuation * _LightColor0.xyz * max(0.0, dot(input.normalDirection, lightDirection));
float3 specularReflection = reflect(-lightDirection, input.normalDirection);
specularReflection = dot(specularReflection, viewDirection);
specularReflection = max(0.0, specularReflection);
specularReflection = max(0.0, dot(input.normalDirection, lightDirection)) * specularReflection;
specularReflection = pow(max(0.0, specularReflection), _Shininess);
specularReflection = max(0.0, dot(input.normalDirection, lightDirection)) * specularReflection;
float3 finalLight = specularReflection + diffuseReflection + UNITY_LIGHTMODEL_AMBIENT;

return float4(finalLight * _Color.rgb * attenuation * _SpecColour.rgb, 1.0);
}
ENDCG
}
}

//Fallback
//FallBack "Diffuse"
}
9 changes: 9 additions & 0 deletions Lab 10/Assets/Shaders/SpecularShader2.shader.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 10/Assets/Textures.meta

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

Binary file added Lab 10/Assets/Textures/wood.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions Lab 10/Assets/Textures/wood.jpg.meta

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

Binary file added Lab 10/ProjectSettings/AudioManager.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/DynamicsManager.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/EditorSettings.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/InputManager.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/NavMeshAreas.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/NetworkManager.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/Physics2DSettings.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/ProjectSettings.asset
Binary file not shown.
2 changes: 2 additions & 0 deletions Lab 10/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 10/ProjectSettings/QualitySettings.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/TagManager.asset
Binary file not shown.
Binary file added Lab 10/ProjectSettings/TimeManager.asset
Binary file not shown.