aesthetics: add noise in post pass, cheating the bloom banding

This commit is contained in:
FMS-Cat
2021-03-26 21:22:46 +09:00
parent 61d9c82095
commit 3f1f9ffc96
2 changed files with 11 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import quadVert from '../shaders/quad.vert';
import { BufferRenderTarget } from '../heck/BufferRenderTarget'; import { BufferRenderTarget } from '../heck/BufferRenderTarget';
import { quadGeometry } from '../globals/quadGeometry'; import { quadGeometry } from '../globals/quadGeometry';
import { dummyRenderTarget } from '../globals/dummyRenderTarget'; import { dummyRenderTarget } from '../globals/dummyRenderTarget';
import { randomTexture } from '../globals/randomTexture';
export interface PostOptions { export interface PostOptions {
input: BufferRenderTarget; input: BufferRenderTarget;
@@ -26,6 +27,7 @@ export class Post extends Entity {
{ initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } },
); );
material.addUniformTexture( 'sampler0', options.input.texture ); material.addUniformTexture( 'sampler0', options.input.texture );
material.addUniformTexture( 'samplerRandom', randomTexture.texture );
if ( process.env.DEV ) { if ( process.env.DEV ) {
if ( module.hot ) { if ( module.hot ) {

View File

@@ -19,6 +19,9 @@ out vec4 fragColor;
uniform float time; uniform float time;
uniform vec2 resolution; uniform vec2 resolution;
uniform sampler2D sampler0; uniform sampler2D sampler0;
uniform sampler2D samplerRandom;
#pragma glslify: prng = require( ./-prng );
vec3 colorMap( vec3 i ) { vec3 colorMap( vec3 i ) {
return vec3( return vec3(
@@ -58,7 +61,12 @@ void main() {
tex = mix( vec3( 0.0 ), tex, vig ); tex = mix( vec3( 0.0 ), tex, vig );
vec3 col = pow( saturate( tex.xyz ), vec3( 0.4545 ) ); vec3 col = tex.xyz;
vec4 seed = texture( samplerRandom, uv );
prng( seed );
prng( seed );
col += ( pow( prng( seed ), 2.2 ) - 0.25 ) * 0.002;
col = pow( saturate( col ), vec3( 0.4545 ) );
col.x = linearstep( 0.0, 1.2, col.x + 0.2 * uv.y ); col.x = linearstep( 0.0, 1.2, col.x + 0.2 * uv.y );
col.z = linearstep( -0.1, 1.0, col.z ); col.z = linearstep( -0.1, 1.0, col.z );
col = colorMap( col ); col = colorMap( col );