Commit d8afb0f2 by Nicolas Capens Committed by Nicolas Capens

Add the DisplacementMap PowerVR sample.

BUG=14598298 Change-Id: Ie155538dac9395021b5a69b9aa553a8c7e85aa8f Reviewed-on: https://swiftshader-review.googlesource.com/1100Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 7b21f276
...@@ -219,6 +219,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2ChameleonMan", "..\te ...@@ -219,6 +219,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2ChameleonMan", "..\te
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2Tools", "..\tests\third_party\PowerVR\Tools\OGLES2\Build\WindowsVC2010\OGLES2Tools.vcxproj", "{09ABE661-9BC0-4152-A820-1FB0522CAC01}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2Tools", "..\tests\third_party\PowerVR\Tools\OGLES2\Build\WindowsVC2010\OGLES2Tools.vcxproj", "{09ABE661-9BC0-4152-A820-1FB0522CAC01}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2DisplacementMap", "..\tests\third_party\PowerVR\Examples\Intermediate\DisplacementMap\OGLES2\Build\WindowsVC2010\OGLES2DisplacementMap.vcxproj", "{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}"
ProjectSection(ProjectDependencies) = postProject
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} = {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
...@@ -577,6 +583,18 @@ Global ...@@ -577,6 +583,18 @@ Global
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.Build.0 = Release|Win32 {09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.Build.0 = Release|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.ActiveCfg = Release|x64 {09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.ActiveCfg = Release|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.Build.0 = Release|x64 {09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.Build.0 = Release|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Debug|Win32.ActiveCfg = Debug|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Debug|Win32.Build.0 = Debug|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Debug|x64.ActiveCfg = Debug|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Debug|x64.Build.0 = Debug|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Profile|Win32.ActiveCfg = Release|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Profile|Win32.Build.0 = Release|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Profile|x64.ActiveCfg = Release|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Profile|x64.Build.0 = Release|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Release|Win32.ActiveCfg = Release|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Release|Win32.Build.0 = Release|Win32
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Release|x64.ActiveCfg = Release|x64
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -610,5 +628,6 @@ Global ...@@ -610,5 +628,6 @@ Global
{9DAFEE32-19F6-4410-AA09-2B564FB86F62} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {9DAFEE32-19F6-4410-AA09-2B564FB86F62} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{9CF4408B-9B08-481F-95DA-3DF0846DABE4} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {9CF4408B-9B08-481F-95DA-3DF0846DABE4} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{09ABE661-9BC0-4152-A820-1FB0522CAC01} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {09ABE661-9BC0-4152-A820-1FB0522CAC01} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{04FC5430-3F1B-42A2-A18A-D8BB7E5B2733} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
:Title:
DisplacementMap
:ShortDescription:
This training course demonstrates displacement mapping using a texture read from the vertex shader.
:FullDescription:
This training course demonstrates displacement mapping using a texture read from the vertex shader. A tesselated grid of vertices is displaced by differing amounts as dictated by the value read from the texture.
Displacement mapping is an alternative to bump mapping, normal mapping, and parallax mapping, that causes the actual geometric position of points over a textured surface to be displaced, often along the local surface normal, according to the value the texture function evaluates to at each point on the surface. It gives surfaces a great sense of depth and detail, permitting self-occlusion, self-shadowing and silhouettes.
Additional geometry is requried in order for the effect to be achieved and thus performance will be affected.
Controls:
- Esc - Close the application
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Content Files">
<UniqueIdentifier>{900022e4-757a-46fb-bd53-6dfc20b3d893}</UniqueIdentifier>
</Filter>
<Filter Include="Content Files\Scene Files">
<UniqueIdentifier>{2c3d4c8c-5d1a-459a-a05a-a4e4b608a44e}</UniqueIdentifier>
<Extensions>pod</Extensions>
</Filter>
<Filter Include="Content Files\Shaders">
<UniqueIdentifier>{2c3d4c8c-5d1a-459a-a05a-a4e4b608a44e}</UniqueIdentifier>
<Extensions>fsh;psh;glsl;frag;vert</Extensions>
</Filter>
<Filter Include="Content Files\Textures">
<UniqueIdentifier>{2c3d4c8c-5d1a-459a-a05a-a4e4b608a44e}</UniqueIdentifier>
<Extensions>ico;bmp;gif;jpg;jpeg;jpe;tiff;tif;png;pvr</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\..\..\Shell\PVRShell.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\..\..\Shell\PVRShellImpl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\..\..\Shell\API\KEGL\PVRShellAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\..\..\Shell\OS\Windows\PVRShellOS.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\..\..\Builds\Windows\Resources\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\..\..\Builds\Windows\Resources\shared.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\OGLES2DisplacementMap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\..\..\Shell\PVRShell.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\..\..\Shell\API\KEGL\PVRShellAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\..\..\Shell\OS\Windows\PVRShellOS.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Content\FragShader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Content\VertShader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Content\DisMapScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Content\Cow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Content\DisMap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\DisMapScene.pod">
<Filter>Content Files\Scene Files</Filter>
</CustomBuild>
<CustomBuild Include="..\..\DisMap.pvr">
<Filter>Content Files\Textures</Filter>
</CustomBuild>
<CustomBuild Include="..\..\Cow.pvr">
<Filter>Content Files\Textures</Filter>
</CustomBuild>
<CustomBuild Include="..\..\FragShader.fsh">
<Filter>Content Files\Shaders</Filter>
</CustomBuild>
<CustomBuild Include="..\..\VertShader.vsh">
<Filter>Content Files\Shaders</Filter>
</CustomBuild>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)..\lib\$(Configuration)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)..\lib\$(Configuration)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)..\lib\$(Configuration)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)..\lib\$(Configuration)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
// This file was created by Filewrap 1.1
// Little endian mode
// DO NOT EDIT
#include "../PVRTMemoryFileSystem.h"
// using 32 bit to guarantee alignment.
#ifndef A32BIT
#define A32BIT static const unsigned int
#endif
// ******** Start: FragShader.fsh ********
// File data
static const char _FragShader_fsh[] =
"uniform sampler2D sTexture;\r\n"
"\r\n"
"varying lowp float LightIntensity;\r\n"
"varying mediump vec2 TexCoord;\r\n"
"\r\n"
"void main()\r\n"
"{\r\n"
" gl_FragColor = texture2D(sTexture, TexCoord) * LightIntensity;\r\n"
"}\r\n";
// Register FragShader.fsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_FragShader_fsh("FragShader.fsh", _FragShader_fsh, 195);
// ******** End: FragShader.fsh ********
// This file was created by Filewrap 1.1
// Little endian mode
// DO NOT EDIT
#include "../PVRTMemoryFileSystem.h"
// using 32 bit to guarantee alignment.
#ifndef A32BIT
#define A32BIT static const unsigned int
#endif
// ******** Start: VertShader.vsh ********
// File data
static const char _VertShader_vsh[] =
"attribute highp vec3 inVertex;\r\n"
"attribute mediump vec3 inNormal;\r\n"
"attribute mediump vec2 inTexCoord;\r\n"
"\r\n"
"uniform highp mat4 MVPMatrix;\r\n"
"uniform mediump vec3 LightDirection;\r\n"
"uniform mediump\tfloat DisplacementFactor;\r\n"
"\r\n"
"varying lowp float LightIntensity;\r\n"
"varying mediump vec2 TexCoord;\r\n"
"\r\n"
"uniform sampler2D sDisMap;\r\n"
"\r\n"
"void main()\r\n"
"{\r\n"
"\t/* \r\n"
"\t\tCalculate the displacemnt value by taking the colour value from our texture\r\n"
"\t\tand scale it by out displacement factor.\r\n"
"\t*/\r\n"
"\tmediump float disp = texture2D(sDisMap, inTexCoord).r * DisplacementFactor;\r\n"
"\r\n"
"\t/* \r\n"
"\t\tTransform position by the model-view-projection matrix but first\r\n"
"\t\tmove the untransformed position along the normal by our displacement\r\n"
"\t\tvalue.\r\n"
"\t*/\r\n"
"\tgl_Position = MVPMatrix * vec4(inVertex + (inNormal * disp), 1.0);\r\n"
"\r\n"
"\t// Pass through texcoords\r\n"
"\tTexCoord = inTexCoord;\r\n"
"\t\r\n"
"\t// Simple diffuse lighting in model space\r\n"
"\tLightIntensity = dot(inNormal, -LightDirection);\r\n"
"}";
// Register VertShader.vsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_VertShader_vsh("VertShader.vsh", _VertShader_vsh, 949);
// ******** End: VertShader.vsh ********
uniform sampler2D sTexture;
varying lowp float LightIntensity;
varying mediump vec2 TexCoord;
void main()
{
gl_FragColor = texture2D(sTexture, TexCoord) * LightIntensity;
}
attribute highp vec3 inVertex;
attribute mediump vec3 inNormal;
attribute mediump vec2 inTexCoord;
uniform highp mat4 MVPMatrix;
uniform mediump vec3 LightDirection;
uniform mediump float DisplacementFactor;
varying lowp float LightIntensity;
varying mediump vec2 TexCoord;
uniform sampler2D sDisMap;
void main()
{
/*
Calculate the displacemnt value by taking the colour value from our texture
and scale it by out displacement factor.
*/
mediump float disp = texture2D(sDisMap, inTexCoord).r * DisplacementFactor;
/*
Transform position by the model-view-projection matrix but first
move the untransformed position along the normal by our displacement
value.
*/
gl_Position = MVPMatrix * vec4(inVertex + (inNormal * disp), 1.0);
// Pass through texcoords
TexCoord = inTexCoord;
// Simple diffuse lighting in model space
LightIntensity = dot(inNormal, -LightDirection);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment