Ajout du shader d'ouverture sur la page d'accueil

This commit is contained in:
2026-08-02 15:31:56 +02:00
parent 36d9ac4230
commit dc2f0013b0
7 changed files with 39 additions and 41 deletions
+1
View File
@@ -160,6 +160,7 @@
</article> </article>
</section> </section>
</section> </section>
<video data-cute-texture-video class="cute-texture-video" src="/assets/video/background.webm" autoplay muted loop ></video>
<canvas class="cute-texture"></canvas> <canvas class="cute-texture"></canvas>
</main> </main>
+18 -16
View File
@@ -110,7 +110,9 @@ const DEFAULT_FRAGMENT_SHADER = `
/** /**
* Initialise un canvas d'arrière plan "CuteTexture" avec les options données * Initialise un canvas d'arrière plan "CuteTexture" avec les options données
*/ */
export function initCuteTexture(){ export function initCuteTexture(options){
let shaderSourceOption = options?.shaderSource;
/** @type {HTMLCanvasElement} */ /** @type {HTMLCanvasElement} */
const targetCanvas = document.querySelector("canvas[data-cute-texture]") || document.querySelector("canvas.cute-texture") || document.querySelector("canvas"); const targetCanvas = document.querySelector("canvas[data-cute-texture]") || document.querySelector("canvas.cute-texture") || document.querySelector("canvas");
if(!targetCanvas) if(!targetCanvas)
@@ -128,7 +130,9 @@ export function initCuteTexture(){
if(ctx == null) if(ctx == null)
throw new Error("WebGL n'ext pas supporté sur votre machine") throw new Error("WebGL n'ext pas supporté sur votre machine")
let mainShader = initMainShader(ctx) let mainShader = initMainShader(ctx, {
shaderSource: shaderSourceOption
})
console.log("Shader CuteTexture initialisé", mainShader) console.log("Shader CuteTexture initialisé", mainShader)
const initTime = Date.now() const initTime = Date.now()
@@ -153,7 +157,9 @@ export function initCuteTexture(){
/** /**
* @param {WebGLRenderingContext} ctx * @param {WebGLRenderingContext} ctx
*/ */
function initMainShader(ctx, oldShader=null){ function initMainShader(ctx, options){
let fragmentShaderCode = options?.shaderSource;
const vertexShader = ctx.createShader(ctx.VERTEX_SHADER) const vertexShader = ctx.createShader(ctx.VERTEX_SHADER)
ctx.shaderSource(vertexShader, DEFAULT_VERTEX_SHADER) ctx.shaderSource(vertexShader, DEFAULT_VERTEX_SHADER)
ctx.compileShader(vertexShader) ctx.compileShader(vertexShader)
@@ -164,11 +170,11 @@ function initMainShader(ctx, oldShader=null){
return null return null
} }
let fragmentShaderCode; if(!fragmentShaderCode){
let fragmentShaderCodeElement = document.querySelector(`script[type="x-shader/glsl+fragment"]`); fragmentShaderCode = getDocumentShaderSource(document);
if(fragmentShaderCodeElement){ }
fragmentShaderCode = fragmentShaderCodeElement.innerHTML
} else { if(!fragmentShaderCode){
fragmentShaderCode = DEFAULT_FRAGMENT_SHADER fragmentShaderCode = DEFAULT_FRAGMENT_SHADER
} }
@@ -229,13 +235,6 @@ function initMainShader(ctx, oldShader=null){
} }
} }
if(oldShader){
ctx.deleteProgram(oldShader.program)
ctx.deleteShader(oldShader.vertexShader)
ctx.deleteShader(oldShader.fragmentShader)
ctx.deleteBuffer(oldShader.vertexIndexBuffer)
}
const vertexIndexBuffer = ctx.createBuffer() const vertexIndexBuffer = ctx.createBuffer()
ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexIndexBuffer) ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexIndexBuffer)
ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array([0, 1, 2]), ctx.STATIC_DRAW) ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array([0, 1, 2]), ctx.STATIC_DRAW)
@@ -244,7 +243,6 @@ function initMainShader(ctx, oldShader=null){
program: shaderProgram, program: shaderProgram,
vertexShader, vertexShader,
fragmentShader, fragmentShader,
fragmentShaderElement: fragmentShaderCodeElement,
videoElement, videoElement,
videoTexture, videoTexture,
aVertexIndex: ctx.getAttribLocation(shaderProgram, "aVertexIndex"), aVertexIndex: ctx.getAttribLocation(shaderProgram, "aVertexIndex"),
@@ -344,3 +342,7 @@ function renderCuteTexture(target, mainShader, initTime){
ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, 3); ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, 3);
} }
export function getDocumentShaderSource(doc=document){
return doc.querySelector(`script[type="x-shader/glsl+fragment"]`)?.innerHTML
}
+10 -4
View File
@@ -2,12 +2,18 @@ import { loadEvents } from './events.js'
import { loadStatus } from './status.js' import { loadStatus } from './status.js'
import { initCuteTexture } from './cuteTexture.js' import { initCuteTexture } from './cuteTexture.js'
// =================================== background texture
initCuteTexture()
// ======================================== events & statut d'ouverture // ======================================== events & statut d'ouverture
loadEvents(); loadEvents();
loadStatus(); loadStatus()
.then((status) => {
console.log("Status actuel du LOL", status);
let cuteTexture = initCuteTexture({
shaderSource: status.shaderSource
});
cuteTexture.target.style.visibility = "visible"
});
// ======================================== floating event window // ======================================== floating event window
+6 -8
View File
@@ -1,4 +1,4 @@
import { statusProxy } from './main.js' import { getDocumentShaderSource } from './cuteTexture.js';
export async function loadStatus(){ export async function loadStatus(){
let res = await fetch('/status/index.html'); let res = await fetch('/status/index.html');
@@ -6,6 +6,8 @@ export async function loadStatus(){
let html_text = await res.text() let html_text = await res.text()
let html = new DOMParser().parseFromString(html_text, "text/html"); let html = new DOMParser().parseFromString(html_text, "text/html");
let shaderSource = getDocumentShaderSource(html);
let target = document.querySelector('#statuSection'); let target = document.querySelector('#statuSection');
let hiddenBtn = target.querySelector('a'); let hiddenBtn = target.querySelector('a');
@@ -15,13 +17,7 @@ export async function loadStatus(){
let status = html.querySelector('#lolStatus'); let status = html.querySelector('#lolStatus');
console.log('current status:', status.innerText); console.log('current status:', status.innerText);
let isOpen = status.innerText.includes('ouvert');
if (status.innerText.includes('ouvert')){
statusProxy.lolStatus = true;
}else{
statusProxy.lolStatus = false;
}
let icon = html.querySelector('link[rel="icon"]'); let icon = html.querySelector('link[rel="icon"]');
let style = html.querySelectorAll('link[rel="stylesheet"]')[0]; let style = html.querySelectorAll('link[rel="stylesheet"]')[0];
@@ -31,4 +27,6 @@ export async function loadStatus(){
document.head.append(style); document.head.append(style);
target.appendChild(status); target.appendChild(status);
return { open: isOpen, shaderSource };
} }
+1 -1
View File
@@ -45,7 +45,7 @@ void main() {
rotatedColor.x*opacity, rotatedColor.x*opacity,
rotatedColor.y*opacity, rotatedColor.y*opacity,
rotatedColor.z*opacity, rotatedColor.z*opacity,
opacity 1.0
); );
} }
</script> </script>
+1 -1
View File
@@ -52,7 +52,7 @@ void main() {
1.0 1.0
); );
highp vec2 videoCoords = vTextureCoord.xy / 2.0 + vec2(0, 0.45); highp vec2 videoCoords = (vTextureCoord.xy / 1.5) + vec2(0, 0.25);
highp vec4 videoPix = clamp(( grayscale(texture2D(uVideo, videoCoords), 1.0) * 2.0 ), vec4(0), vec4(1)); highp vec4 videoPix = clamp(( grayscale(texture2D(uVideo, videoCoords), 1.0) * 2.0 ), vec4(0), vec4(1));
videoPix *= 0.777; videoPix *= 0.777;
+2 -11
View File
@@ -104,12 +104,7 @@ video{
width: auto; width: auto;
position: absolute; position: absolute;
inset: 0; inset: 0;
z-index: -30; z-index: -32;
}
.closedBackground{
opacity: .5;
mix-blend-mode: exclusion;
} }
.openBackground{ .openBackground{
@@ -505,9 +500,5 @@ canvas{
width: auto; width: auto;
position: absolute; position: absolute;
inset: 0; inset: 0;
z-index: -32; z-index: -30;
opacity: .5;
filter: hue-rotate(13.12deg);
mix-blend-mode: multiply;
} }