[orx-dnk3] Add feature architecture and post processing effects
This commit is contained in:
38
orx-dnk3/src/main/kotlin/post/ScreenspaceReflections.kt
Normal file
38
orx-dnk3/src/main/kotlin/post/ScreenspaceReflections.kt
Normal file
@@ -0,0 +1,38 @@
|
||||
package org.openrndr.extra.dnk3.post
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.draw.filterShaderFromUrl
|
||||
import org.openrndr.math.Matrix44
|
||||
import org.openrndr.resourceUrl
|
||||
|
||||
class ScreenspaceReflections : Filter(preprocessedFilterShaderFromUrl(resourceUrl("/shaders/screenspace-reflections.frag"))) {
|
||||
var projection: Matrix44 by parameters
|
||||
var projectionMatrixInverse: Matrix44 by parameters
|
||||
|
||||
var colors: Int by parameters
|
||||
var projDepth: Int by parameters
|
||||
var normals: Int by parameters
|
||||
|
||||
var jitterOriginGain: Double by parameters
|
||||
var iterationLimit: Int by parameters
|
||||
var distanceLimit: Double by parameters
|
||||
var gain: Double by parameters
|
||||
var borderWidth: Double by parameters
|
||||
|
||||
init {
|
||||
colors = 0
|
||||
projDepth = 1
|
||||
normals = 2
|
||||
|
||||
projection = Matrix44.IDENTITY
|
||||
projectionMatrixInverse = Matrix44.IDENTITY
|
||||
|
||||
distanceLimit = 100.0
|
||||
iterationLimit = 128
|
||||
jitterOriginGain = 0.0
|
||||
|
||||
gain = 1.0
|
||||
borderWidth = 130.0
|
||||
}
|
||||
}
|
||||
45
orx-dnk3/src/main/kotlin/post/VolumetricIrradiance.kt
Normal file
45
orx-dnk3/src/main/kotlin/post/VolumetricIrradiance.kt
Normal file
@@ -0,0 +1,45 @@
|
||||
package org.openrndr.extra.dnk3.post
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.dnk3.features.IrradianceSH
|
||||
import org.openrndr.extra.shaderphrases.preprocessShader
|
||||
import org.openrndr.math.IntVector3
|
||||
import org.openrndr.math.Matrix44
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun preprocessedFilterShaderFromUrl(url: String): Shader {
|
||||
return filterShaderFromCode( preprocessShader(URL(url).readText()), "filter-shader: $url")
|
||||
}
|
||||
|
||||
fun preprocessedFilterShaderFromCode(fragmentShaderCode: String, name: String): Shader {
|
||||
return Shader.createFromCode(Filter.filterVertexCode, fragmentShaderCode, name)
|
||||
}
|
||||
|
||||
class VolumetricIrradiance : Filter(preprocessedFilterShaderFromUrl(resourceUrl("/shaders/volumetric-irradiance.frag"))) {
|
||||
|
||||
var stepLength: Double by parameters
|
||||
var irradianceSH: IrradianceSH? = null
|
||||
|
||||
var viewMatrixInverse: Matrix44 by parameters
|
||||
var projectionMatrixInverse: Matrix44 by parameters
|
||||
|
||||
init {
|
||||
stepLength = 0.1
|
||||
viewMatrixInverse = Matrix44.IDENTITY
|
||||
projectionMatrixInverse = Matrix44.IDENTITY
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
irradianceSH?.shMap?.let {
|
||||
parameters["shMap"] = it
|
||||
}
|
||||
irradianceSH?.let {
|
||||
parameters["shMapDimensions"] = IntVector3(it.xCount, it.yCount, it.zCount)
|
||||
parameters["shMapOffset"] = it.offset
|
||||
parameters["shMapSpacing"] = it.spacing
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user