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
25 changes: 25 additions & 0 deletions Project Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
IMAGE PROCESSING AND WEBGL


PART 1:

- Implemented all necessary image processing filters.
- In the 3 extra filters, I have made custom filters:
- The first filter keeps only the portions of image that have high luminance and does not show the rest of the image. This gives a kind of comic book effect with black and white images.
- The other 2 filters just output a component of the colors (red and magenta). This is nothing special so I don't think I will get any points for these.


PART 2:

- Implemented the sine wave and simplex vertex shaders.
- My custom implementation has a sine of exponent which gives a nice cloth-in-the-wind like effect.


SCREENSHOTS:

- See blog


BLOG POST:

experiencetheforce.blogspot.com
Binary file added part1/ImageProcessing/ImageProcessing.sdf
Binary file not shown.
60 changes: 31 additions & 29 deletions part1/ImageProcessing/ImageProcessing.sln
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageProcessing", "ImageProcessing\ImageProcessing.vcxproj", "{C53A9886-B4FD-487A-83A5-01406BA9E8BF}"
ProjectSection(ProjectDependencies) = postProject
{25544C77-3B78-405F-A15D-1231D05969F3} = {25544C77-3B78-405F-A15D-1231D05969F3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SOIL", "SOIL\SOIL.vcxproj", "{25544C77-3B78-405F-A15D-1231D05969F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.ActiveCfg = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.Build.0 = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.ActiveCfg = Release|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.Build.0 = Release|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Debug|Win32.ActiveCfg = Debug|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Debug|Win32.Build.0 = Debug|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Release|Win32.ActiveCfg = Release|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageProcessing", "ImageProcessing\ImageProcessing.vcxproj", "{C53A9886-B4FD-487A-83A5-01406BA9E8BF}"
ProjectSection(ProjectDependencies) = postProject
{25544C77-3B78-405F-A15D-1231D05969F3} = {25544C77-3B78-405F-A15D-1231D05969F3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SOIL", "SOIL\SOIL.vcxproj", "{25544C77-3B78-405F-A15D-1231D05969F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{897A09B4-CB4F-429A-B46E-8A85628EF166}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Debug|Win32.ActiveCfg = Debug|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Debug|Win32.Build.0 = Debug|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Release|Win32.ActiveCfg = Release|Win32
{C53A9886-B4FD-487A-83A5-01406BA9E8BF}.Release|Win32.Build.0 = Release|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.ActiveCfg = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.Build.0 = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.ActiveCfg = Release|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
226 changes: 117 additions & 109 deletions part1/ImageProcessing/ImageProcessing/ImageProcessing.vcxproj
Original file line number Diff line number Diff line change
@@ -1,110 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="boxBlurFS.glsl" />
<None Include="passthroughFS.glsl" />
<None Include="passthroughVS.glsl" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="Utility.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utility.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>ImageProcessing</ProjectName>
<ProjectGuid>{C53A9886-B4FD-487A-83A5-01406BA9E8BF}</ProjectGuid>
<RootNamespace>Box_Blur</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\shared32\glew\include;..\..\shared32\freeglut\include;..\Shader_Loading;..\SOIL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\shared32\glew\lib;..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\SOIL\SOIL.vcxproj">
<Project>{25544c77-3b78-405f-a15d-1231d05969f3}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="blackFS.glsl" />
<None Include="boxBlurFS.glsl" />
<None Include="edgeDetectionFS.glsl" />
<None Include="gaussianBlurFS.glsl" />
<None Include="grayscaleFS.glsl" />
<None Include="imageNegativeFS.glsl" />
<None Include="magentaFS.glsl" />
<None Include="passthroughFS.glsl" />
<None Include="passthroughVS.glsl" />
<None Include="redFS.glsl" />
<None Include="toonShadingFS.glsl" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="Utility.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utility.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>ImageProcessing</ProjectName>
<ProjectGuid>{C53A9886-B4FD-487A-83A5-01406BA9E8BF}</ProjectGuid>
<RootNamespace>Box_Blur</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\shared32\glew\include;..\..\shared32\freeglut\include;..\Shader_Loading;..\SOIL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\shared32\glew\lib;..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\SOIL\SOIL.vcxproj">
<Project>{25544c77-3b78-405f-a15d-1231d05969f3}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
Binary file added part1/ImageProcessing/ImageProcessing/Thumbs.db
Binary file not shown.
17 changes: 17 additions & 0 deletions part1/ImageProcessing/ImageProcessing/blackFS.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
varying vec2 v_Texcoords;

uniform sampler2D u_image;

void main(void)
{
vec3 temp = texture2D(u_image, v_Texcoords).rgb;
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
float luminance = dot(temp.rgb, W);

if(luminance > 0.9)
luminance = 1.0;
else
luminance = 0.0;

gl_FragColor = vec4(vec3(luminance * temp.rgb), 1.0);
}
31 changes: 31 additions & 0 deletions part1/ImageProcessing/ImageProcessing/edgeDetectionFS.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
varying vec2 v_Texcoords;

uniform sampler2D u_image;
uniform vec2 u_step;

const int KERNEL_WIDTH = 3; // Odd
const float offset = 1.0;

void main(void)
{
//vec3 accum = vec3(0.0);
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
mat3 sobelH = mat3(vec3(-1,-2,-1),vec3(0,0,0),vec3(1,2,1));
mat3 sobelV = mat3(vec3(-1,0,1),vec3(-2,0,2),vec3(-1,0,1));
float luminanceH = 0.0;
float luminanceV = 0.0;

for (int i = 0; i < KERNEL_WIDTH; ++i)
{
for (int j = 0; j < KERNEL_WIDTH; ++j)
{
vec2 coord = vec2(v_Texcoords.s + ((float(i) - offset) * u_step.s), v_Texcoords.t + ((float(j) - offset) * u_step.t));
luminanceH += sobelH[i][j] * dot(texture2D(u_image, coord).rgb, W);
luminanceV += sobelV[i][j] * dot(texture2D(u_image, coord).rgb, W);
}
}

vec2 edge = vec2(luminanceH, luminanceV);
float edgeIntensity = length(edge);
gl_FragColor = vec4(vec3(edgeIntensity), 1.0);
}
24 changes: 24 additions & 0 deletions part1/ImageProcessing/ImageProcessing/gaussianBlurFS.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
varying vec2 v_Texcoords;

uniform sampler2D u_image;
uniform vec2 u_step;

const int KERNEL_WIDTH = 3; // Odd
const float offset = 1.0;

void main(void)
{
vec3 accum = vec3(0.0);
mat3 mask = mat3(vec3(1,2,1),vec3(2,4,2),vec3(1,2,1))/16.0;

for (int i = 0; i < KERNEL_WIDTH; ++i)
{
for (int j = 0; j < KERNEL_WIDTH; ++j)
{
vec2 coord = vec2(v_Texcoords.s + /*mask[i][j] * */((float(i) - offset) * u_step.s), v_Texcoords.t + /*mask[i][j] * */((float(j) - offset) * u_step.t));
accum += mask[i][j] * texture2D(u_image, coord).rgb;
}
}

gl_FragColor = vec4(accum/* / float(KERNEL_WIDTH * KERNEL_WIDTH)*/, 1.0);
}
Loading