glsl-face-normal

WebJar for glsl-face-normal

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

glsl-face-normal
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

glsl-face-normal
WebJar for glsl-face-normal
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/glslify/glsl-face-normal

Download glsl-face-normal

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/glsl-face-normal/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>glsl-face-normal</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/glsl-face-normal/
implementation 'org.webjars.npm:glsl-face-normal:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/glsl-face-normal/
implementation ("org.webjars.npm:glsl-face-normal:1.0.2")
'org.webjars.npm:glsl-face-normal:jar:1.0.2'
<dependency org="org.webjars.npm" name="glsl-face-normal" rev="1.0.2">
  <artifact name="glsl-face-normal" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='glsl-face-normal', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "glsl-face-normal" % "1.0.2"
[org.webjars.npm/glsl-face-normal "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

glsl-face-normal

stable

demo-image

(click for demo)

Approximates face normals in the fragment shader for flat shading from the position in camera space.

Note: You need to enable GL_OES_standard_derivatives.

Fragment:

#extension GL_OES_standard_derivatives : enable
varying vec3 vViewPos;

#pragma glslify: faceNormal = require('glsl-face-normal')

void main() {
  vec3 normal = faceNormal(vViewPos);
  //... lighting
}

Vertex:

varying vec3 vViewPos;

void main() {
  vec4 pos = vec4(position, 1.0);
  vec4 mpos = modelViewMatrix * pos;
  gl_Position = projectionMatrix * mpos;
  vViewPos = -mpos.xyz;
}

Usage

NPM

vec3 normal = faceNormal(vec3 pos)

Approximates the face normal from the given pos, which is typically the position in camera-space.

For better precision, you can use the eye relative position instead.

License

MIT. See LICENSE.md for details.

org.webjars.npm

Versions

Version
1.0.2