Skip to content

Instantly share code, notes, and snippets.

View CedricGuillemet's full-sized avatar

Cedric Guillemet CedricGuillemet

View GitHub Profile
if (sphereDistance(currentPosition, sphereCenter, 1.0) < 0.) {
vec3 normal = (currentPosition - sphereCenter);
float dotLight = dot(normal, ligthDirection) * 0.5 + 0.5;
gl_FragColor = vec4(vec3(1.0, 0.5, 0.2) * dotLight, 1.0);
return;
}
void main(void) {
vec3 rayDir = normalize(vPosition - vEyePosition);
float distanceFromSurface = 0.0;
for (int i = 0; i < 100; i++) {
vec3 currentPosition = vPosition + distanceFromSurface * rayDir;
if (sphereDistance(currentPosition, vec3(0,1,0), 1.0) < 0.){
gl_FragColor = vec4(rayDir, 1.0);
return;
}
float sphereDistance(vec3 point, vec3 sphereOrigin, float sphereRadius) {
return length(point - sphereOrigin) - sphereRadius;
}
void main(void) {
vec3 rayDir = normalize(vPosition - vEyePosition);
if (sphereDistance(vPosition, vec3(0,1,0), 1.1) > 0.)
discard;
gl_FragColor = vec4(rayDir, 1.0);
}
void main(void) {
vec3 rayDir = normalize(vPosition - vEyePosition);
gl_FragColor = vec4(rayDir,1.0);
}
void main(void) {
gl_FragColor = vec4(1.0,0.0,1.0,1.0);
}
interface NavMesh {
void NavMesh();
void destroy();
void build([Const] float[] positions, [Const] long positionCount, [Const] long[] indices, [Const] long indexCount, [Const, Ref] rcConfig config);
[Value] DebugNavMesh getDebugNavMesh();
[Value] Vec3 getClosestPoint([Const, Ref] Vec3 position);
[Value] Vec3 getRandomPointAround([Const, Ref] Vec3 position, float maxRadius);
[Value] Vec3 moveAlong([Const, Ref] Vec3 position, [Const, Ref] Vec3 destination);
dtNavMesh getNavMesh();
[Value] NavPath computePath([Const, Ref] Vec3 start, [Const, Ref] Vec3 end);
python -m SimpleHTTPServer
emcc helloworld.c -o helloworld.html
#include <stdio.h>
int main()
{
printf("Hello world from the cpp side!\n");
return 0;
}
mkdir emscripten
cd emscripten
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
emsdk install latest
emsdk activate latest