Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a5757c1
+ Transferred HW4 into 5. Let's do this!
mmerchante Feb 21, 2017
8957b41
+ Starting the choreo
mmerchante Feb 21, 2017
efc2961
+ Base vertex colors working.
mmerchante Feb 21, 2017
ffa39c1
+ Added intro lines, working on vertex colors
mmerchante Feb 21, 2017
1b42e22
+ More choreo, shaders
mmerchante Feb 22, 2017
3344fa9
* Fun polka lerp
mmerchante Feb 22, 2017
743f1e1
+ Bloom passes
mmerchante Feb 22, 2017
646a228
+ Sobel
mmerchante Feb 22, 2017
27fafc1
+ Gotta go fast!
mmerchante Feb 22, 2017
67f8da3
+ Some Kung Fury
mmerchante Feb 22, 2017
b1c9f89
+ Vignette
mmerchante Feb 22, 2017
399eda1
* Fix
mmerchante Feb 22, 2017
3261ad2
+ More tweaks
mmerchante Feb 22, 2017
ef39133
* Tweak
mmerchante Feb 22, 2017
c4d0ac6
Update README.md
mmerchante Mar 25, 2017
4b3d15b
* Image
mmerchante Mar 25, 2017
985f930
Update README.md
mmerchante Mar 25, 2017
d35a378
Update README.md
mmerchante Mar 25, 2017
5820342
Update README.md
mmerchante Mar 25, 2017
9520c44
Update README.md
mmerchante Mar 25, 2017
5b50e1c
Update README.md
mmerchante Mar 25, 2017
7ec8920
* Title
mmerchante Mar 25, 2017
2eb63fd
* Title
mmerchante Mar 25, 2017
04aa86f
- Removed stats and dat.gui
mmerchante Jun 15, 2017
1dfcb1e
* Reduced glare
mmerchante Jun 15, 2017
44a63ce
Create README.md
mmerchante Jun 15, 2017
aca44f4
Create README.md
mmerchante Jun 15, 2017
7e1f1a2
Create README.md
mmerchante Jun 15, 2017
b8cfb0d
Add user prompt to fix AudioContext
ascn Feb 16, 2022
435493c
Revert port change
ascn Feb 16, 2022
997580f
Merge pull request #1 from ascn/master
mmerchante Feb 16, 2022
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
134 changes: 11 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,11 @@

# Project 5: Shaders

## Project Instructions

Implement at least 75 points worth of shaders from the following list. We reserve the right to grant only partial credit for shaders that do not meet our standards, as well as extra credit for shaders that we find to be particularly impressive.

Some of these shading effects were covered in lecture -- some were not. If you wish to implement the more complex effects, you will have to perform some extra research. Of course, we encourage such academic curiosity which is why we’ve included these advanced shaders in the first place!

Document each shader you implement in your README with at least a sentence or two of explanation. Well-commented code will earn you many brownie (and probably sanity) points.

If you use shadertoy or any materials as reference, please properly credit your sources in the README and on top of the shader file. Failing to do so will result in plagiarism and will significantly reduce your points.

