public override PointColore GetCouleurIntersect(V3 camera, V3 directionOculaire, float intersection) { V3 point = camera + (intersection * directionOculaire); IMA.Invert_Coord_Spherique(point - this.position, this.rayon, out float u, out float v); float offsetU = u / (float)(Math.PI * 2); float offsetV = (v + (float)(Math.PI / 2)) / (float)(Math.PI); V3 dMdu = new V3((float)(-Math.Sin(u) * Math.Cos(v) * rayon), (float)(rayon * (float)(Math.Cos(u) * Math.Cos(v))), 0); V3 dMdv = new V3((float)(-Math.Sin(v) * Math.Cos(v) * rayon), (float)(rayon * (float)(-Math.Sin(u) * Math.Sin(v))), rayon * (float)Math.Cos(v)); float dhdu, dhdv; BumpMap.Bump(offsetU, offsetV, out dhdu, out dhdv); V3 normalPoint = new V3(point - position); normalPoint.Normalize(); V3 T2 = dMdu ^ (dhdv * normalPoint); V3 T3 = (dhdu * normalPoint) ^ dMdv; V3 normaleBump = normalPoint + 0.008f * (T2 + T3); normaleBump.Normalize(); return(new PointColore(point, normaleBump, texture.LireCouleur(offsetU, offsetV), this)); }
public override PointColore GetCouleurIntersect(V3 camera, V3 directionOculaire, float intersection) { V3 point = new V3(camera + intersection * directionOculaire); V3 AI = new V3(point - position); float beta = (AI * AC) / (AC.Norm() * AC.Norm()); float alpha = (AI * AB) / (AB.Norm() * AB.Norm()); V3 dMdu = AB; V3 dMdv = AC; float dhdu, dhdv; BumpMap.Bump(alpha, beta, out dhdu, out dhdv); V3 T2 = dMdu ^ (dhdv * normal); V3 T3 = (dhdu * normal) ^ dMdv; V3 normaleBump = normal + 0.08f * (T2 + T3); normaleBump.Normalize(); V3 positionCouleur = textureA + (alpha * (textureB - textureA) + beta * (textureC - textureA)); return(new PointColore(point, normaleBump, texture.LireCouleur(positionCouleur.x, positionCouleur.y), this)); }
public void ComputeScatteringFunctions(SurfaceInteraction si, IObjectArena arena, TransportMode mode, bool allowMultipleLobes) { BumpMap?.Bump(si); var bsdf = si.BSDF.Initialize(in si); var kd = Kd.Evaluate(in si).Clamp(); if (!kd.IsBlack()) { bsdf.Add(arena.Create <LambertianReflection>().Initialize(in kd)); } var ks = Ks.Evaluate(in si).Clamp(); if (ks.IsBlack()) { return; } var fresnel = arena.Create <FresnelDielectric>().Initialize(1.5f, 1f); var rough = Roughness.Evaluate(in si); if (RemapRoughness) { rough = TrowbridgeReitzDistribution.RoughnessToAlpha(rough); } var distribution = arena.Create <TrowbridgeReitzDistribution>().Initialize(rough, rough); bsdf.Add(arena.Create <MicrofacetReflection>().Initialize(ks, distribution, fresnel)); }
public override PointColore GetCouleurIntersect(V3 camera, V3 directionOculaire, float intersection) { V3 point = new V3(camera + intersection * directionOculaire); V3 AI = new V3(point - position); V3 AB = new V3(pointB - position); V3 ABNormalise = new V3(AB); ABNormalise.Normalize(); V3 AC = new V3(pointC - position); V3 ACNormalise = new V3(AC); ACNormalise.Normalize(); V3 normal = new V3(AB ^ AC); normal.Normalize(); float alpha = (AI * AB) / (AB * AB); float beta = (AI * AC) / (AC * AC); V3 dMdu = AB; V3 dMdv = AC; float dhdu, dhdv; BumpMap.Bump(alpha, beta, out dhdu, out dhdv); V3 T2 = dMdu ^ (dhdv * normal); V3 T3 = (dhdu * normal) ^ dMdv; V3 normaleBump = normal + 0.008f * (T2 + T3); normaleBump.Normalize(); return(new PointColore(point, normaleBump, texture.LireCouleur(alpha, beta), this)); }