Demos: ensure 720px wide, reduce indentation
openrndr-demos, orx-color, orx-jumpflood, orx-no-clear
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.loadImage
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val image16 = loadImage("demo-data/images/16-bit.png")
|
||||
val image8 = loadImage("demo-data/images/image-001.png")
|
||||
extend {
|
||||
drawer.image(image16)
|
||||
drawer.image(image8, 320.0, 0.0)
|
||||
}
|
||||
fun main() = application {
|
||||
program {
|
||||
val image16 = loadImage("demo-data/images/16-bit.png")
|
||||
val image8 = loadImage("demo-data/images/image-001.png")
|
||||
extend {
|
||||
drawer.image(image16)
|
||||
drawer.image(image8, 320.0, 0.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.internal.colorBufferLoader
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
val proxy = colorBufferLoader.loadFromUrl("https://avatars3.githubusercontent.com/u/31103334?s=200&v=4")
|
||||
proxy.colorBuffer?.let {
|
||||
drawer.image(it)
|
||||
}
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
val proxy = colorBufferLoader.loadFromUrl("https://avatars3.githubusercontent.com/u/31103334?s=200&v=4")
|
||||
proxy.colorBuffer?.let {
|
||||
drawer.image(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,12 @@ import org.openrndr.math.Vector3
|
||||
|
||||
|
||||
fun main() = application {
|
||||
|
||||
configure {
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
extend(Orbital())
|
||||
|
||||
|
||||
val circlePositions = vertexBuffer(vertexFormat {
|
||||
attribute("position", VertexElementType.VECTOR3_FLOAT32)
|
||||
attribute("scale", VertexElementType.FLOAT32)
|
||||
@@ -31,7 +29,6 @@ fun main() = application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extend {
|
||||
drawer.perspective(90.0, width*1.0/height*1.0, 0.1, 100.0)
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ import org.openrndr.shape.ShapeContour
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val points = List(6) { Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center }
|
||||
val points = List(6) {
|
||||
Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center
|
||||
}
|
||||
val cmr = CatmullRomChain2(points, 1.0, loop = true)
|
||||
val contour = ShapeContour.fromPoints(cmr.positions(200), true)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ This program demonstrates dynamic circle batches
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.GRAY)
|
||||
drawer.circles {
|
||||
|
||||
@@ -12,7 +12,6 @@ fun main() {
|
||||
}
|
||||
|
||||
program {
|
||||
|
||||
val cs = Rectangle(0.0, 0.0, 200.0, 200.0).contour
|
||||
val cc = Circle(100.0, 0.0, 100.0).contour
|
||||
|
||||
|
||||
@@ -5,33 +5,35 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.Rectangle
|
||||
import org.openrndr.shape.intersections
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
val circle = Circle(mouse.position, 200.0).contour
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
val circle = Circle(mouse.position, 200.0).contour
|
||||
|
||||
drawer.fill = null
|
||||
for (y in 50 until height step 100) {
|
||||
for (x in 50 until width step 100) {
|
||||
drawer.fill = null
|
||||
for (y in 50 until height step 100) {
|
||||
for (x in 50 until width step 100) {
|
||||
|
||||
for (ring in 0 until 10) {
|
||||
val r = Rectangle.fromCenter(Vector2(x * 1.0, y * 1.0), 90.0 - ring * 8.0, 90.0 - ring * 8.0).contour
|
||||
for (ring in 0 until 10) {
|
||||
val r = Rectangle.fromCenter(
|
||||
Vector2(x * 1.0, y * 1.0),
|
||||
90.0 - ring * 8.0,
|
||||
90.0 - ring * 8.0
|
||||
).contour
|
||||
|
||||
val ints = intersections(circle, r)
|
||||
if (ints.isEmpty()) {
|
||||
drawer.stroke = ColorRGBa.GREEN
|
||||
drawer.contour(r)
|
||||
} else {
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
ints.map { it.b.contourT }.let { it + it.take(1) }.zipWithNext().forEach {
|
||||
val end = if (it.second <= it.first) it.second + 1.0 else it.second
|
||||
val sub = r.sub(it.first, end)
|
||||
val length = sub.length
|
||||
val ta = sub.tForLength(2.0)
|
||||
val tb = sub.tForLength(length - 2.0)
|
||||
drawer.contour(sub.sub(ta, tb))
|
||||
}
|
||||
val ints = intersections(circle, r)
|
||||
if (ints.isEmpty()) {
|
||||
drawer.stroke = ColorRGBa.GREEN
|
||||
drawer.contour(r)
|
||||
} else {
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
ints.map { it.b.contourT }.let { it + it.take(1) }.zipWithNext().forEach {
|
||||
val end = if (it.second <= it.first) it.second + 1.0 else it.second
|
||||
val sub = r.sub(it.first, end)
|
||||
val length = sub.length
|
||||
val ta = sub.tForLength(2.0)
|
||||
val tb = sub.tForLength(length - 2.0)
|
||||
drawer.contour(sub.sub(ta, tb))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,4 +41,4 @@ fun main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ fun main() = application {
|
||||
val points = 200
|
||||
extend {
|
||||
val contour = ShapeContour.fromPoints(
|
||||
List(points) {
|
||||
val a = PI * 2 * it / points
|
||||
val x = (200 + 50 * cos(a * 2)) * sin(a * 3 + sin(a))
|
||||
val y = 150 * cos(a * 2 + seconds * 0.2)
|
||||
Vector2(x, y)
|
||||
}, closed = true
|
||||
List(points) {
|
||||
val a = PI * 2 * it / points
|
||||
val x = (200 + 50 * cos(a * 2)) * sin(a * 3 + sin(a))
|
||||
val y = 150 * cos(a * 2 + seconds * 0.2)
|
||||
Vector2(x, y)
|
||||
}, closed = true
|
||||
)
|
||||
val ints = intersections(contour, contour)
|
||||
drawer.run {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.draw.Session
|
||||
import org.openrndr.draw.loadCubemap
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val cubemap = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
|
||||
val cube = boxMesh()
|
||||
extend(Orbital()) {
|
||||
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
|
||||
@@ -7,13 +7,17 @@ fun main() = application {
|
||||
program {
|
||||
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
|
||||
val cube = boxMesh()
|
||||
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
|
||||
val cubemap2 = cubemap(
|
||||
cubemap1.width,
|
||||
format = cubemap1.format,
|
||||
type = cubemap1.type,
|
||||
levels = 2,
|
||||
session = Session.active
|
||||
)
|
||||
cubemap1.copyTo(cubemap2, 0, 0)
|
||||
cubemap2.generateMipmaps()
|
||||
|
||||
extend(Orbital()) {
|
||||
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
|
||||
@@ -7,7 +7,13 @@ fun main() = application {
|
||||
program {
|
||||
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
|
||||
val cube = boxMesh()
|
||||
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
|
||||
val cubemap2 = cubemap(
|
||||
cubemap1.width,
|
||||
format = cubemap1.format,
|
||||
type = cubemap1.type,
|
||||
levels = 2,
|
||||
session = Session.active
|
||||
)
|
||||
cubemap1.copyTo(cubemap2, 0, 0)
|
||||
cubemap2.generateMipmaps()
|
||||
|
||||
@@ -18,9 +24,7 @@ fun main() = application {
|
||||
|
||||
cma.generateMipmaps()
|
||||
|
||||
extend(Orbital()) {
|
||||
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.loadImage
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.dds")
|
||||
println(image.format)
|
||||
println(image.type)
|
||||
extend {
|
||||
drawer.image(image)
|
||||
}
|
||||
fun main() = application {
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.dds")
|
||||
println(image.format)
|
||||
println(image.type)
|
||||
extend {
|
||||
drawer.image(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,27 +6,25 @@ import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.resourceText
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val vb = boxMesh()
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/gs-01.vert"),
|
||||
gsCode = resourceText("/shaders/gs-01.geom"),
|
||||
fsCode = resourceText("/shaders/gs-01.frag"),
|
||||
name = "x"
|
||||
)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
}
|
||||
fun main() = application {
|
||||
program {
|
||||
val vb = boxMesh()
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/gs-01.vert"),
|
||||
gsCode = resourceText("/shaders/gs-01.geom"),
|
||||
fsCode = resourceText("/shaders/gs-01.frag"),
|
||||
name = "x"
|
||||
)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ import org.openrndr.extra.meshgenerators.planeMesh
|
||||
import org.openrndr.internal.Driver
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val shader = Shader.createFromCode(vsCode =
|
||||
"""${Driver.instance.shaderConfiguration()}
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode =
|
||||
"""${Driver.instance.shaderConfiguration(ShaderType.VERTEX)}
|
||||
in vec3 a_position;
|
||||
in vec2 a_texCoord0;
|
||||
in vec3 a_normal;
|
||||
@@ -21,14 +20,15 @@ void main() {
|
||||
gl_Position = projMatrix * vec4(a_position, 1.0);
|
||||
}
|
||||
""",
|
||||
fsCode = """${Driver.instance.shaderConfiguration()}
|
||||
fsCode = """${Driver.instance.shaderConfiguration(ShaderType.FRAGMENT)}
|
||||
out vec4 o_color;
|
||||
layout(rgba8) uniform writeonly image2D bla;
|
||||
void main() {
|
||||
imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
o_color = vec4(1.0);
|
||||
o_color = vec4(1.0);
|
||||
}
|
||||
""", name = "ils")
|
||||
""", name = "ils"
|
||||
)
|
||||
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
|
||||
val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0)
|
||||
|
||||
@@ -44,6 +44,5 @@ void main() {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.image(cb)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
|
||||
@@ -15,7 +14,6 @@ fun main() = application {
|
||||
image("image", cb.imageBinding(0, ImageAccess.WRITE))
|
||||
}
|
||||
extend {
|
||||
|
||||
drawer.shadeStyle = ss
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.color.rgb
|
||||
import org.openrndr.draw.*
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val cb = colorBuffer(128, 128)
|
||||
val at = arrayTexture(128, 128, 32)
|
||||
val vt = volumeTexture(32, 32, 32)
|
||||
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
|
||||
val at = arrayTexture(128, 128, 32, type = ColorType.UINT8)
|
||||
val vt = volumeTexture(32, 32, 32, type = ColorType.UINT8)
|
||||
extend {
|
||||
val ss = shadeStyle {
|
||||
fragmentTransform = """
|
||||
@@ -16,12 +15,13 @@ fun main() = application {
|
||||
imageStore(p_at, ivec3(2, 2, 2), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
""".trimIndent()
|
||||
|
||||
parameter("at", at.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
parameter("vt", vt.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
image("at", at.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
image("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
image("vt", vt.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
}
|
||||
drawer.shadeStyle = ss
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.clear(rgb(0.1))
|
||||
drawer.fill = rgb(0.2)
|
||||
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
|
||||
drawer.image(cb, 0.0, 200.0)
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ fun main() {
|
||||
stroke = ColorRGBa.PINK
|
||||
strokeWeight = 8.0
|
||||
fontMap = font
|
||||
LineCap.values().forEachIndexed { x, cap ->
|
||||
LineCap.entries.forEachIndexed { x, cap ->
|
||||
lineCap = cap
|
||||
LineJoin.values().forEachIndexed { y, join ->
|
||||
LineJoin.entries.forEachIndexed { y, join ->
|
||||
lineJoin = join
|
||||
val pos = IntVector2(x - 1, y - 1).vector2 * 180.0
|
||||
isolated {
|
||||
|
||||
@@ -8,7 +8,8 @@ fun main() = application {
|
||||
program {
|
||||
val style = shadeStyle {
|
||||
//fragmentTransform = "x_stroke.a *= step(0.5, fract(c_contourPosition / p_dashLen));"
|
||||
fragmentTransform = "x_stroke.a *= smoothstep(0.0, 1.0, mod(c_contourPosition, p_dashLen)) * smoothstep(p_dashLen, p_dashLen-1.0, mod(c_contourPosition, p_dashLen));"
|
||||
fragmentTransform =
|
||||
"x_stroke.a *= smoothstep(0.0, 1.0, mod(c_contourPosition, p_dashLen)) * smoothstep(p_dashLen, p_dashLen-1.0, mod(c_contourPosition, p_dashLen));"
|
||||
parameter("dashLen", 20.0)
|
||||
}
|
||||
extend {
|
||||
@@ -25,8 +26,7 @@ fun main() = application {
|
||||
shadeStyle = style
|
||||
contour(c)
|
||||
|
||||
drawer.lineSegment(0.0, 0.0, width*1.0, height*1.0)
|
||||
|
||||
drawer.lineSegment(0.0, 0.0, width * 1.0, height * 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,36 +8,34 @@ import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.ffmpeg.VideoPlayerFFMPEG
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val cube = boxMesh()
|
||||
val screen = VideoPlayerFFMPEG.fromScreen(
|
||||
frameRate = 15.0,
|
||||
imageWidth = 300,
|
||||
imageHeight = 300
|
||||
)
|
||||
fun main() = application {
|
||||
program {
|
||||
val cube = boxMesh()
|
||||
val screen = VideoPlayerFFMPEG.fromScreen(
|
||||
frameRate = 15.0,
|
||||
imageWidth = 300,
|
||||
imageHeight = 300
|
||||
)
|
||||
|
||||
screen.play()
|
||||
extend {
|
||||
screen.draw(drawer, true) // update the screen grabber
|
||||
drawer.isolated {
|
||||
clear(ColorRGBa.WHITE)
|
||||
perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
|
||||
depthWrite = true
|
||||
depthTestPass = DepthTestPass.LESS_OR_EQUAL
|
||||
shadeStyle = shadeStyle {
|
||||
fragmentTransform = "x_fill = texture(p_tex, vec2(1.0-va_texCoord0.x, va_texCoord0.y));"
|
||||
screen.colorBuffer?.run {
|
||||
parameter("tex", this)
|
||||
}
|
||||
screen.play()
|
||||
extend {
|
||||
screen.draw(drawer, true) // update the screen grabber
|
||||
drawer.isolated {
|
||||
clear(ColorRGBa.WHITE)
|
||||
perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
|
||||
depthWrite = true
|
||||
depthTestPass = DepthTestPass.LESS_OR_EQUAL
|
||||
shadeStyle = shadeStyle {
|
||||
fragmentTransform = "x_fill = texture(p_tex, vec2(1.0-va_texCoord0.x, va_texCoord0.y));"
|
||||
screen.colorBuffer?.run {
|
||||
parameter("tex", this)
|
||||
}
|
||||
rotate(Vector3.UNIT_Z, 90.0)
|
||||
translate(0.0, 0.0, -120.0)
|
||||
rotate(Vector3.UNIT_X, seconds * 10)
|
||||
scale(90.0)
|
||||
vertexBuffer(cube, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
rotate(Vector3.UNIT_Z, 90.0)
|
||||
translate(0.0, 0.0, -120.0)
|
||||
rotate(Vector3.UNIT_X, seconds * 10)
|
||||
scale(90.0)
|
||||
vertexBuffer(cube, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.draw.BufferPrimitiveType
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.draw.shaderStorageBuffer
|
||||
import org.openrndr.draw.shaderStorageFormat
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
|
||||
@@ -46,6 +49,5 @@ fun main() = application {
|
||||
// Therefore the value of `f1` can vary from frame to frame,
|
||||
// because we don't know how many times `+= 2.0` was executed.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,46 +7,44 @@ import org.openrndr.draw.vertexFormat
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.resourceText
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, 12)
|
||||
val shader = Shader.Companion.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-01.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-01.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-01.tese"),
|
||||
fsCode = resourceText("/shaders/ts-01.frag"),
|
||||
name = "x"
|
||||
)
|
||||
fun main() = application {
|
||||
program {
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, 12)
|
||||
val shader = Shader.Companion.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-01.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-01.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-01.tese"),
|
||||
fsCode = resourceText("/shaders/ts-01.frag"),
|
||||
name = "x"
|
||||
)
|
||||
|
||||
vb.put {
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 300.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 400.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 500.0, 0.0))
|
||||
}
|
||||
vb.put {
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 300.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 400.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 500.0, 0.0))
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
|
||||
shader.end()
|
||||
}
|
||||
shader.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,45 +7,43 @@ import org.openrndr.draw.vertexFormat
|
||||
import org.openrndr.resourceText
|
||||
import org.openrndr.shape.Ellipse
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val ellipse = Ellipse(width/2.0, height/2.0, 100.0, 300.0).contour
|
||||
fun main() = application {
|
||||
program {
|
||||
val ellipse = Ellipse(width / 2.0, height / 2.0, 100.0, 300.0).contour
|
||||
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, ellipse.segments.size * 4)
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, ellipse.segments.size * 4)
|
||||
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-02.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-02.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-02.tese"),
|
||||
gsCode = resourceText("/shaders/ts-02.geom"),
|
||||
fsCode = resourceText("/shaders/ts-02.frag"),
|
||||
name = "x"
|
||||
)
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-02.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-02.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-02.tese"),
|
||||
gsCode = resourceText("/shaders/ts-02.geom"),
|
||||
fsCode = resourceText("/shaders/ts-02.frag"),
|
||||
name = "x"
|
||||
)
|
||||
|
||||
vb.put {
|
||||
for (segment in ellipse.segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start.xy0)
|
||||
write(cubic.control[0].xy0)
|
||||
write(cubic.control[1].xy0)
|
||||
write(cubic.end.xy0)
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
vb.put {
|
||||
for (segment in ellipse.segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start.xy0)
|
||||
write(cubic.control[0].xy0)
|
||||
write(cubic.control[1].xy0)
|
||||
write(cubic.end.xy0)
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,51 +7,49 @@ import org.openrndr.draw.vertexFormat
|
||||
import org.openrndr.resourceText
|
||||
import org.openrndr.shape.Ellipse
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val ellipse = Ellipse(width/2.0, height/2.0, 100.0, 200.0).contour
|
||||
val ellipse = Ellipse(width / 2.0, height / 2.0, 100.0, 200.0).contour
|
||||
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, ellipse.segments.size * 4)
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, ellipse.segments.size * 4)
|
||||
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-03.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-03.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-03.tese"),
|
||||
gsCode = resourceText("/shaders/ts-03.geom"),
|
||||
fsCode = resourceText("/shaders/ts-03.frag"),
|
||||
name = "x"
|
||||
)
|
||||
val shader = Shader.createFromCode(
|
||||
vsCode = resourceText("/shaders/ts-03.vert"),
|
||||
tcsCode = resourceText("/shaders/ts-03.tesc"),
|
||||
tesCode = resourceText("/shaders/ts-03.tese"),
|
||||
gsCode = resourceText("/shaders/ts-03.geom"),
|
||||
fsCode = resourceText("/shaders/ts-03.frag"),
|
||||
name = "x"
|
||||
)
|
||||
|
||||
vb.put {
|
||||
for (segment in ellipse.segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start.xy0)
|
||||
write(cubic.control[0].xy0)
|
||||
write(cubic.control[1].xy0)
|
||||
write(cubic.end.xy0)
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.translate(width/2.0, height/2.0, 0.0)
|
||||
drawer.rotate(seconds*45.0)
|
||||
drawer.translate(-width/2.0, -height/2.0, 0.0)
|
||||
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
|
||||
shader.uniform("weight",((mouse.position.y / height) * 128 + 1) )
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
vb.put {
|
||||
for (segment in ellipse.segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start.xy0)
|
||||
write(cubic.control[0].xy0)
|
||||
write(cubic.control[1].xy0)
|
||||
write(cubic.end.xy0)
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.translate(width / 2.0, height / 2.0, 0.0)
|
||||
drawer.rotate(seconds * 45.0)
|
||||
drawer.translate(-width / 2.0, -height / 2.0, 0.0)
|
||||
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", ((mouse.position.x / width) * 63 + 1).toInt())
|
||||
shader.uniform("weight", ((mouse.position.y / height) * 128 + 1))
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +1,67 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.noise.uniformRing
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.camera.OrbitalCamera
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
import org.openrndr.extra.noise.uniformRing
|
||||
import org.openrndr.extra.shaderphrases.preprocessedFromUrls
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.resourceUrl
|
||||
import org.openrndr.shape.Ellipse
|
||||
import org.openrndr.shape.path3D
|
||||
|
||||
import org.openrndr.extra.shaderphrases.preprocessedFromUrls
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend(Orbital())
|
||||
fun main() = application {
|
||||
program {
|
||||
extend(Orbital())
|
||||
|
||||
val path = path3D {
|
||||
moveTo(Vector3.ZERO)
|
||||
for (i in 0 until 100) {
|
||||
continueTo(anchor + Vector3.uniformRing(0.0, 10.0),anchor + Vector3.uniformRing(0.0, 10.0))
|
||||
}
|
||||
}
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, path.segments.size * 4)
|
||||
|
||||
val shader = Shader.preprocessedFromUrls(
|
||||
vsUrl = resourceUrl("/shaders/ts-04.vert"),
|
||||
tcsUrl = resourceUrl("/shaders/ts-04.tesc"),
|
||||
tesUrl = resourceUrl("/shaders/ts-04.tese"),
|
||||
gsUrl = resourceUrl("/shaders/ts-04.geom"),
|
||||
fsUrl = resourceUrl("/shaders/ts-04.frag")
|
||||
)
|
||||
|
||||
val mesh = sphereMesh()
|
||||
extend {
|
||||
val vc = vb.put {
|
||||
for (segment in path.sub(0.0, cos(seconds*0.1)*0.5+ 0.5).segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start)
|
||||
write(cubic.control[0])
|
||||
write(cubic.control[1])
|
||||
write(cubic.end)
|
||||
}
|
||||
}
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
|
||||
drawer.depthWrite = true
|
||||
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
|
||||
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", 32)
|
||||
shader.uniform("weight", 3.0 + cos(seconds))
|
||||
shader.uniform("time", seconds*0.0)
|
||||
drawer.depthWrite = false
|
||||
|
||||
driver.setState(drawer.drawStyle)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vc)
|
||||
shader.end()
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
val path = path3D {
|
||||
moveTo(Vector3.ZERO)
|
||||
for (i in 0 until 100) {
|
||||
continueTo(anchor + Vector3.uniformRing(0.0, 10.0), anchor + Vector3.uniformRing(0.0, 10.0))
|
||||
}
|
||||
}
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, path.segments.size * 4)
|
||||
|
||||
val shader = Shader.preprocessedFromUrls(
|
||||
vsUrl = resourceUrl("/shaders/ts-04.vert"),
|
||||
tcsUrl = resourceUrl("/shaders/ts-04.tesc"),
|
||||
tesUrl = resourceUrl("/shaders/ts-04.tese"),
|
||||
gsUrl = resourceUrl("/shaders/ts-04.geom"),
|
||||
fsUrl = resourceUrl("/shaders/ts-04.frag")
|
||||
)
|
||||
|
||||
val mesh = sphereMesh()
|
||||
extend {
|
||||
val vc = vb.put {
|
||||
for (segment in path.sub(0.0, cos(seconds * 0.1) * 0.5 + 0.5).segments) {
|
||||
val cubic = segment.cubic
|
||||
write(cubic.start)
|
||||
write(cubic.control[0])
|
||||
write(cubic.control[1])
|
||||
write(cubic.end)
|
||||
}
|
||||
}
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
|
||||
drawer.depthWrite = true
|
||||
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
|
||||
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
shader.uniform("resolution", 32)
|
||||
shader.uniform("weight", 3.0 + cos(seconds))
|
||||
shader.uniform("time", seconds * 0.0)
|
||||
drawer.depthWrite = false
|
||||
|
||||
driver.setState(drawer.drawStyle)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vc)
|
||||
shader.end()
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.openrndr.draw.*
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val volumeTexture = VolumeTexture.create(128,128,32, type = ColorType.UINT8)
|
||||
val volumeTexture = VolumeTexture.create(128, 128, 32, type = ColorType.UINT8)
|
||||
val rt = renderTarget(128, 128) {
|
||||
volumeTexture(volumeTexture, 0)
|
||||
}
|
||||
|
||||
@@ -31,9 +31,11 @@ fun main() = application {
|
||||
|
||||
// Rectangles with the bottom right corner centered in the window
|
||||
drawer.rectangles(List(10) {
|
||||
Rectangle(drawer.bounds.center,
|
||||
-squareSize * 2 + it * 10,
|
||||
-squareSize * 2 + it * 10)
|
||||
Rectangle(
|
||||
drawer.bounds.center,
|
||||
-squareSize * 2 + it * 10,
|
||||
-squareSize * 2 + it * 10
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,9 @@ fun main() = application {
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.rectangles {
|
||||
for (y in 0 until height/20) {
|
||||
for (x in 0 until width/20) {
|
||||
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds*90.0)
|
||||
|
||||
for (y in 0 until height / 20) {
|
||||
for (x in 0 until width / 20) {
|
||||
rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds * 90.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user