From 46f02cbd1a7e8e028109be8e76fb4f48bdfbf8b9 Mon Sep 17 00:00:00 2001 From: cryham Date: Sun, 24 Nov 2024 19:00:35 +0100 Subject: [PATCH] hdr, todo --- .../Pbs/Any/Main/800.PixelShader_piece_ps.any | 8 +++- .../Any/Main/800.VertexShader_piece_vs.any | 11 +++--- .../Terra/Any/800.PixelShader_piece_ps.any | 2 +- .../Unlit/Any/800.PixelShader_piece_ps.any | 2 +- data/materials/Common/GLSL/BoxBlurH_ps.glsl | 5 ++- data/materials/Common/GLSL/BoxBlurV_ps.glsl | 5 ++- .../GLSL/DownScale01_SumLumStart_ps.glsl | 38 ++++++++++++++++++- .../Common/GLSL/DownScale03_SumLumEnd_ps.glsl | 2 +- data/materials/Pbs/sky.material.json | 2 +- 9 files changed, 60 insertions(+), 15 deletions(-) diff --git a/data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any b/data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any index bb1e44fc..ef958210 100644 --- a/data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any +++ b/data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any @@ -489,7 +489,11 @@ else pixelData.viewDir = midf3_c( normalize( -inPs.pos ) ); @end - pixelData.NdotV = saturate( dot( pixelData.normal, pixelData.viewDir ) ); + // property( grass ) // todo: lit grass .. + // pixelData.NdotV = 0.0; + // else + pixelData.NdotV = saturate( dot( pixelData.normal, pixelData.viewDir ) ); + // end @end @property( !ambient_fixed || vct_num_probes ) @@ -993,7 +997,7 @@ //** gamma -- @property( !sky ) - finalColour.xyz = pow(finalColour, midf3_c(1.15, 1.15, 1.15) ); + finalColour.xyz = pow(finalColour, midf3_c(1.15, 1.15, 1.15) ); @end @property( !hw_gamma_write ) diff --git a/data/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any b/data/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any index 63037f06..6844400a 100644 --- a/data/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any +++ b/data/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any @@ -253,11 +253,12 @@ @piece( DefaultBodyVS ) // Define inputPos using inVs_vertex. - @property( hlms_pose ) - float4 inputPos = inVs_vertex; // We need inputPos as lvalue for PoseTransform - @else - #define inputPos inVs_vertex - @end + // property( hlms_pose ) + // float4 inputPos = inVs_vertex; // We need inputPos as lvalue for PoseTransform + // else + // #define inputPos inVs_vertex + // end + float4 inputPos = inVs_vertex; @property( !hlms_shadowcaster ) @property( hlms_colour ) //** Pbs vertex color diff --git a/data/Hlms/Terra/Any/800.PixelShader_piece_ps.any b/data/Hlms/Terra/Any/800.PixelShader_piece_ps.any index 110e9756..6295b33f 100644 --- a/data/Hlms/Terra/Any/800.PixelShader_piece_ps.any +++ b/data/Hlms/Terra/Any/800.PixelShader_piece_ps.any @@ -445,7 +445,7 @@ @end //** gamma -- - finalColour.xyz = pow(finalColour, midf3_c(1.15, 1.15, 1.15)); + finalColour.xyz = pow(finalColour, midf3_c(1.15, 1.15, 1.15)); @property( !hw_gamma_write ) //Linear to Gamma space diff --git a/data/Hlms/Unlit/Any/800.PixelShader_piece_ps.any b/data/Hlms/Unlit/Any/800.PixelShader_piece_ps.any index e68cea60..f02d91c9 100644 --- a/data/Hlms/Unlit/Any/800.PixelShader_piece_ps.any +++ b/data/Hlms/Unlit/Any/800.PixelShader_piece_ps.any @@ -139,7 +139,7 @@ //** gamma -- Gui etc - diffuseCol.xyz = pow(diffuseCol.xyz, midf3_c(1.15, 1.15, 1.15)); + diffuseCol.xyz = pow(diffuseCol.xyz, midf3_c(1.15, 1.15, 1.15)); @insertpiece( custom_ps_preLights ) diff --git a/data/materials/Common/GLSL/BoxBlurH_ps.glsl b/data/materials/Common/GLSL/BoxBlurH_ps.glsl index 702d7937..8efe8006 100644 --- a/data/materials/Common/GLSL/BoxBlurH_ps.glsl +++ b/data/materials/Common/GLSL/BoxBlurH_ps.glsl @@ -25,7 +25,10 @@ vulkan( layout( ogre_P0 ) uniform Params { ) uniform vec4 invTex0Size; vulkan( }; ) -#define NUM_SAMPLES 65 +// #define NUM_SAMPLES 11 +// #define NUM_SAMPLES 65 +// #define NUM_SAMPLES 31 +#define NUM_SAMPLES 15 void main() { diff --git a/data/materials/Common/GLSL/BoxBlurV_ps.glsl b/data/materials/Common/GLSL/BoxBlurV_ps.glsl index 75b7f0e8..f7ffede9 100644 --- a/data/materials/Common/GLSL/BoxBlurV_ps.glsl +++ b/data/materials/Common/GLSL/BoxBlurV_ps.glsl @@ -25,7 +25,10 @@ vulkan( layout( ogre_P0 ) uniform Params { ) uniform vec4 invTex0Size; vulkan( }; ) -#define NUM_SAMPLES 11 +// #define NUM_SAMPLES 11 +// #define NUM_SAMPLES 65 +// #define NUM_SAMPLES 31 +#define NUM_SAMPLES 15 void main() { diff --git a/data/materials/Common/GLSL/DownScale01_SumLumStart_ps.glsl b/data/materials/Common/GLSL/DownScale01_SumLumStart_ps.glsl index a58a4fb3..76f211ca 100644 --- a/data/materials/Common/GLSL/DownScale01_SumLumStart_ps.glsl +++ b/data/materials/Common/GLSL/DownScale01_SumLumStart_ps.glsl @@ -25,6 +25,41 @@ in block //for x in range(0, 16): // printMorton(x) +/* +vec3 makeBloom(float lod, vec2 offset, vec2 bCoord){ + + vec2 pixelSize = 1.0 / vec2(iResolution.x, iResolution.y); + + offset += pixelSize; + + float lodFactor = exp2(lod); + + vec3 bloom = vec3(0.0); + vec2 scale = lodFactor * pixelSize; + + vec2 coord = (bCoord.xy-offset)*lodFactor; + float totalWeight = 0.0; + + if (any(greaterThanEqual(abs(coord - 0.5), scale + 0.5))) + return vec3(0.0); + + for (int i = -5; i < 5; i++) { + for (int j = -5; j < 5; j++) { + + float wg = pow(1.0-length(vec2(i,j)) * 0.125,6.0); + + bloom = pow(texture(iChannel0,vec2(i,j) * scale + lodFactor * pixelSize + coord, lod).rgb,vec3(2.2))*wg + bloom; + totalWeight += wg; + + } + } + + bloom /= totalWeight; + + return bloom; +} +/**/ + const vec2 c_offsets[16] = vec2[16] ( vec2( 0, 0 ), vec2( 1, 0 ), vec2( 0, 1 ), vec2( 1, 1 ), @@ -53,7 +88,7 @@ void main() //We would need 64x64 samples, but we only sample 4x4, therefore we sample one //pixel and skip 15, then repeat. We perform: //(ViewportResolution / TargetResolution) / 4 - vec2 ratio = tex0Size.xy * viewportSize.zw * 0.25; + vec2 ratio = tex0Size.xy * viewportSize.zw * 4 * 0.25; //? vec3 vSample = texture( vkSampler2D( rt0, samplerState ), inPs.uv0 ).xyz; float sampleLum = dot( vSample, c_luminanceCoeffs ) + 0.0001; @@ -69,7 +104,6 @@ void main() //fLogLuminance += log( clamp( sampleLum, c_minLuminance, c_maxLuminance ) ); fLogLuminance += log( sampleLum * 1024.0 ); } - fLogLuminance *= 0.0625; // /= 16.0; fragColour = fLogLuminance; diff --git a/data/materials/Common/GLSL/DownScale03_SumLumEnd_ps.glsl b/data/materials/Common/GLSL/DownScale03_SumLumEnd_ps.glsl index aa5c7e82..60e3d357 100644 --- a/data/materials/Common/GLSL/DownScale03_SumLumEnd_ps.glsl +++ b/data/materials/Common/GLSL/DownScale03_SumLumEnd_ps.glsl @@ -44,5 +44,5 @@ void main() float oldLum = texture( vkSampler2D( oldLumRt, samplerPoint ), vec2( 0.0, 0.0 ) ).x; //Adapt luminicense based 75% per second. - fragColour = mix( newLum, oldLum, pow( 0.25, timeSinceLast ) ); + fragColour = mix( newLum, oldLum, pow( 0.25, timeSinceLast /* *0.3 slower */ ) ); } diff --git a/data/materials/Pbs/sky.material.json b/data/materials/Pbs/sky.material.json index 3bb4ab76..5d14504d 100644 --- a/data/materials/Pbs/sky.material.json +++ b/data/materials/Pbs/sky.material.json @@ -461,7 +461,7 @@ }, "emissive" : { - "value" : [1, 1, 1], + "value" : [1.001, 1.001, 1.001], "texture" : "day_clouds_04_blue.jpg", "sampler" : "Sampler_Sky" }