Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Generate spherical harmonics from a cubemap. The example screenshot shows them used to cheaply generate environmental diffuse light for a mesh.
$ npm i -S cubemap-sh
You pass in:
128
)4
)const coefficients = sh([posx, negx, posy, negy, posz, negz], CUBE_MAP_SIZE, NUM_CHANNELS)
What you get back is an array of 9 vec3
s (an array of arrays, each one having 3 elements for r g and b).
To use them for example to light up your mesh, you can use the corresponding glsl-sh module and pass them to a shader
that looks like this:
precision mediump float;
#pragma glslify: sh = require('glsl-sh') // import using glslify
varying vec3 vWorldNormal;
uniform vec3 c[9]; // this is what you get from the function above, pass it straight to the shader
uniform vec3 color;
void main() {
vec3 n = normalize(vWorldNormal);
vec3 shColor = sh(c, n) * color; // here we get diffuse light calculated by the sperhical harmonics multiplied by the color of the mesh
gl_FragColor = vec4(shColor, 1.0);
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0 / 2.2)); // gamma correction
}
Please note this example uses glslify.
const sh = require('cubemap-sh')
faces:
128
4
returns array of 9 vec3
s
MIT
FAQs
generate spherical harmonics from a cubemap
We found that cubemap-sh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.