mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Optimized shadow mapping using Blue Noise sampling.
This reduces the number of shadow mapping taps from 12 to 6 while keeping very good results.
This commit is contained in:
parent
2c6f2377bf
commit
caa9258289
11 changed files with 5934 additions and 141 deletions
11
README.md
11
README.md
|
@ -393,14 +393,15 @@ convertMapToJSON <mapfile> | Command: Convert .map file to new .json
|
|||
|
||||
|
||||
|
||||
____
|
||||
|
||||
---
|
||||
# Known Issues <a name="issues"></a>
|
||||
____
|
||||
* HDR does not work with old-school stencil shadows
|
||||
* MSAA anti-aliasing modes don't work with HDR: Use SMAA
|
||||
|
||||
* Some lights cause shadow acne with shadow mapping
|
||||
* Some shadows might almost disappear due to the shadow filtering
|
||||
* [HDR] HDR does not work with old-school stencil shadows
|
||||
* [HDR] MSAA anti-aliasing modes don't work with HDR: Use SMAA
|
||||
* [HDR] HDR causes problems with the grabber gun
|
||||
* [HDR] HDR darkens the screen when you get hit by an enemy
|
||||
* [Vulkan] Video playback does not work
|
||||
* [Vulkan] Shadow Mapping is not supported yet
|
||||
* [Vulkan] HDR is not supported yet
|
||||
|
|
137
RELEASE-NOTES.md
137
RELEASE-NOTES.md
|
@ -17,27 +17,62 @@ _______________________________________
|
|||
TBD mid 2020 - Changes since RBDOOM-3-BFG 1.2.0
|
||||
_______________________________
|
||||
|
||||
- Fixed GPU Skinning with Vulkan
|
||||
RBDOOM-3-BFG 1.3.0 is mainly a Phyiscally Based Rendering Update.
|
||||
|
||||
- Fixed the lighting with stencil shadows with Vulkan and added Carmarck's Rerverse optimization
|
||||
Implementing Phyiscally Based Rendering (PBR) in Doom 3 is a challenge and comes with a few compromises because the Doom 3 content was designed to work with the hardware constraints in 2004 and that even meant to run on a Geforce 3.
|
||||
|
||||
- Added anisotropic filtering to Vulkan
|
||||
The light rigs aren't made for PBR but it is possible to achieve a good PBR lighting even with the old content by tweaking the light formulars with a few good magic constants. However I also want to support the modding scene to allow them to create brand new PBR materials made with Substance Designer/Painter or other modern tools so multiple rendering paths have been implemented.
|
||||
|
||||
- Added Git submodule glslang 7.10.2984 -> stable release Nov 15, 2018
|
||||
From an artistic point of view PBR allows artists to create textures that are based on real world measured color values and they look more or less the same in any renderer that follows the PBR guidelines and formulars.
|
||||
RBDOOM-3-BFG only supports the PBR roughness/metal workflow.
|
||||
|
||||
- Changed light interaction shaders to use PBR GGX Cook-Torrance specular contribution. The roughness input is estimated by the D3 glossmap if no PBR texture is provided
|
||||
The main goal is that the new content looks the same in RBDOOM-3-BFG as in Blender 2.8 with Cycles or Eevee.
|
||||
|
||||
- PBR texture support ground work is done. Only a few bits are left to be enabled.
|
||||
[PBR]
|
||||
|
||||
- Extended ambient pass to support Image Based Lighting using a single fixed cubemap at the moment (r_useIBL)
|
||||
* Changed light interaction shaders to use PBR GGX Cook-Torrance specular contribution. The material roughness is estimated by the old school Doom 3 glossmap if no PBR texture is provided
|
||||
|
||||
- Turned off Half-Lambert lighting hack in favor of IBL
|
||||
* PBR texture support ground work is done. Only a few bits are left to be enabled.
|
||||
|
||||
- Vulkan version builds on Linux. Big thanks to Eric Womer for helping out with the SDL 2 part
|
||||
* Extended ambient pass to support Image Based Lighting using a single fixed cubemap at the moment (r_usePBR)
|
||||
|
||||
- com_showFPS 1 uses ImGui to show more detailed renderer stats like the console prints with r_speeds
|
||||
* Turned off Half-Lambert lighting hack in favor of Image Based Lighting
|
||||
|
||||
- Removed 32bit support: FFmpeg and OpenAL libraries are only distributed as Win64 versions, 32bit CMakes files are gone
|
||||
* Improved r_hdrDebug which shows F-stops like in Filament
|
||||
|
||||
* Turned off r_hdrAutomaticExposure by default because it caused too much flickering and needs further work. The new default values work well with all Doom 3 content
|
||||
|
||||
* r_lightScale (default 3) can be changed when HDR is enabled
|
||||
|
||||
* Light shaders were tweaked with magic constants that r_useHDR 1, r_forceAmbient 0.3, r_exposure 0.5 look as bright as in Doom 2016 or any other PBR renderer
|
||||
|
||||
* SSAO only affects the ambient pass and not the direct lighting and the ambient occlusion affects the specular indirect contribution depending on the roughness of a material. See moving Frostbite to PBR (Lagarde2014)
|
||||
|
||||
* Added HACK to look for PBR reflection maps with the suffix _rmao if a specular map was specified and ends with _s.tga. This allows to override the materials with PBR textures without touching the material .mtr files.
|
||||
|
||||
[VULKAN]
|
||||
|
||||
* Fixed GPU Skinning with Vulkan
|
||||
|
||||
* Fixed the lighting with stencil shadows with Vulkan and added Carmarck's Rerverse optimization
|
||||
|
||||
* Added anisotropic filtering to Vulkan
|
||||
|
||||
* Added Git submodule glslang 7.10.2984 -> stable release Nov 15, 2018
|
||||
|
||||
* Vulkan version builds on Linux. Big thanks to Eric Womer for helping out with the SDL 2 part
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
* com_showFPS 1 uses ImGui to show more detailed renderer stats like the console prints with r_speeds
|
||||
|
||||
* Removed 32bit support: FFmpeg and OpenAL libraries are only distributed as Win64 versions, 32bit CMakes files are gone
|
||||
|
||||
* Added Blue Noise based Filmic Dithering by Timothy Lottes and Chromatic Aberration
|
||||
|
||||
* Artistic Style C++ beautifier configuration has slightly changed to work closer to Clang Format's behaviour
|
||||
|
||||
* Updated documentation regarding modding support in the README
|
||||
|
||||
|
||||
|
||||
|
@ -48,23 +83,23 @@ _______________________________
|
|||
|
||||
This is a maintenance release without Vulkan support even though it contains a lot Vulkan specific code.
|
||||
|
||||
- Experimental Work in Progress Vulkan renderer backend based on Dustin Land's Doom 3 BFG Vulkan port
|
||||
* Experimental Work in Progress Vulkan renderer backend based on Dustin Land's Doom 3 BFG Vulkan port
|
||||
This renderer backend only supports ambient lighting and no light interactions but it also comes with a big renderer code cleanup.
|
||||
|
||||
The changes also fixed several rendering bugs that occured in OpenGL:
|
||||
|
||||
- Fixed black dots when HDR and SSAO is enabled
|
||||
* Fixed black dots when HDR and SSAO is enabled
|
||||
|
||||
- Hit/damage markers show a white background #422
|
||||
* Hit/damage markers show a white background #422
|
||||
|
||||
- Refactored and simplified OpenGL renderer backend to match Vulkan backend
|
||||
* Refactored and simplified OpenGL renderer backend to match Vulkan backend
|
||||
|
||||
- Renamed the .vertex and .pixel shader files to .hlsl
|
||||
* Renamed the .vertex and .pixel shader files to .hlsl
|
||||
This allows better editing of the shaders within Visual Studio including Intellisense support.
|
||||
|
||||
- Integrated libbinkdec for video playback as a slim alternative to FFmpeg (thanks to Daniel Gibson)
|
||||
* Integrated libbinkdec for video playback as a slim alternative to FFmpeg (thanks to Daniel Gibson)
|
||||
|
||||
- Added in-engine Flash debugging tools and new console variables.
|
||||
* Added in-engine Flash debugging tools and new console variables.
|
||||
These tools help to analyse the id Tech view of Flash and what SWF tags are supported and how they are interpreted
|
||||
by id Tech's own ActionScript 2 interpreter
|
||||
- swf_exportAtlas
|
||||
|
@ -72,14 +107,14 @@ This is a maintenance release without Vulkan support even though it contains a l
|
|||
- swf_exportJSON
|
||||
- swf_show : Draws the bounding box of instanced Flash sprites in red and their names
|
||||
|
||||
- Added Steel Storm 2 Engine render demo fixes
|
||||
* Added Steel Storm 2 Engine render demo fixes
|
||||
|
||||
- Merged LordHavoc's image compression progress bar which shows up in the map loading screen
|
||||
* Merged LordHavoc's image compression progress bar which shows up in the map loading screen
|
||||
when loading and compressing new images from mods
|
||||
|
||||
- Added instructions how to use these Doom 3 port with the GOG installer
|
||||
* Added instructions how to use these Doom 3 port with the GOG installer
|
||||
|
||||
- Many smaller compiler related fixes like VS 2017 and VS 2019 support.
|
||||
* Many smaller compiler related fixes like VS 2017 and VS 2019 support.
|
||||
If it fails to compile with GCC then it should at least build with Clang on Linux
|
||||
|
||||
|
||||
|
@ -88,21 +123,21 @@ _______________________________________
|
|||
11 April 2016 - RBDOOM-3-BFG 1.1.0 preview 3
|
||||
_______________________________
|
||||
|
||||
- True 64 bit HDR lighting with adaptive filmic tone mapping and gamma-correct rendering in linear RGB space
|
||||
* True 64 bit HDR lighting with adaptive filmic tone mapping and gamma-correct rendering in linear RGB space
|
||||
|
||||
- Enhanced Subpixel Morphological Antialiasing
|
||||
* Enhanced Subpixel Morphological Antialiasing
|
||||
For more information see "Anti-Aliasing Methods in CryENGINE 3" and the docs at http://www.iryoku.com/smaa/
|
||||
- Filmic post process effects like Technicolor color grading and film grain
|
||||
* Filmic post process effects like Technicolor color grading and film grain
|
||||
|
||||
- Fixed issues with Mesa drivers and allowed them to use shadow mapping
|
||||
* Fixed issues with Mesa drivers and allowed them to use shadow mapping
|
||||
|
||||
- Defaulted fs_resourceLoadPriority to 0 so it is not necessary anymore to specify when running a modification
|
||||
* Defaulted fs_resourceLoadPriority to 0 so it is not necessary anymore to specify when running a modification
|
||||
|
||||
- Additional ambient render pass to make the game less dark similar to the Quake 4 r_forceAmbient technique
|
||||
* Additional ambient render pass to make the game less dark similar to the Quake 4 r_forceAmbient technique
|
||||
|
||||
- Screen Space Ambient Occlusion http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
* Screen Space Ambient Occlusion http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
|
||||
- Did some fine tuning to the Half-Lambert lighting curve so bump mapping doesn't loose too much details
|
||||
* Did some fine tuning to the Half-Lambert lighting curve so bump mapping doesn't loose too much details
|
||||
|
||||
|
||||
_______________________________________
|
||||
|
@ -110,25 +145,25 @@ _______________________________________
|
|||
7 March 2015 - RBDOOM-3-BFG 1.0.3
|
||||
_______________________________
|
||||
|
||||
- SDL 2 is the default for Linux
|
||||
* SDL 2 is the default for Linux
|
||||
|
||||
- CMake options like -DUSE_SYSTEM_LIBJPEG to aid Linux distribution package maintainers
|
||||
* CMake options like -DUSE_SYSTEM_LIBJPEG to aid Linux distribution package maintainers
|
||||
|
||||
- SDL gamepad support and other SDL input improvements like support for more mouse buttons
|
||||
* SDL gamepad support and other SDL input improvements like support for more mouse buttons
|
||||
|
||||
- Mac OS X support (experimental)
|
||||
* Mac OS X support (experimental)
|
||||
|
||||
- XAudio 2, Windows 8 SDK fixes
|
||||
* XAudio 2, Windows 8 SDK fixes
|
||||
|
||||
- Better Mesa support (not including advanced shadow mapping)
|
||||
* Better Mesa support (not including advanced shadow mapping)
|
||||
|
||||
- Added back dmap and aas compilers (mapping tools)
|
||||
* Added back dmap and aas compilers (mapping tools)
|
||||
|
||||
- Cinematic sequences can be skipped
|
||||
* Cinematic sequences can be skipped
|
||||
|
||||
- Localization support for other languages than English
|
||||
* Localization support for other languages than English
|
||||
|
||||
- Improved modding support through loading of custom models and animations (see section 12 MODIFICATIONS in the README)
|
||||
* Improved modding support through loading of custom models and animations (see section 12 MODIFICATIONS in the README)
|
||||
|
||||
|
||||
|
||||
|
@ -161,27 +196,27 @@ _______________________________________
|
|||
RBDOOM-3-BFG-win32-20140510-git-14f87fe.7z
|
||||
_______________________________
|
||||
|
||||
- Added soft shadow mapping
|
||||
* Added soft shadow mapping
|
||||
|
||||
- Added PNG image support
|
||||
* Added PNG image support
|
||||
|
||||
- Replaced QGL with GLEW
|
||||
* Replaced QGL with GLEW
|
||||
|
||||
- base/renderprogs/ can be baked into the executable using Premake/Lua
|
||||
* base/renderprogs/ can be baked into the executable using Premake/Lua
|
||||
|
||||
- Replaced Visual Studio solution with CMake
|
||||
* Replaced Visual Studio solution with CMake
|
||||
|
||||
- Linux port using SDL/SDL2 and OpenAL
|
||||
* Linux port using SDL/SDL2 and OpenAL
|
||||
|
||||
- 64 bit support for Windows and Linux
|
||||
* 64 bit support for Windows and Linux
|
||||
|
||||
- Sourcecode cleanup using Artistic Style 2.03 C++ beautifier and by fixing tons of warnings using Clang compiler
|
||||
* Sourcecode cleanup using Artistic Style 2.03 C++ beautifier and by fixing tons of warnings using Clang compiler
|
||||
|
||||
- Fast compile times using precompiled header support
|
||||
* Fast compile times using precompiled header support
|
||||
|
||||
- Tons of renderer bugfixes and Cg -> GLSL converter that supports ES 2.00, ES 3.30 additional to GLSL 1.50
|
||||
* Tons of renderer bugfixes and Cg -> GLSL converter that supports ES 2.00, ES 3.30 additional to GLSL 1.50
|
||||
|
||||
- Netcode fixes to allow multiplayer sessions to friends with +connect <ip of friend> (manual port forwarding required)
|
||||
* Netcode fixes to allow multiplayer sessions to friends with +connect <ip of friend> (manual port forwarding required)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2013-2016 Robert Beckebans
|
||||
Copyright (C) 2013-2020 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -248,3 +248,27 @@ static float2 vposToScreenPosTexCoord( float2 vpos ) { return vpos.xy * rpWindow
|
|||
|
||||
#define BRANCH
|
||||
#define IFANY
|
||||
|
||||
|
||||
//note: works for structured patterns too
|
||||
// [0;1[
|
||||
float RemapNoiseTriErp( const float v )
|
||||
{
|
||||
float r2 = 0.5 * v;
|
||||
float f1 = sqrt( r2 );
|
||||
float f2 = 1.0 - sqrt( r2 - 0.25 );
|
||||
return ( v < 0.5 ) ? f1 : f2;
|
||||
}
|
||||
|
||||
//note: returns [-intensity;intensity[, magnitude of 2x intensity
|
||||
//note: from "NEXT GENERATION POST PROCESSING IN CALL OF DUTY: ADVANCED WARFARE"
|
||||
// http://advances.realtimerendering.com/s2014/index.html
|
||||
float InterleavedGradientNoise( float2 uv )
|
||||
{
|
||||
|
||||
const float3 magic = float3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
float rnd = fract( magic.z * fract( dot( uv, magic.xy ) ) );
|
||||
|
||||
return rnd;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,20 @@ struct PS_OUT
|
|||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
|
||||
float BlueNoise( float2 n, float x )
|
||||
{
|
||||
float noise = tex2D( samp6, ( n.xy / 256.0 ) ).r;
|
||||
|
||||
noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );
|
||||
|
||||
noise = RemapNoiseTriErp( noise );
|
||||
|
||||
//noise = noise * 2.0 - 1.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
|
||||
|
@ -223,7 +237,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
shadow *= stepSize;
|
||||
|
||||
#elif 1
|
||||
#elif 0
|
||||
|
||||
const float2 poissonDisk[12] = float2[](
|
||||
float2(0.6111618, 0.1050905),
|
||||
|
@ -268,6 +282,57 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
shadow *= stepSize;
|
||||
|
||||
|
||||
#elif 1
|
||||
|
||||
const float2 poissonDisk[12] = float2[](
|
||||
float2(0.6111618, 0.1050905),
|
||||
float2(0.1088336, 0.1127091),
|
||||
float2(0.3030421, -0.6292974),
|
||||
float2(0.4090526, 0.6716492),
|
||||
float2(-0.1608387, -0.3867823),
|
||||
float2(0.7685862, -0.6118501),
|
||||
float2(-0.1935026, -0.856501),
|
||||
float2(-0.4028573, 0.07754025),
|
||||
float2(-0.6411021, -0.4748057),
|
||||
float2(-0.1314865, 0.8404058),
|
||||
float2(-0.7005203, 0.4596822),
|
||||
float2(-0.9713828, -0.06329931) );
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
// RB: casting a float to int and using it as index can really kill the performance ...
|
||||
float numSamples = 6.0; //int(rpScreenCorrectionFactor.w);
|
||||
float stepSize = 1.0 / numSamples;
|
||||
|
||||
//float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;
|
||||
//float random = tex2D( samp6, jitterTC.xy ).x;
|
||||
|
||||
float random = BlueNoise( fragment.position.xy * 1.0, 100.0 );
|
||||
|
||||
//float random = InterleavedGradientNoise( fragment.position.xy );
|
||||
|
||||
random *= PI;
|
||||
|
||||
float2 rot;
|
||||
rot.x = cos( random );
|
||||
rot.y = sin( random );
|
||||
|
||||
float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale.x;
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
float2 jitter = poissonDisk[i];
|
||||
float2 jitterRotated;
|
||||
jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y;
|
||||
jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x;
|
||||
|
||||
float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );
|
||||
|
||||
shadow += texture( samp5, shadowTexcoordJittered.xywz);
|
||||
}
|
||||
|
||||
shadow *= stepSize;
|
||||
|
||||
#else
|
||||
|
||||
float shadow = texture( samp5, shadowTexcoord.xywz );
|
||||
|
@ -307,7 +372,8 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
half3 diffuseColor = diffuseMap;
|
||||
half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat
|
||||
#endif
|
||||
|
||||
|
||||
//diffuseColor = half3( 1.0 );
|
||||
|
||||
// RB: compensate r_lightScale 3 and the division of Pi
|
||||
//lambert *= 1.3;
|
||||
|
|
|
@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0);
|
||||
uniform sampler2D samp1 : register(s1);
|
||||
uniform sampler2D samp1 : register(s1); // blue noise 256
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
@ -234,48 +234,58 @@ float PhotoLuma( float3 c )
|
|||
return dot( c, photoLuma );
|
||||
}
|
||||
|
||||
//note: works for structured patterns too
|
||||
// [0;1[
|
||||
float RemapNoiseTriErp( const float v )
|
||||
|
||||
|
||||
float BlueNoise( float2 n, float x )
|
||||
{
|
||||
float r2 = 0.5 * v;
|
||||
float f1 = sqrt( r2 );
|
||||
float f2 = 1.0 - sqrt( r2 - 0.25 );
|
||||
return ( v < 0.5 ) ? f1 : f2;
|
||||
float noise = tex2D( samp1, ( n.xy / 512.0 ) * 1.0 ).r;
|
||||
|
||||
noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );
|
||||
|
||||
//noise = InterleavedGradientNoise( n );
|
||||
|
||||
noise = RemapNoiseTriErp( noise );
|
||||
|
||||
noise = noise * 2.0 - 1.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
#if 1
|
||||
float3 BlueNoise3( float2 n, float x )
|
||||
{
|
||||
float3 noise = tex2D( samp1, ( n.xy / 512.0 ) * 1.0 ).rgb;
|
||||
|
||||
noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );
|
||||
|
||||
noise.x = RemapNoiseTriErp( noise.x );
|
||||
noise.y = RemapNoiseTriErp( noise.y );
|
||||
noise.z = RemapNoiseTriErp( noise.z );
|
||||
|
||||
noise = noise * 2.0 - 1.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
|
||||
float Noise( float2 n, float x )
|
||||
{
|
||||
// golden ratio
|
||||
n += x;// * 1.61803398875;
|
||||
n += x;
|
||||
|
||||
#if 1
|
||||
return fract( sin( dot( n.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 ) * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
#else
|
||||
//return BlueNoise( n, 55.0 );
|
||||
return BlueNoise( n, 1.0 );
|
||||
|
||||
//note: returns [-intensity;intensity[, magnitude of 2x intensity
|
||||
//note: from "NEXT GENERATION POST PROCESSING IN CALL OF DUTY: ADVANCED WARFARE"
|
||||
// http://advances.realtimerendering.com/s2014/index.html
|
||||
//float InterleavedGradientNoise( vec2 uv )
|
||||
float Noise( float2 uv, float x )
|
||||
{
|
||||
// RB: golden ratio
|
||||
uv += x;// * 1.61803398875;
|
||||
|
||||
const float3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
float rnd = fract( magic.z * fract( dot( uv, magic.xy ) ) );
|
||||
|
||||
//rnd = RemapNoiseTriErp(rnd) * 2.0 - 0.5;
|
||||
|
||||
return rnd;
|
||||
}
|
||||
//return InterleavedGradientNoise( n ) * 2.0 - 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Step 1 in generation of the dither source texture.
|
||||
float Step1( float2 uv, float n )
|
||||
{
|
||||
float a = 1.0, b = 2.0, c = -12.0, t = 1.0;
|
||||
|
||||
return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * (
|
||||
Noise( uv + float2( -1.0, -1.0 ) * t, n ) * a +
|
||||
Noise( uv + float2( 0.0, -1.0 ) * t, n ) * b +
|
||||
|
@ -293,6 +303,7 @@ float Step1( float2 uv, float n )
|
|||
float Step2( float2 uv, float n )
|
||||
{
|
||||
float a = 1.0, b = 2.0, c = -2.0, t = 1.0;
|
||||
|
||||
return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * (
|
||||
Step1( uv + float2( -1.0, -1.0 ) * t, n ) * a +
|
||||
Step1( uv + float2( 0.0, -1.0 ) * t, n ) * b +
|
||||
|
@ -309,31 +320,53 @@ float Step2( float2 uv, float n )
|
|||
// Used for stills.
|
||||
float3 Step3( float2 uv )
|
||||
{
|
||||
#if 1
|
||||
float a = Step2( uv, 0.07 );
|
||||
float b = Step2( uv, 0.11 );
|
||||
float c = Step2( uv, 0.13 );
|
||||
#if 0
|
||||
// Monochrome can look better on stills.
|
||||
return float3( a );
|
||||
#else
|
||||
|
||||
return float3( a, b, c );
|
||||
#else
|
||||
//float a = BlueNoise( uv, 0.07 );
|
||||
//float b = BlueNoise( uv, 0.11 );
|
||||
//float c = BlueNoise( uv, 0.13 );
|
||||
|
||||
//float a = 1.0, b = 2.0, c = -12.0;
|
||||
//return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * float3( BlueNoise( uv, 0.0 ) );
|
||||
return BlueNoise3( uv, 0.0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Used for temporal dither.
|
||||
float3 Step3T( float2 uv )
|
||||
{
|
||||
#if 1
|
||||
float a = Step2( uv, 0.07 * fract( rpJitterTexOffset.z ) );
|
||||
float b = Step2( uv, 0.11 * fract( rpJitterTexOffset.z ) );
|
||||
float c = Step2( uv, 0.13 * fract( rpJitterTexOffset.z ) );
|
||||
|
||||
return float3( a, b, c );
|
||||
#else
|
||||
float a = BlueNoise( uv + 0.07, 1.0 );
|
||||
float b = BlueNoise( uv + 0.11, 1.0 );
|
||||
float c = BlueNoise( uv + 0.13, 1.0 );
|
||||
|
||||
//return BlueNoise3( uv + 0.07, 1.0 );
|
||||
return float3( a, b, c );
|
||||
|
||||
//float a = 1.0, b = 2.0, c = -2.0, d = -12.0;
|
||||
|
||||
//float3 step2 = ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * BlueNoise3( uv, 55.0 );
|
||||
//return step2 * ( 1.0 / ( a * 4.0 + b * 4.0 - d ) ) * BlueNoise3( uv, 55.0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#define STEPS 12.0
|
||||
|
||||
void DitheringPass( inout float4 fragColor )
|
||||
{
|
||||
float2 uv = fragment.position.xy;
|
||||
float2 uv = fragment.position.xy * 1.0;
|
||||
float2 uv2 = fragment.texcoord0;
|
||||
//float2 uv3 = float2( uv2.x, 1.0 - uv2.y );
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ cd ..
|
|||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DONATIVE=ON -DSDL2=ON ../neo
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DONATIVE=ON -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON ../neo
|
||||
|
|
|
@ -559,6 +559,7 @@ public:
|
|||
idImage* jitterImage16;
|
||||
idImage* grainImage1;
|
||||
idImage* randomImage256;
|
||||
idImage* blueNoiseImage256;
|
||||
idImage* currentRenderHDRImage;
|
||||
#if defined(USE_HDR_MSAA)
|
||||
idImage* currentRenderHDRImageNoMSAA;
|
||||
|
|
5475
neo/renderer/Image_blueNoiseVC_1M.h
Normal file
5475
neo/renderer/Image_blueNoiseVC_1M.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2013-2015 Robert Beckebans
|
||||
Copyright (C) 2013-2020 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -36,6 +36,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "SMAA/AreaTex.h"
|
||||
#include "SMAA/SearchTex.h"
|
||||
#include "Image_brdfLut.h"
|
||||
#include "Image_blueNoiseVC_1M.h" // 256^2 R8 data
|
||||
//#include "Image_blueNoiseVC_2.h" // 512^2 RGB8 data
|
||||
|
||||
#define DEFAULT_SIZE 16
|
||||
|
||||
|
@ -679,6 +681,30 @@ static void R_CreateRandom256Image( idImage* image )
|
|||
image->GenerateImage( ( byte* )data, 256, 256, TF_NEAREST, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
// RB
|
||||
static void R_CreateBlueNoise256Image( idImage* image )
|
||||
{
|
||||
static byte data[BLUENOISE_TEX_HEIGHT][BLUENOISE_TEX_WIDTH][4];
|
||||
|
||||
for( int x = 0; x < BLUENOISE_TEX_WIDTH; x++ )
|
||||
{
|
||||
for( int y = 0; y < BLUENOISE_TEX_HEIGHT; y++ )
|
||||
{
|
||||
#if 0
|
||||
data[x][y][0] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x * 3 + 0 ];
|
||||
data[x][y][1] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x * 3 + 1 ];
|
||||
data[x][y][2] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x * 3 + 2 ];
|
||||
#else
|
||||
data[x][y][0] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x ];
|
||||
data[x][y][1] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x ];
|
||||
data[x][y][2] = blueNoiseTexBytes[ y * BLUENOISE_TEX_PITCH + x ];
|
||||
#endif
|
||||
data[x][y][3] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
image->GenerateImage( ( byte* )data, BLUENOISE_TEX_WIDTH, BLUENOISE_TEX_HEIGHT, TF_NEAREST, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
|
||||
static void R_CreateHeatmap5ColorsImage( idImage* image )
|
||||
|
@ -951,6 +977,7 @@ void idImageManager::CreateIntrinsicImages()
|
|||
jitterImage16 = globalImages->ImageFromFunction( "_jitter16", R_CreateJitterImage16 );
|
||||
|
||||
randomImage256 = globalImages->ImageFromFunction( "_random256", R_CreateRandom256Image );
|
||||
blueNoiseImage256 = globalImages->ImageFromFunction( "_blueNoise256", R_CreateBlueNoise256Image );
|
||||
|
||||
currentRenderHDRImage = globalImages->ImageFromFunction( "_currentRenderHDR", R_HDR_RGBA16FImage_ResNative );
|
||||
#if defined(USE_HDR_MSAA)
|
||||
|
|
|
@ -5,7 +5,7 @@ Doom 3 BFG Edition GPL Source Code
|
|||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2014 Carl Kenner
|
||||
Copyright (C) 2016-2017 Dustin Land
|
||||
Copyright (C) 2013-2019 Robert Beckebans
|
||||
Copyright (C) 2013-2020 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -1692,14 +1692,17 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
{
|
||||
jitterTexOffset[0] = ( rand() & 255 ) / 255.0;
|
||||
jitterTexOffset[1] = ( rand() & 255 ) / 255.0;
|
||||
|
||||
jitterTexOffset[2] = Sys_Milliseconds() / 1000.0f;
|
||||
jitterTexOffset[3] = tr.frameCount % 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
}
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
if( vLight->parallel )
|
||||
|
@ -1760,6 +1763,8 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
|
||||
// texture 6 will be the jitter texture for soft shadowing
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_JITTER );
|
||||
globalImages->blueNoiseImage256->Bind();
|
||||
/*
|
||||
if( r_shadowMapSamples.GetInteger() == 16 )
|
||||
{
|
||||
globalImages->jitterImage16->Bind();
|
||||
|
@ -1772,6 +1777,7 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
{
|
||||
globalImages->jitterImage1->Bind();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// force the light textures to not use anisotropic filtering, which is wasted on them
|
||||
|
@ -6080,16 +6086,16 @@ void idRenderBackend::PostProcess( const void* data )
|
|||
globalImages->currentRenderImage->Bind();
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->grainImage1->Bind();
|
||||
globalImages->blueNoiseImage256->Bind();
|
||||
|
||||
renderProgManager.BindShader_PostProcess();
|
||||
|
||||
const static int GRAIN_SIZE = 128;
|
||||
const static int BLUENOISE_SIZE = 256;
|
||||
|
||||
// screen power of two correction factor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[1] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[0] = 1.0f / BLUENOISE_SIZE;
|
||||
screenCorrectionParm[1] = 1.0f / BLUENOISE_SIZE;
|
||||
screenCorrectionParm[2] = 1.0f;
|
||||
screenCorrectionParm[3] = 1.0f;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
@ -6099,16 +6105,18 @@ void idRenderBackend::PostProcess( const void* data )
|
|||
{
|
||||
jitterTexOffset[0] = ( rand() & 255 ) / 255.0;
|
||||
jitterTexOffset[1] = ( rand() & 255 ) / 255.0;
|
||||
|
||||
jitterTexOffset[2] = Sys_Milliseconds() / 1000.0f;
|
||||
jitterTexOffset[3] = tr.frameCount % 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
}
|
||||
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
// Draw
|
||||
|
|
|
@ -17,7 +17,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"Copyright (C) 2013-2016 Robert Beckebans\n"
|
||||
"Copyright (C) 2013-2020 Robert Beckebans\n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
|
@ -263,6 +263,30 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"#define BRANCH\n"
|
||||
"#define IFANY\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"//note: works for structured patterns too\n"
|
||||
"// [0;1[\n"
|
||||
"float RemapNoiseTriErp( const float v )\n"
|
||||
"{\n"
|
||||
" float r2 = 0.5 * v;\n"
|
||||
" float f1 = sqrt( r2 );\n"
|
||||
" float f2 = 1.0 - sqrt( r2 - 0.25 );\n"
|
||||
" return ( v < 0.5 ) ? f1 : f2;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//note: returns [-intensity;intensity[, magnitude of 2x intensity\n"
|
||||
"//note: from \"NEXT GENERATION POST PROCESSING IN CALL OF DUTY: ADVANCED WARFARE\"\n"
|
||||
"// http://advances.realtimerendering.com/s2014/index.html\n"
|
||||
"float InterleavedGradientNoise( float2 uv )\n"
|
||||
"{\n"
|
||||
" \n"
|
||||
" const float3 magic = float3( 0.06711056, 0.00583715, 52.9829189 );\n"
|
||||
" float rnd = fract( magic.z * fract( dot( uv, magic.xy ) ) );\n"
|
||||
"\n"
|
||||
" return rnd;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
|
||||
},
|
||||
|
||||
|
@ -9569,6 +9593,20 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" half4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"float BlueNoise( float2 n, float x )\n"
|
||||
"{\n"
|
||||
" float noise = tex2D( samp6, ( n.xy / 256.0 ) ).r;\n"
|
||||
" \n"
|
||||
" noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );\n"
|
||||
" \n"
|
||||
" noise = RemapNoiseTriErp( noise );\n"
|
||||
" \n"
|
||||
" //noise = noise * 2.0 - 1.0;\n"
|
||||
" \n"
|
||||
" return noise;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main( PS_IN fragment, out PS_OUT result )\n"
|
||||
"{\n"
|
||||
" half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );\n"
|
||||
|
@ -9733,7 +9771,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" \n"
|
||||
" shadow *= stepSize;\n"
|
||||
"\n"
|
||||
"#elif 1\n"
|
||||
"#elif 0\n"
|
||||
" \n"
|
||||
" const float2 poissonDisk[12] = float2[](\n"
|
||||
" float2(0.6111618, 0.1050905),\n"
|
||||
|
@ -9778,6 +9816,57 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"\n"
|
||||
" shadow *= stepSize;\n"
|
||||
"\n"
|
||||
" \n"
|
||||
" #elif 1\n"
|
||||
" \n"
|
||||
" const float2 poissonDisk[12] = float2[](\n"
|
||||
" float2(0.6111618, 0.1050905),\n"
|
||||
" float2(0.1088336, 0.1127091),\n"
|
||||
" float2(0.3030421, -0.6292974),\n"
|
||||
" float2(0.4090526, 0.6716492),\n"
|
||||
" float2(-0.1608387, -0.3867823),\n"
|
||||
" float2(0.7685862, -0.6118501),\n"
|
||||
" float2(-0.1935026, -0.856501),\n"
|
||||
" float2(-0.4028573, 0.07754025),\n"
|
||||
" float2(-0.6411021, -0.4748057),\n"
|
||||
" float2(-0.1314865, 0.8404058),\n"
|
||||
" float2(-0.7005203, 0.4596822),\n"
|
||||
" float2(-0.9713828, -0.06329931) );\n"
|
||||
" \n"
|
||||
" float shadow = 0.0;\n"
|
||||
" \n"
|
||||
" // RB: casting a float to int and using it as index can really kill the performance ...\n"
|
||||
" float numSamples = 6.0; //int(rpScreenCorrectionFactor.w);\n"
|
||||
" float stepSize = 1.0 / numSamples;\n"
|
||||
" \n"
|
||||
" //float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;\n"
|
||||
" //float random = tex2D( samp6, jitterTC.xy ).x;\n"
|
||||
" \n"
|
||||
" float random = BlueNoise( fragment.position.xy * 1.0, 100.0 );\n"
|
||||
" \n"
|
||||
" //float random = InterleavedGradientNoise( fragment.position.xy );\n"
|
||||
" \n"
|
||||
" random *= PI;\n"
|
||||
" \n"
|
||||
" float2 rot;\n"
|
||||
" rot.x = cos( random );\n"
|
||||
" rot.y = sin( random );\n"
|
||||
" \n"
|
||||
" float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale.x;\n"
|
||||
" for( int i = 0; i < 6; i++ )\n"
|
||||
" {\n"
|
||||
" float2 jitter = poissonDisk[i];\n"
|
||||
" float2 jitterRotated;\n"
|
||||
" jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y;\n"
|
||||
" jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x;\n"
|
||||
" \n"
|
||||
" float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );\n"
|
||||
" \n"
|
||||
" shadow += texture( samp5, shadowTexcoordJittered.xywz);\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" shadow *= stepSize;\n"
|
||||
" \n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
" float shadow = texture( samp5, shadowTexcoord.xywz );\n"
|
||||
|
@ -9817,7 +9906,8 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" half3 diffuseColor = diffuseMap;\n"
|
||||
" half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
" \n"
|
||||
" //diffuseColor = half3( 1.0 );\n"
|
||||
" \n"
|
||||
" // RB: compensate r_lightScale 3 and the division of Pi\n"
|
||||
" //lambert *= 1.3;\n"
|
||||
|
@ -10296,7 +10386,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"\n"
|
||||
"// *INDENT-OFF*\n"
|
||||
"uniform sampler2D samp0 : register(s0);\n"
|
||||
"uniform sampler2D samp1 : register(s1);\n"
|
||||
"uniform sampler2D samp1 : register(s1); // blue noise 256\n"
|
||||
"\n"
|
||||
"struct PS_IN\n"
|
||||
"{\n"
|
||||
|
@ -10498,48 +10588,58 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" return dot( c, photoLuma );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//note: works for structured patterns too\n"
|
||||
"// [0;1[\n"
|
||||
"float RemapNoiseTriErp( const float v )\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"float BlueNoise( float2 n, float x )\n"
|
||||
"{\n"
|
||||
" float r2 = 0.5 * v;\n"
|
||||
" float f1 = sqrt( r2 );\n"
|
||||
" float f2 = 1.0 - sqrt( r2 - 0.25 );\n"
|
||||
" return ( v < 0.5 ) ? f1 : f2;\n"
|
||||
" float noise = tex2D( samp1, ( n.xy / 512.0 ) * 1.0 ).r;\n"
|
||||
" \n"
|
||||
" noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );\n"
|
||||
" \n"
|
||||
" //noise = InterleavedGradientNoise( n );\n"
|
||||
" \n"
|
||||
" noise = RemapNoiseTriErp( noise );\n"
|
||||
" \n"
|
||||
" noise = noise * 2.0 - 1.0;\n"
|
||||
" \n"
|
||||
" return noise;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#if 1\n"
|
||||
"float3 BlueNoise3( float2 n, float x )\n"
|
||||
"{\n"
|
||||
" float3 noise = tex2D( samp1, ( n.xy / 512.0 ) * 1.0 ).rgb;\n"
|
||||
" \n"
|
||||
" noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x );\n"
|
||||
" \n"
|
||||
" noise.x = RemapNoiseTriErp( noise.x );\n"
|
||||
" noise.y = RemapNoiseTriErp( noise.y );\n"
|
||||
" noise.z = RemapNoiseTriErp( noise.z );\n"
|
||||
" \n"
|
||||
" noise = noise * 2.0 - 1.0;\n"
|
||||
" \n"
|
||||
" return noise;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"float Noise( float2 n, float x )\n"
|
||||
"{\n"
|
||||
" // golden ratio\n"
|
||||
" n += x;// * 1.61803398875;\n"
|
||||
" n += x;\n"
|
||||
" \n"
|
||||
"#if 1\n"
|
||||
" return fract( sin( dot( n.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 ) * 2.0 - 1.0;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"//note: returns [-intensity;intensity[, magnitude of 2x intensity\n"
|
||||
"//note: from \"NEXT GENERATION POST PROCESSING IN CALL OF DUTY: ADVANCED WARFARE\"\n"
|
||||
"// http://advances.realtimerendering.com/s2014/index.html\n"
|
||||
"//float InterleavedGradientNoise( vec2 uv )\n"
|
||||
"float Noise( float2 uv, float x )\n"
|
||||
"{\n"
|
||||
" // RB: golden ratio\n"
|
||||
" uv += x;// * 1.61803398875;\n"
|
||||
"\n"
|
||||
" const float3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );\n"
|
||||
" float rnd = fract( magic.z * fract( dot( uv, magic.xy ) ) );\n"
|
||||
"\n"
|
||||
" //rnd = RemapNoiseTriErp(rnd) * 2.0 - 0.5;\n"
|
||||
"\n"
|
||||
" return rnd;\n"
|
||||
"}\n"
|
||||
" //return BlueNoise( n, 55.0 );\n"
|
||||
" return BlueNoise( n, 1.0 );\n"
|
||||
" \n"
|
||||
" //return InterleavedGradientNoise( n ) * 2.0 - 1.0;\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"// Step 1 in generation of the dither source texture.\n"
|
||||
"float Step1( float2 uv, float n )\n"
|
||||
"{\n"
|
||||
" float a = 1.0, b = 2.0, c = -12.0, t = 1.0;\n"
|
||||
" \n"
|
||||
" return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * (\n"
|
||||
" Noise( uv + float2( -1.0, -1.0 ) * t, n ) * a +\n"
|
||||
" Noise( uv + float2( 0.0, -1.0 ) * t, n ) * b +\n"
|
||||
|
@ -10557,6 +10657,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"float Step2( float2 uv, float n )\n"
|
||||
"{\n"
|
||||
" float a = 1.0, b = 2.0, c = -2.0, t = 1.0;\n"
|
||||
" \n"
|
||||
" return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * (\n"
|
||||
" Step1( uv + float2( -1.0, -1.0 ) * t, n ) * a +\n"
|
||||
" Step1( uv + float2( 0.0, -1.0 ) * t, n ) * b +\n"
|
||||
|
@ -10573,31 +10674,53 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"// Used for stills.\n"
|
||||
"float3 Step3( float2 uv )\n"
|
||||
"{\n"
|
||||
"#if 1\n"
|
||||
" float a = Step2( uv, 0.07 );\n"
|
||||
" float b = Step2( uv, 0.11 );\n"
|
||||
" float c = Step2( uv, 0.13 );\n"
|
||||
"#if 0\n"
|
||||
" // Monochrome can look better on stills.\n"
|
||||
" return float3( a );\n"
|
||||
" \n"
|
||||
" return float3( a, b, c );\n"
|
||||
"#else\n"
|
||||
" return float3( a, b, c );\n"
|
||||
" //float a = BlueNoise( uv, 0.07 );\n"
|
||||
" //float b = BlueNoise( uv, 0.11 );\n"
|
||||
" //float c = BlueNoise( uv, 0.13 );\n"
|
||||
" \n"
|
||||
" //float a = 1.0, b = 2.0, c = -12.0;\n"
|
||||
" //return ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * float3( BlueNoise( uv, 0.0 ) );\n"
|
||||
" return BlueNoise3( uv, 0.0 );\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"// Used for temporal dither.\n"
|
||||
"float3 Step3T( float2 uv )\n"
|
||||
"{\n"
|
||||
" #if 1\n"
|
||||
" float a = Step2( uv, 0.07 * fract( rpJitterTexOffset.z ) );\n"
|
||||
" float b = Step2( uv, 0.11 * fract( rpJitterTexOffset.z ) );\n"
|
||||
" float c = Step2( uv, 0.13 * fract( rpJitterTexOffset.z ) );\n"
|
||||
" \n"
|
||||
" return float3( a, b, c );\n"
|
||||
"#else\n"
|
||||
" float a = BlueNoise( uv + 0.07, 1.0 );\n"
|
||||
" float b = BlueNoise( uv + 0.11, 1.0 );\n"
|
||||
" float c = BlueNoise( uv + 0.13, 1.0 );\n"
|
||||
" \n"
|
||||
" //return BlueNoise3( uv + 0.07, 1.0 );\n"
|
||||
" return float3( a, b, c );\n"
|
||||
" \n"
|
||||
" //float a = 1.0, b = 2.0, c = -2.0, d = -12.0;\n"
|
||||
" \n"
|
||||
" //float3 step2 = ( 1.0 / ( a * 4.0 + b * 4.0 - c ) ) * BlueNoise3( uv, 55.0 );\n"
|
||||
" //return step2 * ( 1.0 / ( a * 4.0 + b * 4.0 - d ) ) * BlueNoise3( uv, 55.0 );\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"#define STEPS 12.0\n"
|
||||
"\n"
|
||||
"void DitheringPass( inout float4 fragColor )\n"
|
||||
"{\n"
|
||||
" float2 uv = fragment.position.xy;\n"
|
||||
" float2 uv = fragment.position.xy * 1.0;\n"
|
||||
" float2 uv2 = fragment.texcoord0;\n"
|
||||
" //float2 uv3 = float2( uv2.x, 1.0 - uv2.y );\n"
|
||||
"\n"
|
||||
|
|
Loading…
Reference in a new issue