示例#1
0
        override public Couleur getCouleurRaycast(V3 PointIntersection, Scene scene)
        {
            //Console.WriteLine("Sphere Pt Intersect: " + PointIntersection.x + " " + PointIntersection.y + " " + PointIntersection.z);

            V3 pixel_position = PointIntersection - center;

            //Console.WriteLine("                      " + PointIntersection.x + " " + PointIntersection.y + " " + PointIntersection.z);

            IMA.Invert_Coord_Spherique(pixel_position, rayon, out float u, out float v);
            //Console.WriteLine("        u: " + u+" ,v " + v);



            //------------------------------BUMP MAPING---------------------------------------//
            float pi         = (float)Math.PI;
            float uNormalise = u / (2 * pi);
            float vNormalise = v / pi + pi;

            Partial_derivative(u, v, out V3 dMdu, out V3 dMdv);
            materiel.GetTextureBump().Bump(uNormalise, vNormalise, out float dhdu, out float dhdv);
            V3 normal = getNormal(u, v) + materiel.GetForceBumping() * (dhdu * (getNormal(u, v) ^ dMdv) + dhdv * (getNormal(u, v) ^ dMdu));

            //------------------------------TEXTURE---------------------------------------//
            Couleur couleur = new Couleur();

            if (materiel.GetTexture() != null)
            {
                couleur = materiel.GetTexture().LireCouleur(uNormalise, vNormalise);
            }
            else
            {
                couleur = materiel.GetCouleur();
            }

            //------------------------------LUMIERE---------------------------------------//
            couleur = scene.CouleurEclairee(PointIntersection, normal, couleur, materiel, this);

            return(couleur);
        }
示例#2
0
        override public Couleur getCouleurRaycast(V3 PointIntersection, Scene scene)
        {
            float u = ((PointIntersection - A) * (B - A)) / ((B - A) * (B - A));
            float v = ((PointIntersection - A) * (C - A)) / ((C - A) * (C - A));


            //V3 pixel_position = getPixel3DPosition(u, v);
            V3 pixel_position = PointIntersection;


            //------------------------------BUMP MAPING---------------------------------------//
            float uNormalise = u;
            float vNormalise = v;

            Partial_derivative(u, v, out V3 dMdu, out V3 dMdv);
            materiel.GetTextureBump().Bump(u, v, out float dhdu, out float dhdv);
            V3 normal = getNormal() + materiel.GetForceBumping() * (dhdu * (getNormal() ^ dMdv) + dhdv * (getNormal() ^ dMdu));

            //V3 normal = getNormal(u,v);
            //------------------------------TEXTURE---------------------------------------//
            Couleur couleur = new Couleur();

            if (materiel.GetTexture() != null)
            {
                couleur = materiel.GetTexture().LireCouleur(uNormalise, vNormalise);
            }
            else
            {
                couleur = materiel.GetCouleur();
            }

            //------------------------------LUMIERE---------------------------------------//
            couleur = scene.CouleurEclairee(pixel_position, normal, couleur, materiel, this);
            //System.Console.WriteLine(couleur.R+" "+couleur.V+" "+couleur.B);
            //------------------------------DESSIN FINAL---------------------------------------//
            return(couleur);
        }