-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renderer): add ability to render a height map & add camera contr…
…ols (#159)
- Loading branch information
Showing
4 changed files
with
113 additions
and
3 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
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
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
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,29 @@ | ||
// VERTEX SHADER | ||
varying lowp vec4 vColor; | ||
|
||
uniform sampler2D density; | ||
uniform vec3 hiCol; | ||
uniform vec3 lowCol; | ||
|
||
vec4 getColourFromDensity(float density) | ||
{ | ||
return vec4(mix(lowCol, hiCol, density), 1.0); | ||
} | ||
|
||
vec2 getCoordFromPoint(vec3 pos) | ||
{ | ||
float x = ((pos.x + (${width} / 2.0)) / ${width}); | ||
float y = ((-pos.y + (${height} / 2.0)) / ${height}); | ||
return vec2(x, y); | ||
} | ||
|
||
void main(void) | ||
{ | ||
highp vec2 vTextureCoord = getCoordFromPoint(position); | ||
vColor = getColourFromDensity(texture2D(density, vTextureCoord).r); | ||
|
||
vec3 changedPosition = position; | ||
changedPosition.z = texture2D(density, vTextureCoord).r; | ||
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( changedPosition, 1.0 ); | ||
} |