Skip to content

Commit

Permalink
Merge pull request #49 from tomasz-herman/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tomasz-herman committed Jan 5, 2021
2 parents 58b4187 + 05c3229 commit 4ee6581
Show file tree
Hide file tree
Showing 52 changed files with 1,959 additions and 413 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-2021 Tomasz Herman, Karol Krupa, Paweł Flis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
120 changes: 0 additions & 120 deletions MainForm.resx

This file was deleted.

28 changes: 12 additions & 16 deletions RayTracer/RayTracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AssimpNet" Version="5.0.0-beta1" />
<PackageReference Include="OpenTK" Version="3.1.0" />
<PackageReference Include="Serilog" Version="2.10.1-dev-01249" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.1-dev-00073" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00839" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0-dev-00887" />
<PackageReference Include="StbImageSharp" Version="2.22.4" />
<PackageReference Include="StbImageWriteSharp" Version="1.13.5" />
<PackageReference Include="AssimpNet" Version="5.0.0-beta1" />
<PackageReference Include="OpenTK" Version="3.1.0" />
<PackageReference Include="Serilog" Version="2.10.1-dev-01249" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.1-dev-00073" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00839" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0-dev-00887" />
<PackageReference Include="StbImageSharp" Version="2.22.4" />
<PackageReference Include="StbImageWriteSharp" Version="1.13.5" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Shaders\*" />
<EmbeddedResource Include="Resources\Shaders\*" />
<None Remove="Resources\Shaders\*" />
<EmbeddedResource Include="Resources\Shaders\*" />
<None Remove="Resources\Textures\*" />
<EmbeddedResource Include="Resources\Textures\*" />
</ItemGroup>

<ItemGroup>
<Folder Include="Resources\Models" />
<Folder Include="Resources\Textures" />
</ItemGroup>

</Project>
79 changes: 77 additions & 2 deletions RayTracer/Resources/Shaders/shader.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,84 @@
#version 330 core
#define MAX_LIGHTS 5
#define MATERIALS 3

struct Light
{
vec3 position;

vec3 diffuse;
};

struct Material
{
float part;
int useColor;
vec3 color;
sampler2D texture;
};

in vec2 texCoord;
out vec4 FragColor;

in vec2 texCoord;
in vec3 Normal;
in vec3 FragPos;

uniform int lightsCount;
uniform Material materials[MATERIALS];
uniform Light light[MAX_LIGHTS];
uniform vec3 ambientLight;
uniform vec3 cameraPosition;
uniform float disturbance;

vec3 Phong();
vec4 GetMaterialColor(Material material);
float Attenuation(float dist);
vec4 Clamp(vec4 vec);
vec3 Clamp(vec3 vec);

void main()
{
FragColor = vec4(0.0f, texCoord, 0.0f);
FragColor = vec4(Phong(), 1.0);
}

vec3 Phong() {
vec4 ambient = Clamp(GetMaterialColor(materials[0]));
vec4 diffuse = GetMaterialColor(materials[1]);
vec4 specular = GetMaterialColor(materials[2]);

vec3 normal = normalize(Normal);
vec3 viewDirection = normalize(cameraPosition - vec3(FragPos));

vec3 a = vec3(ambient), d = vec3(diffuse) * ambientLight, s = vec3(0);

// Point lights
for (int i = 0; i < lightsCount; i++) {
float lightDistance = length(vec3(light[i].position) - FragPos);
vec3 lightDir = normalize(light[i].position - FragPos);
float diff = max(dot(normal, lightDir), 0.0);
d += Clamp(light[i].diffuse) * diff * vec3(diffuse);
vec3 reflectDir = reflect(-lightDir, normal);
float reflectAngle = max(dot(reflectDir, viewDirection), 0);
s += vec3(specular * pow(reflectAngle, 1 + (1-disturbance)*99));
}

return a * materials[0].part + d * materials[1].part + s * materials[2].part;
}

vec4 GetMaterialColor(Material material)
{
return material.useColor == 1 ? vec4(material.color, 1.0) : texture(material.texture, texCoord);
}

float Attenuation(float dist)
{
return 1 + 0.007 * dist + 0.0002 * dist * dist;
}

vec3 Clamp(vec3 vec) {
return vec3(clamp(vec.x, 0, 1), clamp(vec.y, 0, 1), clamp(vec.z, 0, 1));
}

vec4 Clamp(vec4 vec) {
return vec4(clamp(vec.x, 0, 1), clamp(vec.y, 0, 1), clamp(vec.z, 0, 1), clamp(vec.w, 0, 1));
}
17 changes: 11 additions & 6 deletions RayTracer/Resources/Shaders/shader.vert
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#version 330 core
layout (location = 0) in vec3 aPosition;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoord;

out vec2 texCoord;
out vec3 Normal;
out vec3 FragPos;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform mat4 mvp;

out vec2 texCoord;
void main()
void main(void)
{
texCoord = aTexCoord;
mat4 vp = view * projection;
gl_Position = vec4(aPosition, 1.0) * model * vp ;
Normal = aNormal * mat3(model);
FragPos = vec3(vec4(aPosition, 1.0)*model);

gl_Position = vec4(aPosition, 1.0)*mvp;
}
Binary file added RayTracer/Resources/Textures/blue_something.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RayTracer/Resources/Textures/earthmap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RayTracer/Resources/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.
Loading

0 comments on commit 4ee6581

Please sign in to comment.