Examples: [https://cis700-procedural-graphics.github.io/Project5-Shaders/](https://cis700-procedural-graphics.github.io/Project5-Shaders/)

### 15 points each: Instagram-like filters

- Tone mapping:
- Linear (+5 points)
- Reinhard (+5 points)
- Filmic (+5 points)
- Gaussian blur (no double counting with Bloom)
- Iridescence
- Pointilism
- Vignette
- Fish-eye bulge

### 25 points each:
- Bloom
- Noise Warp
- Hatching
- Lit Sphere ([paper](http://www.ppsloan.org/publications/LitSphere.pdf))

### 37.5 points each:
- K-means color compression (unless you are extremely clever, the k-means clusterer has to be CPU side)
- Dithering
- Edge detection with Sobel filtering
- Uncharted 2 customizable filmic curve, following John Hable’s presetantion.
- Without Linear, Reinhard, filmic (+10 points)
- With all of linear, Reinhard, filmic (+10 points)
- Customizable via GUI (+17.5 points)
- Controlling Exposure (4 points)
- Side by side comparison between linear, Reinhard, filmic, and Uncharted2 (13.5 points).

### 5 points - Interactivity
Implement a dropdown GUI to select different shader effects from your list.

### ??? points
Propose your own shading effects!

### For the overachievers:
Weave all your shading effects into one aesthetically-coherent scene, perhaps by incorporating some of your previous assignments!


## Getting Started

### main.js

`main.js` is responsible for setting up the scene with the Mario mesh, initializing GUI and camera, etc.

### Adding Shaders

To add a shader, you'll want to add a file to the `src/shaders` or `src/post` folder. As examples, we've provided two shaders `lambert.js` and `grayscale.js`. Here, I will give a brief overview of how these work and how everything hooks together.

**shaders/lambert.js**

IMPORTANT: I make my lambert shader available by exporting it in `shaders/index.js`.

```javascript
export {default as Lambert} from './Lambert'
```

Each shader should export a function that takes in the `renderer`, `scene`, and `camera`. That function should return a `Shader` Object.

`Shader.initGUI` is a function that will be called to initialize the GUI for that shader. in `lambert.js`, you can see that it's here that I set up all the parameters that will affect my shader.

`Shader.material` should be a `THREE.ShaderMaterial`. This should be pretty similar to what you've seen in previous projects. `Shader.material.vertexShader` and `Shader.material.fragmentShader` are the vertex and fragment shaders used.

At the bottom, I have the following snippet of code. All it does is bind the Mario texture once it's loaded.

```javascript
textureLoaded.then(function(texture) {
Shader.material.uniforms.texture.value = texture;
});
```

So when you change the Shader parameter in the GUI, `Shader.initGUI(gui)` will be called to initialize the GUI, and then the Mario mesh will have `Shader.material` applied to it.

**post/grayscale.js**

GUI parameters here are initialized the same way they are for the other shaders.

Post process shaders should use the THREE.js `EffectComposer`. To set up the grayscale filter, I first create a new composer: `var composer = new EffectComposer(renderer);`. Then I add a a render pass as the first pass: `composer.addPass(new EffectComposer.RenderPass(scene, camera));`. This will set up the composer to render the scene as normal into a buffer. I add my filter to operate on that buffer: `composer.addPass(GrayscaleShader);`, and mark it as the final pass that will write to the screen `GrayscaleShader.renderToScreen = true;`

GrayscaleShader is a `EffectComposer.ShaderPass` which basically takes the same arguments as `THREE.ShaderMaterial`. Note, that one uniform that will have to include is `tDiffuse`. This is the texture sampler which the EffectComposer will automatically bind the previously rendered pass to. If you look at `glsl/grayscale-frag.glsl`, this is the texture we read from to get the previous pixel color: `vec4 col = texture2D(tDiffuse, f_uv);`.

IMPORTANT: You initially define your shader passes like so:

```javascript
var GrayscaleShader = new EffectComposer.ShaderPass({
uniforms: {
tDiffuse: {
type: 't',
value: null
},
u_amount: {
type: 'f',
value: options.amount
}
},
vertexShader: require('../glsl/pass-vert.glsl'),
fragmentShader: require('../glsl/grayscale-frag.glsl')
});
```

BUT, if you want to modify the uniforms, you need to do so like so: `GrayscaleShader.material.uniforms.u_amount.value = val;`. Note the extra `.material` property.

## Deploy

1. Create a `gh-pages` branch on GitHub
2. Do `npm run build`
3. Commit and add all your changes.
4. Do `npm run deploy`
# Procedural Rubik City

A short animation based on "To the Moon", by Dunderpatrullen. Done with three.JS and WebGL. Every element is procedural.

This was done as an assignment for a procedural graphics class I took at the University of Pennsylvania.

It was developed in approximately 5 days.

# [Try it!](https://mmerchante.github.io/procedural-rubik-city/)

![Alt text](/images/city.png?raw=true "")
38 changes: 38 additions & 0 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var colors = require('colors');
var path = require('path');
var git = require('simple-git')(__dirname);
var deploy = require('gh-pages-deploy');
var packageJSON = require('require-module')('./package.json');

var success = 1;
git.fetch('origin', 'master', function(err) {
if (err) throw err;
git.status(function(err, status) {
if (err) throw err;
if (!status.isClean()) {
success = 0;
console.error('Error: You have uncommitted changes! Please commit them first'.red);
}

if (status.current !== 'master') {
success = 0;
console.warn('Warning: Please deploy from the master branch!'.yellow)
}

git.diffSummary(['origin/master'], function(err, diff) {
if (err) throw err;

if (diff.files.length || diff.insertions || diff.deletions) {
success = 0;
console.error('Error: Current branch is different from origin/master! Please push all changes first'.red)
}

if (success) {
var cfg = packageJSON['gh-pages-deploy'] || {};
var buildCmd = deploy.getFullCmd(cfg);
deploy.displayCmds(deploy.getFullCmd(cfg));
deploy.execBuild(buildCmd, cfg);
}
})
})
})
Binary file added images/bg_vignette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bloom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/city.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/glitch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sobel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/vignette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Shader Demos</title>
<title>Mariano Merchante - To the moon!</title>
<style>
html, body {
margin: 0;
Expand All @@ -11,9 +11,18 @@
width: 100%;
height: 100%;
}
.overlay {
position: fixed;
color: White;
z-index: 100;
left: 50%;
top: 50%;
font-size: 30px;
}
</style>
</head>
<body>
<div class="overlay">▶</div>
<script src="bundle.js"></script>
</body>
</html>
</html>
Binary file added music/music.mp3
Binary file not shown.
34 changes: 23 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
{
"scripts": {
"start": "webpack-dev-server --hot --inline",
"deploy": "git push origin `git subtree split --prefix build master`:gh-pages --force",
"build": "webpack"
"build": "webpack",
"deploy": "node deploy.js"
},
"gh-pages-deploy": {
"prep": [
"build"
],
"noprompt": true
},
"dependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"dat-gui": "^0.5.0",
"file-loader": "^0.10.0",
"ease-component": "1.0.0",
"gl-matrix": "^2.3.2",
"random-js": "1.0.8",
"stats-js": "^1.0.0-alpha1",
"three": "^0.84.0",
"three": "^0.82.1",
"three-effectcomposer": "0.0.1",
"three-obj-loader": "^1.0.2",
"three-orbit-controls": "^82.1.0",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0",
"three-orbit-controls": "^82.1.0"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"colors": "^1.1.2",
"gh-pages-deploy": "^0.4.2",
"simple-git": "^1.65.0",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2",
"webpack-glsl-loader": "^1.0.1"
}
}
Binary file removed src/assets/wahoo.bmp
Binary file not shown.
Loading