Skip to content

Commit

Permalink
hdr, todo
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Nov 24, 2024
1 parent 3750e23 commit 46f02cb
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 15 deletions.
8 changes: 6 additions & 2 deletions data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down
11 changes: 6 additions & 5 deletions data/Hlms/Pbs/Any/Main/800.VertexShader_piece_vs.any
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/Hlms/Terra/Any/800.PixelShader_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/Hlms/Unlit/Any/800.PixelShader_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down
5 changes: 4 additions & 1 deletion data/materials/Common/GLSL/BoxBlurH_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
5 changes: 4 additions & 1 deletion data/materials/Common/GLSL/BoxBlurV_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
38 changes: 36 additions & 2 deletions data/materials/Common/GLSL/DownScale01_SumLumStart_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion data/materials/Common/GLSL/DownScale03_SumLumEnd_ps.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ ) );
}
2 changes: 1 addition & 1 deletion data/materials/Pbs/sky.material.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 46f02cb

Please sign in to comment.