multiple labmda

This commit is contained in:
2025-12-28 17:04:49 +01:00
parent d8e178fe06
commit 911deefbf5
3 changed files with 189 additions and 47 deletions

View File

@ -8,13 +8,15 @@ out vec4 finalColor;
uniform vec2 center;
uniform float screenHeight;
uniform vec2 resolution;
//uniform vec2 resolution;
uniform float d1;
uniform float d2;
uniform float lambda;
//uniform float lambda;
uniform float angleM1;
uniform float angleM1_Y;
uniform float zoom;
uniform float lambdas[10];
uniform int lambdasCount;
const float PI = 3.14159265359;
@ -45,26 +47,43 @@ void main() {
float relX = (pixelX - center.x) * zoom;
float relY = (pixelY - center.y) * zoom;
vec3 baseColorVec = WavelengthToRGB(lambda);
// r^2
float radiusSq = relX * relX + relY * relY;
// Diff de marche lamme d'air 2 * e cos(i) mais petits angles => cos(i) ~ 1 - i^2/2 mais i ~ r/f et r^2 = x^2 + y^2
float ringFactor = radiusSq * 0.065;
float ringFactorBase = radiusSq * 0.065;
// Diff de marche du au coin d'air
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0f;
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0;
float currDelta = deltaLnm - ringFactor + wDelta;
float currDeltaBase = deltaLnm + wDelta;
// Formule de Fresnel : I = I_0 * cos^2(phi)
float K = PI / lambda;
float phase = currDelta * K;
float intensity = cos(phase);
intensity = intensity * intensity;
float currDelta = deltaLnm - ringFactorBase + wDelta;
vec3 finalVec = baseColorVec * intensity;
vec3 accumColor = vec3(0.0);
finalColor = vec4(finalVec, 1.0);
for(int i = 0; i < 10; i++) {
if (i >= lambdasCount) break;
float l = lambdas[i];
vec3 baseColorVec = WavelengthToRGB(l);
float currDelta = currDeltaBase - ringFactorBase;
float K = PI / l;
float phase = currDelta * K;
float intensity = cos(phase);
intensity = intensity * intensity;
accumColor += baseColorVec * intensity;
}
// finalColor = vec4(accumColor, 1.0);
// float K = PI / lambda;
// float phase = currDelta * K;
// float intensity = cos(phase);
// intensity = intensity * intensity;
// vec3 finalVec = baseColorVec * intensity;
//finalColor = vec4(finalVec, 1.0);
finalColor = vec4(accumColor, 1.0);
}