This repository was archived by the owner on Dec 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -536,7 +536,16 @@ void rad::RadSimImpl::samplePatchReflectivity() {
536
536
texScale.s = std::max (patchSize * glm::length (texInfo.vS ), 1 .0f );
537
537
texScale.t = std::max (patchSize * glm::length (texInfo.vT ), 1 .0f );
538
538
539
- patch.getReflectivity () *= material.sampleColor (texPos, texScale);
539
+ // A bit of gamma "correction" to increase the reflectivity
540
+ glm::vec3 texel = material.sampleColor (texPos, texScale);
541
+ float intensity = glm::dot (texel, RGB_INTENSITY);
542
+
543
+ if (intensity >= 0 .0001f ) {
544
+ float adjustedIntensity = std::pow (intensity, 1 .0f / TEXTURE_GAMMA_ADJ);
545
+ texel *= adjustedIntensity / intensity;
546
+ }
547
+
548
+ patch.getReflectivity () *= texel;
540
549
}
541
550
};
542
551
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ namespace rad {
26
26
// ! qrad also interprets color values of entities in linear space.
27
27
constexpr float ENT_LIGHT_GAMMA = 2 .5f ;
28
28
29
+ // ! Adjustment gamma when sampling reflectivity from textures.
30
+ // ! Applied to linear values. Increases low reflectivity values.
31
+ constexpr float TEXTURE_GAMMA_ADJ = 1 .3f ;
32
+
29
33
// ! Maximum number of lightstyles. Engine limit.
30
34
constexpr int MAX_LIGHTSTYLES = 255 ;
31
35
You can’t perform that action at this time.
0 commit comments