Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Light Feature - GSOC 2023 #6255

Merged
merged 56 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
50a0c14
Added functions for diffused image light
Jul 6, 2023
dfa600c
Added functions for diffused image light
Jul 6, 2023
0521694
Merge branch 'main' into imageLight
Jul 10, 2023
b155bac
Merge branch 'main' into imageLight
Jul 13, 2023
34e6438
Added shaders and code to read them
Jul 13, 2023
916f5be
Merge branch 'main' into imageLight
Jul 20, 2023
c59ae6c
refactoring the ImageLight fragment shader
Jul 20, 2023
8b1e19c
added definition of map function in lightingglsl
Jul 21, 2023
5287a4f
removed errors
Jul 21, 2023
b05bca6
error correction
Jul 25, 2023
f6899a8
Merge branch 'main' into imageLight
Jul 25, 2023
8cd5775
corrected errors
Jul 25, 2023
3c9bf12
added comments
Aug 4, 2023
701cbee
added comments
Aug 4, 2023
4c63de5
Merge branch 'main' into imageLight
AryanKoundal Aug 5, 2023
b9837dc
made the changes from the build file test
AryanKoundal Aug 5, 2023
5546093
create a new map for storing the images and modifying the files where…
AryanKoundal Aug 6, 2023
98af50f
modifications according to the reviews
AryanKoundal Aug 8, 2023
8dbbff5
Merge branch 'main' into imageLight
AryanKoundal Aug 8, 2023
711c5f5
applied all the changes after debugging
AryanKoundal Aug 8, 2023
52c4d42
Merge branch 'main' into imageLight
AryanKoundal Aug 11, 2023
0121439
made changes according to the reviews
AryanKoundal Aug 11, 2023
8e9cd8a
Merge branch 'main' into imageLight
AryanKoundal Sep 8, 2023
7cf062d
Convert existing shaders to support GLES 300
davepagurek Sep 24, 2023
93a2428
Merge branch 'main' into imageLight
AryanKoundal Oct 10, 2023
d1c19b3
Merge branch 'imageLight' into feat/mipmap
davepagurek Oct 10, 2023
b803601
getting on track with main
AryanKoundal Oct 13, 2023
dc0ef6a
Merge branch 'main' into imageLight
AryanKoundal Oct 13, 2023
f0f3a19
Merge pull request #1 from davepagurek/feat/mipmap
AryanKoundal Oct 13, 2023
02d6f00
added code for specular light
AryanKoundal Oct 14, 2023
9a0c3fc
Merge branch 'main' into imageLight
AryanKoundal Oct 14, 2023
0860bd7
Fix tests
davepagurek Oct 15, 2023
0ade514
modifications to rendererGl and lighting.glsl
AryanKoundal Oct 18, 2023
07371e8
Merge branch 'main' into imageLight
AryanKoundal Oct 18, 2023
25a711b
Merge pull request #2 from davepagurek/feat/mipmap
AryanKoundal Oct 18, 2023
c04d916
additions
AryanKoundal Oct 23, 2023
9dbe8a0
Merge branch 'main' into imageLight
AryanKoundal Oct 23, 2023
5cac577
Fall back to regular texture on WebGL1
davepagurek Oct 23, 2023
5547d7d
resolved errors
AryanKoundal Oct 26, 2023
ff3973d
Merge branch 'main' into imageLight
AryanKoundal Oct 26, 2023
b37afe5
Updated the outcolor
AryanKoundal Oct 26, 2023
69008c0
added comments
AryanKoundal Oct 26, 2023
d713b35
resolved pow error and added documentation
AryanKoundal Oct 26, 2023
6656e90
added documentation and example
AryanKoundal Oct 27, 2023
374051b
resolved imageLight documentation example error
AryanKoundal Oct 27, 2023
b964403
modified timeout to 25sec for imageLight examples to work
AryanKoundal Oct 27, 2023
0e7c3bc
modified timeout to 25sec for imageLight examples to work
AryanKoundal Oct 27, 2023
14aed59
changed settimeout back to original 4sec limit and changed the image …
AryanKoundal Oct 27, 2023
5d99712
Merge branch 'main' into imageLight
AryanKoundal Oct 27, 2023
4fe2890
slight modifications on the suggestions
AryanKoundal Oct 28, 2023
6fec78a
resolved suggestion
AryanKoundal Oct 30, 2023
94e639b
used WorldNormalInstead of R in lighting.glgl
AryanKoundal Oct 31, 2023
f2c0f1e
changed angles in lighting.glsl
AryanKoundal Oct 31, 2023
e68f9f0
added images in examples and removed unnecessary code
AryanKoundal Oct 31, 2023
6df91ec
Merge branch 'main' into imageLight
AryanKoundal Nov 3, 2023
fe5e0db
replaced asset with smaller size
AryanKoundal Nov 3, 2023
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
Binary file added docs/yuidoc-p5-theme/assets/outdoor_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions src/webgl/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,99 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
return this;
};

/**
* Creates an image light with the given image.
*
* The image light simulates light from all the directions.
* This is done by using the image as a texture for an infinitely
* large sphere light. This sphere contains
* or encapsulates the whole scene/drawing.
* It will have different effect for varying shininess of the
* object in the drawing.
* Under the hood it is mainly doing 2 types of calculations,
* the first one is creating an irradiance map the
* environment map of the input image.
* The second one is managing reflections based on the shininess
* or roughness of the material used in the scene.
*
* Note: The image's diffuse light will be affected by fill()
* and the specular reflections will be affected by specularMaterial()
* and shininess().
*
* @method imageLight
* @param {p5.image} img image for the background
* @example
* <div class="notest">
* <code>
* let img;
* function preload() {
* img = loadImage('assets/outdoor_image.jpg');
* }
* function setup() {
* createCanvas(100, 100, WEBGL);
* }
* function draw() {
* background(220);
* imageMode(CENTER);
* push();
* translate(0, 0, -200);
* scale(2);
* image(img, 0, 0, width, height);
davepagurek marked this conversation as resolved.
Show resolved Hide resolved
* pop();
* ambientLight(50);
* imageLight(img);
* specularMaterial(20);
* noStroke();
* scale(2);
* rotateX(frameCount * 0.005);
* rotateY(frameCount * 0.005);
* box(25);
* }
* </code>
* </div>
* @alt
* image light example
* @example
* <div class="notest">
* <code>
* let img;
* let slider;
* function preload() {
* img = loadImage('assets/outdoor_spheremap.jpg');
* }
* function setup() {
* createCanvas(100, 100, WEBGL);
* slider = createSlider(0, 400, 100, 1);
* slider.position(0, height);
* }
* function draw() {
* background(220);
* imageMode(CENTER);
* push();
* translate(0, 0, -200);
* scale(2);
* image(img, 0, 0, width, height);
* pop();
* ambientLight(50);
* imageLight(img);
* specularMaterial(20);
* shininess(slider.value());
* noStroke();
* scale(2);
* sphere(15);
* }
* </code>
* </div>
* @alt
* light with slider having a slider for varying roughness
*/
p5.prototype.imageLight = function(img){
davepagurek marked this conversation as resolved.
Show resolved Hide resolved
// activeImageLight property is checked by _setFillUniforms
// for sending uniforms to the fillshader
this._renderer.activeImageLight = img;
davepagurek marked this conversation as resolved.
Show resolved Hide resolved
this._renderer._enableLighting = true;
};

/**
* Places an ambient and directional light in the scene.
* The lights are set to ambientLight(128, 128, 128) and
Expand Down
Loading
Loading