Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51,746 changes: 51,746 additions & 0 deletions Cow.json

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions Instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# [HW1: Noise](https://github.com/CIS700-Procedural-Graphics/Project1-Noise)

## Getting Started

1. [Install Node.js](https://nodejs.org/en/download/). Node.js is a JavaScript runtime. It basically allows you to run JavaScript when not in a browser. For our purposes, this is not necessary. The important part is that with it comes `npm`, the Node Package Manager. This allows us to easily declare and install external dependencies such as [three.js](https://threejs.org/), [dat.GUI](https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage), and [glMatrix](http://glmatrix.net/). Some other packages we'll be using make it significantly easier to develop your code and create modules for better code reuse and clarity. These tools make it _signficantly_ easier to write code in multiple `.js` files without globally defining everything.

2. Fork and clone your repository.

3. In the root directory of your project, run `npm install`. This will download all of those dependencies.

4. Do either of the following (but I highly recommend the first one for reasons I will explain later).

a. Run `npm start` and then go to `localhost:7000` in your web browser

b. Run `npm run build` and then go open `index.html` in your web browser

You should hopefully see the framework code with a 3D cube at the center of the screen!


## Developing Your Code
All of the JavaScript code is living inside the `src` directory. The main file that gets executed when you load the page as you may have guessed is `main.js`. Here, you can make any changes you want, import functions from other files, etc. The reason that I highly suggest you build your project with `npm start` is that doing so will start a process that watches for any changes you make to your code. If it detects anything, it'll automagically rebuild your project and then refresh your browser window for you. Wow. That's cool. If you do it the other way, you'll need to run `npm build` and then refresh your page every time you want to test something.

## Publishing Your Code
We highly suggest that you put your code on GitHub. One of the reasons we chose to make this course using JavaScript is that the Web is highly accessible and making your awesome work public and visible can be a huge benefit when you're looking to score a job or internship. To aid you in this process, running `npm run deploy` will automatically build your project and push it to `gh-pages` where it will be visible at `username.github.io/repo-name`.

## What is Actually Happening?
You can skip this part if you really want, but I highly suggest you read it.

### npm install
`npm install` will install all dependencies into a folder called `node_modules`. That's about it.

### package.json

This is the important file that `npm` looks at. In it, you can see the commands it's using for the `start`, `build`, and `deploy` scripts mentioned above. You can also see all of the dependencies the project requires. I will briefly go through what each of these is.
- dat-gui: Gives us a nice and simple GUI for modifying variables in our program

- gl-matrix: Useful library for linear algebra, much like glm

- stats-js: Gives us a nice graph for timing things. We use it to report how long it takes to render each frame

- three: Three.js is the main library we're using to draw stuff

- three-orbit-controls: Handles mouse / touchscreen camera controls

- babel-core, babel-loader, babel-preset-es2015: JavaScript is a a really fast moving language. It is constantly, constantly changing. Unfortunately, web browsers don't keep up nearly as quickly. Babel does the job of converting your code to a form that current browsers support. This allows us to use newer JavaScript features such as classes and imports without worrying about compatibility.

- gh-pages-deploy: This is the library that automates publishing your code to Github

- webpack: Webpack serves the role of packaging your project into a single file. Browsers don't actually support "importing" from other files, so without Webpack, to access data and functions in other files we would need to globally define EVERYTHING. This is an extremely bad idea. Webpack lets us use imports and develop code in separate files. Running `npm build` or `npm start` is what bundles all of your code together.

- webpack-dev-server: This is an extremely useful tool for development. It essentially creates a file watcher and rebuilds your project whenever you make changes. It also injects code into your page that gets notified when these changes occur so it can automatically refresh your page.

- webpack-glsl-loader: Webpack does much more than just JavaScript. We can use it to load glsl, css, images, etc. For whatever you want to import, somebody has probably made a webpack loader for it.

### webpack.config.js

This is the configuration file in webpack. The most important part is `entry` and `output`. These define the input and output for webpack. It will start from `entry`, explore all dependencies, and package them all into `output`. Here, the `output` is `bundle.js`. If you look in `index.html`, you can see that the page is loading `bundle.js`, not `main.js`.

The other sections are just configuration settings for `webpack-dev-server` and setup for loading different types of files.
60 changes: 26 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
# [HW1: Noise](https://github.com/CIS700-Procedural-Graphics/Project1-Noise)

## Getting Started
## Project Description

1. [Install Node.js](https://nodejs.org/en/download/). Node.js is a JavaScript runtime. It basically allows you to run JavaScript when not in a browser. For our purposes, this is not necessary. The important part is that with it comes `npm`, the Node Package Manager. This allows us to easily declare and install external dependencies such as [three.js](https://threejs.org/), [dat.GUI](https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage), and [glMatrix](http://glmatrix.net/). Some other packages we'll be using make it significantly easier to develop your code and create modules for better code reuse and clarity. These tools make it _signficantly_ easier to write code in multiple `.js` files without globally defining everything.
### Overall description

2. Fork and clone your repository.
The project goes about creating a sphere, and then applying a pseudo-4D noise (3D Noise utilizing time as an input) to deform its surface. Various GUI controls were added to give the project more life.

3. In the root directory of your project, run `npm install`. This will download all of those dependencies.
GUI controls let you:

4. Do either of the following (but I highly recommend the first one for reasons I will explain later).
1. Change the texture applied onto the sphere (from a fixed set of images)

a. Run `npm start` and then go to `localhost:7000` in your web browser
2. Change the strength of the Noise

b. Run `npm run build` and then go open `index.html` in your web browser
3. Change the persistence of the octaves of Noise

You should hopefully see the framework code with a 3D cube at the center of the screen!
4. Change the number of octaves of Noise

5. Change the field of view of the camera

## Developing Your Code
All of the JavaScript code is living inside the `src` directory. The main file that gets executed when you load the page as you may have guessed is `main.js`. Here, you can make any changes you want, import functions from other files, etc. The reason that I highly suggest you build your project with `npm start` is that doing so will start a process that watches for any changes you make to your code. If it detects anything, it'll automagically rebuild your project and then refresh your browser window for you. Wow. That's cool. If you do it the other way, you'll need to run `npm build` and then refresh your page every time you want to test something.
6. Change the aspect ratio of the camera

## Publishing Your Code
We highly suggest that you put your code on GitHub. One of the reasons we chose to make this course using JavaScript is that the Web is highly accessible and making your awesome work public and visible can be a huge benefit when you're looking to score a job or internship. To aid you in this process, running `npm run deploy` will automatically build your project and push it to `gh-pages` where it will be visible at `username.github.io/repo-name`.
The UVs are updated constantly to make the surface of the sphere seem animated.

## What is Actually Happening?
You can skip this part if you really want, but I highly suggest you read it.
### Things Done:

### npm install
`npm install` will install all dependencies into a folder called `node_modules`. That's about it.
#### main.js description

### package.json
1. Created a Icosahedron geometry, which when sub-dived approximates a sphere really well.

This is the important file that `npm` looks at. In it, you can see the commands it's using for the `start`, `build`, and `deploy` scripts mentioned above. You can also see all of the dependencies the project requires. I will briefly go through what each of these is.
- dat-gui: Gives us a nice and simple GUI for modifying variables in our program

- gl-matrix: Useful library for linear algebra, much like glm
2. Using this approximated sphere and a custom material 'color_Material', I created a sphere mesh, that was added to the scene.

- stats-js: Gives us a nice graph for timing things. We use it to report how long it takes to render each frame
3. The color_Material contains multiple uniforms (including multiple textures that will be used with different image samplers), that will be passed too the shader to control various aspects. Some of these uniforms were also added to the GUI to increase interactivity.
'color_Material' also holds the creates its own fragment and vertex shaders (all Materials in nodejs do).

- three: Three.js is the main library we're using to draw stuff
4. All the GUI parameters and uniforms used by the shader are updated to create a dynamic looking scene in 'function onUpdate(framework)'

- three-orbit-controls: Handles mouse / touchscreen camera controls
#### Shaders

- babel-core, babel-loader, babel-preset-es2015: JavaScript is a a really fast moving language. It is constantly, constantly changing. Unfortunately, web browsers don't keep up nearly as quickly. Babel does the job of converting your code to a form that current browsers support. This allows us to use newer JavaScript features such as classes and imports without worrying about compatibility.
##### Vertex Shader

- gh-pages-deploy: This is the library that automates publishing your code to Github
1. The Vertex shader deals with the actual Noise function, using which we deform the position, of that vertex along it's surface normal.

- webpack: Webpack serves the role of packaging your project into a single file. Browsers don't actually support "importing" from other files, so without Webpack, to access data and functions in other files we would need to globally define EVERYTHING. This is an extremely bad idea. Webpack lets us use imports and develop code in separate files. Running `npm build` or `npm start` is what bundles all of your code together.
2. The noise function is a multi-octave noise function, that utilizes a simple hash function to map a 3D point to some unique noise value.
The noise function also makes use of a cosine interpolation and smoothing stage to give a less jittery and smooth noise output.

- webpack-dev-server: This is an extremely useful tool for development. It essentially creates a file watcher and rebuilds your project whenever you make changes. It also injects code into your page that gets notified when these changes occur so it can automatically refresh your page.
3. The noise output is just a float value that scales the normal of that vertex and adds this scaled normal to the vertex position.

- webpack-glsl-loader: Webpack does much more than just JavaScript. We can use it to load glsl, css, images, etc. For whatever you want to import, somebody has probably made a webpack loader for it.
##### Fragment Shader

### webpack.config.js

This is the configuration file in webpack. The most important part is `entry` and `output`. These define the input and output for webpack. It will start from `entry`, explore all dependencies, and package them all into `output`. Here, the `output` is `bundle.js`. If you look in `index.html`, you can see that the page is loading `bundle.js`, not `main.js`.

The other sections are just configuration settings for `webpack-dev-server` and setup for loading different types of files.
1. The fragment shader utilizes a flag to determine which image sampler, if any, is to be used to create a colorful deformed sphere at every timestep.
Binary file added blue_gradient.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading