diff --git a/src/core/main.js b/src/core/main.js
index 0e19d75ec1..831735ece9 100644
--- a/src/core/main.js
+++ b/src/core/main.js
@@ -867,6 +867,23 @@ class p5 {
// This is a pointer to our global mode p5 instance, if we're in
// global mode.
+/**
+ * A variable that stores a reference to the sketch's p5 instance.
+ *
+ * In global mode, `p5.instance` refers to the sketch's p5 instance. It's
+ * useful when a function or method needs a reference to the sketch. For
+ * example, it can be used with
+ * copyToContext() to copy a
+ * p5.Shader object from a
+ * p5.Graphics object to the main canvas.
+ *
+ * Note: `p5.instance` is only available in global mode. In instance mode,
+ * use the instance variable instead.
+ *
+ * @property {p5} instance
+ * @for p5
+ * @readOnly
+ */
p5.instance = null;
/**
diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js
index a82f112361..18af8d78a2 100644
--- a/src/webgl/p5.Shader.js
+++ b/src/webgl/p5.Shader.js
@@ -587,7 +587,7 @@ p5.Shader = class {
* p5.Graphics, as in
* `myShader.copyToContext(pg)`. The shader can also be copied from a
* p5.Graphics object to the main canvas using
- * the `window` variable, as in `myShader.copyToContext(window)`.
+ * p5.instance, as in `myShader.copyToContext(p5.instance)`.
*
* Note: A p5.Shader object created with
* createShader(),
@@ -729,7 +729,7 @@ p5.Shader = class {
* pg.shader(original);
*
* // Copy the original shader to the main canvas.
- * copied = original.copyToContext(window);
+ * copied = original.copyToContext(p5.instance);
*
* // Apply the copied shader to the main canvas.
* shader(copied);