mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Moving bloom strength math to the combine steps, and fixing a redundant multiply issue in the REGL based renderer
This commit is contained in:
@@ -2,13 +2,12 @@ precision mediump float;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D bloomTex;
|
||||
uniform sampler2D backgroundTex;
|
||||
uniform float bloomStrength;
|
||||
varying vec2 vUV;
|
||||
|
||||
vec4 getBrightness(vec2 uv) {
|
||||
vec4 primary = texture2D(tex, uv);
|
||||
vec4 bloom = texture2D(bloomTex, uv) * bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - bloomStrength), 1.0);
|
||||
vec4 bloom = texture2D(bloomTex, uv);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -4,7 +4,6 @@ precision mediump float;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D bloomTex;
|
||||
uniform sampler2D paletteTex;
|
||||
uniform float bloomStrength;
|
||||
uniform float ditherMagnitude;
|
||||
uniform float time;
|
||||
uniform vec3 backgroundColor, cursorColor, glintColor;
|
||||
@@ -18,8 +17,8 @@ highp float rand( const in vec2 uv, const in float t ) {
|
||||
|
||||
vec4 getBrightness(vec2 uv) {
|
||||
vec4 primary = texture2D(tex, uv);
|
||||
vec4 bloom = texture2D(bloomTex, uv) * bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - bloomStrength), 1.0);
|
||||
vec4 bloom = texture2D(bloomTex, uv);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -3,7 +3,6 @@ precision mediump float;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D bloomTex;
|
||||
uniform float bloomStrength;
|
||||
uniform sampler2D stripeTex;
|
||||
uniform float ditherMagnitude;
|
||||
uniform float time;
|
||||
@@ -18,8 +17,8 @@ highp float rand( const in vec2 uv, const in float t ) {
|
||||
|
||||
vec4 getBrightness(vec2 uv) {
|
||||
vec4 primary = texture2D(tex, uv);
|
||||
vec4 bloom = texture2D(bloomTex, uv) * bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - bloomStrength), 1.0);
|
||||
vec4 bloom = texture2D(bloomTex, uv);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
struct Config {
|
||||
pyramidHeight : f32,
|
||||
bloomStrength : f32
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> config : Config;
|
||||
@@ -62,5 +63,5 @@ struct ComputeInput {
|
||||
sum += textureSampleLevel( tex4, linearSampler, uv, i + 1.0 ) * weight;
|
||||
}
|
||||
|
||||
textureStore(outputTex, coord, sum);
|
||||
textureStore(outputTex, coord, sum * config.bloomStrength);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
struct Config {
|
||||
bloomStrength : f32,
|
||||
unused : f32,
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> config : Config;
|
||||
@@ -15,12 +15,14 @@ struct ComputeInput {
|
||||
|
||||
fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
|
||||
var primary = textureSampleLevel(tex, linearSampler, uv, 0.0);
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0) * config.bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - config.bloomStrength), vec4<f32>(1.0));
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(32, 1, 1) fn computeMain(input : ComputeInput) {
|
||||
|
||||
var unused = config.unused;
|
||||
|
||||
// Resolve the invocation ID to a texel coordinate
|
||||
var coord = vec2<i32>(input.id.xy);
|
||||
var screenSize = textureDimensions(tex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
struct Config {
|
||||
bloomStrength : f32,
|
||||
unused : f32,
|
||||
};
|
||||
|
||||
struct Time {
|
||||
@@ -33,13 +33,15 @@ struct ComputeInput {
|
||||
fn getBrightness(uv : vec2<f32>, intensity : f32) -> vec4<f32> {
|
||||
|
||||
var primary = textureSampleLevel(tex, linearSampler, uv, 0.0);
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0) * config.bloomStrength;
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0);
|
||||
|
||||
return primary * (1.0 + intensity * 0.3) + bloom * 0.5;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(32, 1, 1) fn computeMain(input : ComputeInput) {
|
||||
|
||||
var unused = config.unused;
|
||||
|
||||
// Resolve the invocation ID to a texel coordinate
|
||||
var coord = vec2<i32>(input.id.xy);
|
||||
var screenSize = textureDimensions(tex);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
struct Config {
|
||||
bloomStrength : f32,
|
||||
ditherMagnitude : f32,
|
||||
backgroundColor : vec3<f32>,
|
||||
cursorColor : vec3<f32>,
|
||||
@@ -40,8 +39,8 @@ fn randomFloat( uv : vec2<f32> ) -> f32 {
|
||||
|
||||
fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
|
||||
var primary = textureSampleLevel(tex, linearSampler, uv, 0.0);
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0) * config.bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - config.bloomStrength), vec4<f32>(1.0));
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(32, 1, 1) fn computeMain(input : ComputeInput) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
struct Config {
|
||||
bloomStrength : f32,
|
||||
ditherMagnitude : f32,
|
||||
backgroundColor : vec3<f32>,
|
||||
cursorColor : vec3<f32>,
|
||||
@@ -36,8 +35,8 @@ fn randomFloat( uv : vec2<f32> ) -> f32 {
|
||||
|
||||
fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
|
||||
var primary = textureSampleLevel(tex, linearSampler, uv, 0.0);
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0) * config.bloomStrength;
|
||||
return min((primary + bloom) * (2.0 - config.bloomStrength), vec4<f32>(1.0));
|
||||
var bloom = textureSampleLevel(bloomTex, linearSampler, uv, 0.0);
|
||||
return primary + bloom;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(32, 1, 1) fn computeMain(input : ComputeInput) {
|
||||
|
||||
Reference in New Issue
Block a user