Skip to content

Commit a520ab5

Browse files
Add overlay blending and update ECS transform logic
Added overlay and hard light blending functions to util.shdinc for improved shader compositing. Marked brl::random as inline for header safety. Updated EcsEntity::calculateTransform to use local transform properties and parent transforms for correct hierarchical transformations. Added and updated various test assets and textures for tinyswords tower models.
1 parent d421a81 commit a520ab5

32 files changed

+1799
-25
lines changed

default_assets/shaders/util.shdinc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,28 @@ int getShadeIndex(vec3 v) {
4444

4545

4646
return -1;
47-
}
47+
}
48+
49+
float calculateLuminance(vec3 rgbColor) {
50+
return 0.2126 * rgbColor.r + 0.7152 * rgbColor.g + 0.0722 * rgbColor.b;
51+
}
52+
53+
float blendOverlay(float base, float blend) {
54+
return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend));
55+
}
56+
57+
vec3 blendOverlay(vec3 base, vec3 blend) {
58+
return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b));
59+
}
60+
61+
vec3 blendOverlay(vec3 base, vec3 blend, float opacity) {
62+
return (blendOverlay(base, blend) * opacity + base * (1.0 - opacity));
63+
}
64+
65+
vec3 blendHardLight(vec3 base, vec3 blend) {
66+
return blendOverlay(blend,base);
67+
}
68+
69+
vec3 blendHardLight(vec3 base, vec3 blend, float opacity) {
70+
return (blendHardLight(base, blend) * opacity + base * (1.0 - opacity));
71+
}

include/borealis/util/random.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace brl
77
{
8-
int random(int min, int max) {
8+
inline int random(int min, int max) {
99
return min + (std::rand() % (max - min + 1));
1010
}
1111
} // namespace brl

src/brl/ecs/entity.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,14 @@ glm::mat4 brl::EcsEntity::calculateTransform()
157157
{
158158
glm::mat4 t(1.0);
159159

160-
t = translate(t, position());
161-
t *= toMat4(rotation());
162-
t = glm::scale(t, scale());
160+
t = translate(t, localPosition);
161+
t *= toMat4(localRotation);
162+
t = glm::scale(t, localScale);
163+
164+
if (parent)
165+
{
166+
t = parent->calculateTransform() * t;
167+
}
163168

164169
return t;
165170
}
796 KB
Loading
677 KB
Loading
826 KB
Loading
421 KB
Loading
793 KB
Loading
-230 KB
Binary file not shown.
-231 KB
Binary file not shown.

0 commit comments

Comments
 (0)