-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example 24. Erode effect using perlin noise.
Added perlin noise function.
- Loading branch information
Showing
15 changed files
with
2,402 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Example24</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> | ||
<triggers>clean,full,incremental,</triggers> | ||
<arguments> | ||
<dictionary> | ||
<key>?name?</key> | ||
<value></value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.append_environment</key> | ||
<value>true</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key> | ||
<value>all</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.buildArguments</key> | ||
<value></value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.buildCommand</key> | ||
<value>make</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.buildLocation</key> | ||
<value>${workspace_loc:/Example05/DebugMac}</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key> | ||
<value>clean</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.contents</key> | ||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key> | ||
<value>false</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key> | ||
<value>true</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.enableFullBuild</key> | ||
<value>true</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key> | ||
<value>all</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.stopOnError</key> | ||
<value>true</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> | ||
<value>true</value> | ||
</dictionary> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> | ||
<triggers>full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.linuxtools.rpm.rpmlint.rpmlintBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.cdt.core.cnature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> | ||
<nature>org.eclipse.linuxtools.rpm.rpmlint.rpmlintNature</nature> | ||
</natures> | ||
</projectDescription> |
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,37 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project> | ||
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.894771756.809860878.1368823954.968111795" name="x64__Darwin__GCC_Debug"> | ||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/> | ||
</extension> | ||
</configuration> | ||
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.894771756.809860878.1382563384.1598579354" name="x64__Linux__GCC_Debug"> | ||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/> | ||
</extension> | ||
</configuration> | ||
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.894771756.809860878.1112206935" name="x86__Linux__GCC_Debug"> | ||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" ref="shared-provider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/> | ||
</extension> | ||
</configuration> | ||
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.894771756.1982576218" name="x86__Windows__MinGW_Debug"> | ||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> | ||
</extension> | ||
</configuration> | ||
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.release.289745933.146695515" name="x86__Windows__MinGW_Release"> | ||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> | ||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> | ||
</extension> | ||
</configuration> | ||
</project> |
22 changes: 22 additions & 0 deletions
22
Example24/.settings/org.eclipse.cdt.managedbuilder.core.prefs
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,22 @@ | ||
#Wed Jan 11 19:59:32 CET 2012 | ||
eclipse.preferences.version=1 | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/CPATH/delimiter=; | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/CPATH/operation=remove | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/C_INCLUDE_PATH/delimiter=; | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/C_INCLUDE_PATH/operation=remove | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/append=true | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/appendContributed=true | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/CPATH/delimiter=; | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/CPATH/operation=remove | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/C_INCLUDE_PATH/delimiter=; | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/C_INCLUDE_PATH/operation=remove | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/append=true | ||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/appendContributed=true | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/LIBRARY_PATH/delimiter=; | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/LIBRARY_PATH/operation=remove | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/append=true | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.894771756/appendContributed=true | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/LIBRARY_PATH/delimiter=; | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/LIBRARY_PATH/operation=remove | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/append=true | ||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.289745933/appendContributed=true |
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,73 @@ | ||
#version 150 | ||
|
||
struct LightProperties | ||
{ | ||
vec3 direction; | ||
vec4 ambientColor; | ||
vec4 diffuseColor; | ||
vec4 specularColor; | ||
}; | ||
|
||
struct MaterialProperties | ||
{ | ||
vec4 ambientColor; | ||
vec4 diffuseColor; | ||
vec4 specularColor; | ||
float specularExponent; | ||
}; | ||
|
||
uniform LightProperties u_light; | ||
uniform MaterialProperties u_material; | ||
|
||
uniform sampler3D u_texture; | ||
|
||
uniform float u_erode; | ||
|
||
in vec3 v_normal; | ||
in vec3 v_eye; | ||
in vec3 v_vertex; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() | ||
{ | ||
float erodeLevel = texture(u_texture, normalize(v_vertex)).r; | ||
|
||
// u_erode gets smaller over time. If this value is smaller than the reference texel, discard it. | ||
// This results in an erode effect over time. | ||
if (erodeLevel > u_erode) | ||
{ | ||
discard; | ||
} | ||
|
||
// If not dicarded, render standard phong. | ||
|
||
vec4 color = u_light.ambientColor * u_material.ambientColor; | ||
|
||
vec3 normal = normalize(v_normal); | ||
|
||
float nDotL = max(dot(u_light.direction, normal), 0.0); | ||
|
||
if (nDotL > 0.0) | ||
{ | ||
vec3 eye = normalize(v_eye); | ||
|
||
// Incident vector is opposite light direction vector. | ||
vec3 reflection = reflect(-u_light.direction, normal); | ||
|
||
float eDotR = max(dot(eye, reflection), 0.0); | ||
|
||
color += u_light.diffuseColor * u_material.diffuseColor * nDotL; | ||
|
||
float specularIntensity = 0.0; | ||
|
||
if (eDotR > 0.0) | ||
{ | ||
specularIntensity = pow(eDotR, u_material.specularExponent); | ||
} | ||
|
||
color += u_light.specularColor * u_material.specularColor * specularIntensity; | ||
} | ||
|
||
fragColor = color; | ||
} |
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,27 @@ | ||
#version 150 | ||
|
||
uniform mat4 u_projectionMatrix; | ||
uniform mat4 u_modelViewMatrix; | ||
uniform mat3 u_normalMatrix; | ||
|
||
in vec4 a_vertex; | ||
in vec3 a_normal; | ||
|
||
out vec3 v_normal; | ||
out vec3 v_eye; | ||
out vec3 v_vertex; | ||
|
||
void main() | ||
{ | ||
vec4 vertex = u_modelViewMatrix * a_vertex; | ||
|
||
v_eye = -vec3(vertex); | ||
|
||
v_normal = u_normalMatrix * a_normal; | ||
|
||
// The later fetched texel is always the same. So when the sphere rotates, | ||
// the associated texel rotates on the surface of the sphere as well. | ||
v_vertex = vec3(a_vertex); | ||
|
||
gl_Position = u_projectionMatrix * vertex; | ||
} |
Oops, something went wrong.