-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles000.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles001.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles002.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles003.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles004.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/examples/06_Advanced_drawing/C140_Shade_styles005.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
package examples.`06_Advanced_drawing` | ||
|
||
import org.intellij.lang.annotations.Language | ||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.draw.* | ||
import org.openrndr.extra.camera.OrbitalCamera | ||
import org.openrndr.extra.meshgenerators.sphereMesh | ||
import org.openrndr.math.Vector3 | ||
import org.openrndr.shape.Circle | ||
import kotlin.math.cos | ||
import kotlin.math.sin | ||
|
||
fun main() { | ||
application { | ||
program { | ||
val style = shadeStyle { | ||
// Define the `random` function and declare a `c` | ||
// variable to pass to the fragment shader. | ||
vertexPreamble = """ | ||
float random(vec2 st) { | ||
return fract(sin(dot(st.xy, | ||
vec2(12.9898, 78.233))) * 43758.5453123); | ||
} | ||
out vec3 c; | ||
""".trimIndent() | ||
|
||
// Calculate the value of `c` per vertex. | ||
// It will get interpolated by the GPU. | ||
vertexTransform = """ | ||
c.r = random(x_position.xy); | ||
c.g = random(x_position.yx); | ||
c.b = random(x_position.xy + 1.0); | ||
""".trimIndent() | ||
|
||
// Declare a `c` variable to receive from the vertex shader. | ||
fragmentPreamble = "in vec3 c;" | ||
// Use the value of `c` to set the color of a pixel. | ||
fragmentTransform = "x_fill.rgb = c;" | ||
} | ||
extend { | ||
drawer.shadeStyle = style | ||
repeat(7) { | ||
// Notice how we do not set `drawer.fill`. | ||
drawer.rectangle(50.0 + it * 77, 50.0, 70.0, 390.0) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|