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
4 changed files
with
104 additions
and
6 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
37 changes: 37 additions & 0 deletions
37
modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-fragment.glsl3.js
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 @@ | ||
export default `#version 300 es | ||
#define SHADER_NAME simple-mesh-layer-fs | ||
precision highp float; | ||
uniform bool hasTexture; | ||
uniform sampler2D sampler; | ||
uniform vec4 color; | ||
uniform bool flatShade; | ||
in vec2 vTexCoord; | ||
in vec3 cameraPosition; | ||
in vec3 normals_commonspace; | ||
in vec4 position_commonspace; | ||
in vec4 vColor; | ||
out vec4 fragColor; | ||
void main(void) { | ||
vec3 normal; | ||
if (flatShade) { | ||
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); | ||
} else { | ||
normal = normals_commonspace; | ||
} | ||
vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor / 255.; | ||
vec3 lightColor = lighting_getLightColor(color.rgb * 255., cameraPosition, position_commonspace.xyz, normal); | ||
fragColor = vec4(lightColor / 255., color.a); | ||
// use highlight color if this fragment belongs to the selected object. | ||
fragColor = picking_filterHighlightColor(fragColor); | ||
// use picking color if rendering to picking FBO. | ||
fragColor = picking_filterPickingColor(fragColor); | ||
} | ||
`; |
40 changes: 40 additions & 0 deletions
40
modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-vertex.glsl3.js
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,40 @@ | ||
export default `#version 300 es | ||
#define SHADER_NAME simple-mesh-layer-vs | ||
// Scale the model | ||
uniform float sizeScale; | ||
// Primitive attributes | ||
in vec3 positions; | ||
in vec3 normals; | ||
in vec2 texCoords; | ||
// Instance attributes | ||
in vec3 instancePositions; | ||
in vec2 instancePositions64xy; | ||
in vec4 instanceColors; | ||
in vec3 instancePickingColors; | ||
in mat3 instanceModelMatrix; | ||
in vec3 instanceTranslation; | ||
// Outputs to fragment shader | ||
out vec2 vTexCoord; | ||
out vec3 cameraPosition; | ||
out vec3 normals_commonspace; | ||
out vec4 position_commonspace; | ||
out vec4 vColor; | ||
void main(void) { | ||
vec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation; | ||
pos = project_size(pos); | ||
vTexCoord = texCoords; | ||
cameraPosition = project_uCameraPosition; | ||
normals_commonspace = project_normal(instanceModelMatrix * normals); | ||
vColor = instanceColors; | ||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64xy, pos, position_commonspace); | ||
picking_setPickingColor(instancePickingColors); | ||
} | ||
`; |
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