[orx-fx] Add noiseGain and noiseSeed to MipBloom
This commit is contained in:
@@ -82,6 +82,7 @@ fun main() {
|
|||||||
blur.window = 5
|
blur.window = 5
|
||||||
blur.sigma = 3.0
|
blur.sigma = 3.0
|
||||||
blur.gain = 3.0
|
blur.gain = 3.0
|
||||||
|
blur.noiseSeed = seconds
|
||||||
}
|
}
|
||||||
is FrameBlur -> {
|
is FrameBlur -> {
|
||||||
blur.blend = 0.05
|
blur.blend = 0.05
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ class BloomDownscale : Filter(filterShaderFromUrl(filterFragmentUrl("blur/bloom-
|
|||||||
class BloomUpscale : Filter(filterShaderFromUrl(filterFragmentUrl("blur/bloom-upscale.frag"))) {
|
class BloomUpscale : Filter(filterShaderFromUrl(filterFragmentUrl("blur/bloom-upscale.frag"))) {
|
||||||
var gain: Double by parameters
|
var gain: Double by parameters
|
||||||
var shape: Double by parameters
|
var shape: Double by parameters
|
||||||
var seed: Double by parameters
|
var noiseSeed: Double by parameters
|
||||||
|
var noiseGain: Double by parameters
|
||||||
|
|
||||||
init {
|
init {
|
||||||
gain = 1.0
|
gain = 1.0
|
||||||
shape = 1.0
|
shape = 1.0
|
||||||
seed = 1.0
|
noiseSeed = 1.0
|
||||||
|
noiseGain = 0.25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +48,15 @@ open class MipBloom<T : Filter>(val blur: T) : Filter(filterShaderFromUrl(filter
|
|||||||
@DoubleParameter("gain", 0.0, 4.0)
|
@DoubleParameter("gain", 0.0, 4.0)
|
||||||
var gain: Double = 1.0
|
var gain: Double = 1.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* noise gain. low noise gains will result in visible banding of the image. default value is 0.25
|
||||||
|
*/
|
||||||
|
@DoubleParameter("noise gain", 0.0, 1.0)
|
||||||
|
var noiseGain: Double = 0.25
|
||||||
|
|
||||||
|
@DoubleParameter("noise seed", 0.0, 1000.0)
|
||||||
|
var noiseSeed: Double = 0.0
|
||||||
|
|
||||||
@BooleanParameter("sRGB")
|
@BooleanParameter("sRGB")
|
||||||
var sRGB = true
|
var sRGB = true
|
||||||
|
|
||||||
@@ -89,6 +100,8 @@ open class MipBloom<T : Filter>(val blur: T) : Filter(filterShaderFromUrl(filter
|
|||||||
linearize.apply(sourceCopy!!, sourceCopy!!)
|
linearize.apply(sourceCopy!!, sourceCopy!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upscale.noiseGain = noiseGain
|
||||||
|
upscale.noiseSeed = noiseSeed
|
||||||
downScale.apply(sourceCopy!!, intermediates[0])
|
downScale.apply(sourceCopy!!, intermediates[0])
|
||||||
blur.apply(intermediates[0], intermediates[0])
|
blur.apply(intermediates[0], intermediates[0])
|
||||||
|
|
||||||
@@ -131,7 +144,6 @@ class HashBloom : MipBloom<HashBlur>(blur = HashBlur()) {
|
|||||||
|
|
||||||
@Description("Gaussian bloom")
|
@Description("Gaussian bloom")
|
||||||
class GaussianBloom : MipBloom<GaussianBlur>(blur = GaussianBlur()) {
|
class GaussianBloom : MipBloom<GaussianBlur>(blur = GaussianBlur()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blur sample window, default value is 5
|
* blur sample window, default value is 5
|
||||||
*/
|
*/
|
||||||
@@ -144,6 +156,7 @@ class GaussianBloom : MipBloom<GaussianBlur>(blur = GaussianBlur()) {
|
|||||||
@DoubleParameter("kernel sigma", 0.0, 25.0)
|
@DoubleParameter("kernel sigma", 0.0, 25.0)
|
||||||
var sigma: Double = 1.0
|
var sigma: Double = 1.0
|
||||||
|
|
||||||
|
|
||||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||||
blur.window = window
|
blur.window = window
|
||||||
blur.sigma = sigma
|
blur.sigma = sigma
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ float nrand(vec2 n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- based on https://github.com/excess-demogroup/even-laster-engine/blob/a451a89f6bd6d3c6017d5890b92d9f72823bc742/src/shaders/bloom_upscale.frag
|
// -- based on https://github.com/excess-demogroup/even-laster-engine/blob/a451a89f6bd6d3c6017d5890b92d9f72823bc742/src/shaders/bloom_upscale.frag
|
||||||
uniform float seed;
|
uniform float noiseSeed;
|
||||||
uniform float shape;
|
uniform float shape;
|
||||||
uniform float gain;
|
uniform float gain;
|
||||||
|
|
||||||
|
uniform float noiseGain;
|
||||||
|
|
||||||
in vec2 v_texCoord0;
|
in vec2 v_texCoord0;
|
||||||
out vec4 o_output;
|
out vec4 o_output;
|
||||||
|
|
||||||
@@ -25,51 +27,51 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
float weight = pow(0.0, shape);
|
float weight = pow(0.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 2 - 1) / textureSize(tex0, 0);
|
rnd = (rnd * 2 - 1) / textureSize(tex0, 0);
|
||||||
sum += textureLod(tex0, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex0, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
float weight = pow(1.0, shape);
|
float weight = pow(1.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 2 - 1) / textureSize(tex1, 0);
|
rnd = (rnd * 2 - 1) / textureSize(tex1, 0);
|
||||||
sum += textureLod(tex1, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex1, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
float weight = pow(2.0, shape);
|
float weight = pow(2.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 2 - 1) / textureSize(tex2, 0);
|
rnd = (rnd * 2 - 1) / textureSize(tex2, 0);
|
||||||
sum += textureLod(tex2, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex2, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
float weight = pow(3.0, shape);
|
float weight = pow(3.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||||
sum += textureLod(tex3, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex3, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
float weight = pow(4.0, shape);
|
float weight = pow(4.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||||
sum += textureLod(tex4, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex4, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
float weight = pow(5.0, shape);
|
float weight = pow(5.0, shape);
|
||||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + seed),
|
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||||
nrand(5 + 0.0 + pos.yx - seed));
|
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||||
sum += textureLod(tex5, pos + rnd * 0.25, 0.0) * weight;
|
sum += textureLod(tex5, pos + rnd * noiseGain, 0.0) * weight;
|
||||||
total += weight;
|
total += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user