mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-05-02 09:34:58 +00:00
feat: Enhance spinning cube shader and adjust rainbow color calculations
This commit is contained in:
@@ -531,6 +531,7 @@ local function create_static_cube(position, scale, color)
|
||||
end
|
||||
|
||||
local function create_spinning_cube()
|
||||
log_debug("Spinning cube shader=default (rainbow wrap)")
|
||||
local function compute_model_matrix(time)
|
||||
local rotation = math3d.rotation_y(time * rotation_speed)
|
||||
local scale = scale_matrix(1.5, 1.5, 1.5) -- Make cube 3x3x3 units
|
||||
|
||||
@@ -5,7 +5,7 @@ layout(location = 1) in vec3 fragWorldPos;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
vec3 RainbowBand(float t) {
|
||||
t = clamp(t, 0.0, 1.0);
|
||||
t = fract(t);
|
||||
float scaled = t * 5.0;
|
||||
int index = int(floor(scaled));
|
||||
float blend = fract(scaled);
|
||||
@@ -40,8 +40,8 @@ vec3 RainbowBand(float t) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
float bandPos = (fragWorldPos.y + 1.0) * 0.5;
|
||||
float diagonal = (fragWorldPos.x + fragWorldPos.z) * 0.15;
|
||||
float bandPos = fragWorldPos.y * 0.35;
|
||||
float diagonal = (fragWorldPos.x + fragWorldPos.z) * 0.25;
|
||||
vec3 rainbow = RainbowBand(bandPos + diagonal);
|
||||
vec3 shaded = mix(rainbow, fragColor, 0.08);
|
||||
outColor = vec4(shaded, 1.0);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user