-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
591 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
examples/ComputeConvolution/ComputeConvolution.Assets/ComputeConvolution.Assets.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="**\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+540 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Xn.png
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
BIN
+593 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Xp.png
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
BIN
+4.51 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Yn.png
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
BIN
+311 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Yp.png
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
BIN
+610 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Zn.png
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
BIN
+669 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Data/Sky/TC_Miramar_Zp.png
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
BIN
+282 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/Kufam-Regular.ttf
Binary file not shown.
Binary file added
BIN
+103 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/Mali-Medium.ttf
Binary file not shown.
Binary file added
BIN
+103 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/Mali-Regular.ttf
Binary file not shown.
Binary file added
BIN
+164 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/RobotoCondensed-Light.ttf
Binary file not shown.
Binary file added
BIN
+166 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/RobotoCondensed-Regular.ttf
Binary file not shown.
Binary file added
BIN
+112 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/RobotoMono-Medium.ttf
Binary file not shown.
Binary file added
BIN
+112 KB
examples/ComputeConvolution/ComputeConvolution.Assets/Fonts/RobotoMono-Regular.ttf
Binary file not shown.
101 changes: 101 additions & 0 deletions
101
examples/ComputeConvolution/ComputeConvolution.Assets/Shaders/ConvolveSkybox.cs.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#version 460 core | ||
|
||
layout(binding = 0, rgba8) readonly uniform imageCube u_environment; | ||
layout(binding = 1, rgba16f) writeonly uniform imageCube u_irradiance; | ||
|
||
const float PI = 3.14159265359; | ||
|
||
vec3 cubeCoordToWorld(ivec3 cubeCoord, vec2 cubemapSize) | ||
{ | ||
vec2 texCoord = vec2(cubeCoord.xy) / cubemapSize; | ||
texCoord = texCoord * 2.0 - 1.0; // -1..1 | ||
switch(cubeCoord.z) | ||
{ | ||
case 0: return vec3(1.0, -texCoord.yx); // posx | ||
case 1: return vec3(-1.0, -texCoord.y, texCoord.x); //negx | ||
case 2: return vec3(texCoord.x, 1.0, texCoord.y); // posy | ||
case 3: return vec3(texCoord.x, -1.0, -texCoord.y); //negy | ||
case 4: return vec3(texCoord.x, -texCoord.y, 1.0); // posz | ||
case 5: return vec3(-texCoord.xy, -1.0); // negz | ||
} | ||
return vec3(0.0); | ||
} | ||
|
||
float max3(vec3 v) | ||
{ | ||
return max(max(v.x, v.y), v.z); | ||
} | ||
|
||
ivec3 texCoordToCube(vec3 texCoord, vec2 cubemapSize) | ||
{ | ||
vec3 abst = abs(texCoord); | ||
texCoord /= max3(abst); | ||
|
||
float cubeFace; | ||
vec2 uvCoord; | ||
if (abst.x > abst.y && abst.x > abst.z) | ||
{ | ||
// x major | ||
float negx = step(texCoord.x, 0.0); | ||
uvCoord = mix(-texCoord.zy, vec2(texCoord.z, -texCoord.y), negx); | ||
cubeFace = negx; | ||
} | ||
else if (abst.y > abst.z) | ||
{ | ||
// y major | ||
float negy = step(texCoord.y, 0.0); | ||
uvCoord = mix(texCoord.xz, vec2(texCoord.x, -texCoord.z), negy); | ||
cubeFace = 2.0 + negy; | ||
} | ||
else | ||
{ | ||
// z major | ||
float negz = step(texCoord.z, 0.0); | ||
uvCoord = mix(vec2(texCoord.x, -texCoord.y), -texCoord.xy, negz); | ||
cubeFace = 4.0 + negz; | ||
} | ||
uvCoord = (uvCoord + 1.0) * 0.5; // 0..1 | ||
uvCoord = uvCoord * cubemapSize; | ||
uvCoord = clamp(uvCoord, vec2(0.0), cubemapSize - vec2(1.0)); | ||
|
||
return ivec3(ivec2(uvCoord), int(cubeFace)); | ||
} | ||
|
||
layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in; | ||
void main() | ||
{ | ||
vec2 cubeSize = imageSize(u_irradiance); | ||
ivec3 cubeCoord = ivec3(gl_GlobalInvocationID); | ||
if (any(lessThan(cubeCoord, ivec3(0))) || any(greaterThanEqual(cubeCoord.xy, cubeSize))) | ||
{ | ||
return; | ||
} | ||
|
||
vec3 worldPos = cubeCoordToWorld(cubeCoord, cubeSize); | ||
// tangent space from origin point | ||
vec3 normal = normalize(worldPos); | ||
vec3 up = vec3(0.0, 1.0, 0.0); | ||
vec3 right = normalize(cross(up, normal)); | ||
up = cross(normal, right); | ||
|
||
vec3 irradiance = vec3(0.0); | ||
|
||
//float sampleDelta = 0.025; | ||
float sampleDelta = 1.0; | ||
float nrSamples = 0.0; | ||
|
||
for (float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta) | ||
{ | ||
for (float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta) | ||
{ | ||
vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)); | ||
vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal; | ||
ivec3 sampleCoord = texCoordToCube(sampleVec, cubeSize); | ||
irradiance += imageLoad(u_environment, sampleCoord).rgb * cos(theta) * sin(theta); | ||
nrSamples++; | ||
} | ||
} | ||
|
||
irradiance = PI * irradiance * (1.0 / float(nrSamples)); | ||
imageStore(u_irradiance, cubeCoord, vec4(irradiance, 1.0)); | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/ComputeConvolution/ComputeConvolution.Assets/Shaders/FST.vs.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#version 460 core | ||
|
||
layout (location = 0) out gl_PerVertex | ||
{ | ||
vec4 gl_Position; | ||
}; | ||
layout(location = 1) out vec2 fs_uv; | ||
|
||
void main() | ||
{ | ||
vec2 pos = vec2(gl_VertexID == 0, gl_VertexID == 2); | ||
fs_uv = pos.xy * 2.0; | ||
gl_Position = vec4(pos * 4.0 - 1.0, 0.0, 1.0); | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/ComputeConvolution/ComputeConvolution.Assets/Shaders/Texture.fs.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#version 460 core | ||
|
||
layout(location = 0) in vec2 v_uv; | ||
|
||
layout(location = 0) uniform sampler2D s_texture; | ||
|
||
layout(location = 0) out vec4 o_color; | ||
|
||
void main() | ||
{ | ||
o_color = texture(s_texture, v_uv); | ||
} |
38 changes: 38 additions & 0 deletions
38
examples/ComputeConvolution/ComputeConvolution/ComputeConvolution.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\EngineKit\EngineKit.csproj" /> | ||
<ProjectReference Include="..\ComputeConvolution.Assets\ComputeConvolution.Assets.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> | ||
<PackageReference Include="Serilog" Version="2.12.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Serilog"> | ||
<HintPath>..\..\..\..\..\..\..\..\.nuget\packages\serilog\2.12.0\lib\net6.0\Serilog.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.