Commit 7741dabb authored by paps's avatar paps
Browse files

fin d'implémentation des perturbation de normal avec le bruit de perlin

Probleme du segfault dans la binder réglé
parent 5f7f2883
Loading
Loading
Loading
Loading
+181 −183
Original line number Diff line number Diff line
@@ -184,7 +184,8 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min


    // ### Debut : Intersection en X
    if (dir.x > EPSILON) {
    if (dir.x > EPSILON) 
    {

        Real distExitTMP = (max.x - orig.x - EPSILON)/dir.x;

@@ -332,9 +333,9 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

    pointEntry = ray.getPoint(distEntry + EPSILON);

    curVoxelX = (int)(((pointEntry.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
    curVoxelY = (int)(((pointEntry.y - min.y) / m_lenBinder.y) * m_nbVoxelY);
    curVoxelZ = (int)(((pointEntry.z - min.z) / m_lenBinder.z) * m_nbVoxelZ);
    curVoxelX = (int)((((int)(pointEntry.x - min.x)) / m_lenBinder.x) * m_nbVoxelX);
    curVoxelY = (int)((((int)(pointEntry.y - min.y)) / m_lenBinder.y) * m_nbVoxelY);
    curVoxelZ = (int)((((int)(pointEntry.z - min.z)) / m_lenBinder.z) * m_nbVoxelZ);

    if (origInBinder) {
        minbound = 2 * EPSILON;
@@ -343,8 +344,6 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
    }
    maxbound = minbound;



    // ## Initialisation de la progression en X
    if (dir.x > EPSILON) {

@@ -373,7 +372,6 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

            vY = 1;
            incVoxelY = m_nbVoxelX;

            dy = m_lenVoxel.y / dir.y;
            Dy = (min.y + m_lenVoxel.y * (curVoxelY+1) - orig.y) / dir.y;

@@ -407,7 +405,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
            incVoxelZ = -(m_nbVoxelX * m_nbVoxelY);

            dz = -m_lenVoxel.z / dir.z;
            Dz = (min.z + m_lenVoxel.z * (curVoxelZ) - orig.z) / dir.z;
            Dz = (min.z + m_lenVoxel.z * (curVoxelZ-1) - orig.z) / dir.z;

    } else {

+1 −2
Original line number Diff line number Diff line
@@ -224,8 +224,7 @@ LrGeometryFacet::getIntersection(const LrRay &ray, LrHit *hit, int fragment,

    // si on arrive par l'arrière ou qu'on est parallèle à la facette
    // il n'y a pas d'intersection
    if (N * ray.getDirection() > 0)
        return false;
    if (N * ray.getDirection() > 0) return false;

    // distance avec le point d'impact sur le plan
    LrVector OA(ray.getOrigin(), A);
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ LrColor LrOpticPhong::compute(const LrRay &rayIn, const LrVector &rayOut,
                              const LrVector &normal, const LrVector &tangeante, 
                              Real u, Real v) const
{
    LrVector normalPert = m_pertNormal->getNormal(u, v, tangeante, normal);
    LrVector normalPert = m_pertNormal->getNormal(u, v, tangeante, normal, rayIn.getOrigin());
   //voir cour page 88
  //(rayIn*normal) == cos entre la normal et rayIn
    Real angleLamb = normalPert*rayIn.getDirection();
+19 −0
Original line number Diff line number Diff line
@@ -94,3 +94,22 @@ double LrPerlin::d_noise(double x, double y, double z)
		   grad(p[BB+1], x-1, y-1, z-1))));
}
/*****************************************************************************/
Real LrPerlin::lissage(Real x, Real y, Real z)
{
    Real corners = ( f_noise(x-1, y-1, z-1) 
                    + f_noise(x+1, y-1, z-1)
                    + f_noise(x-1, y+1, z+1)
                    + f_noise(x+1, y+1, z+1) ) / 16;
    
    Real sides   = ( f_noise(x-1, y, z)  
                    + f_noise(x+1, y, z)  
                    + f_noise(x, y-1, z)  
                    + f_noise(x, y+1, z) 
                    + f_noise(x, y, z-1)  
                    + f_noise(x, y, z+1) ) /  8;
    
    Real center  =  f_noise(x, y, z) / 4;

    return corners + sides + center;

}
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ class LrPerlin

        /** version de d_noise avec des float */
        Real f_noise(Real x, Real y, Real z);
        Real lissage(Real x, Real y, Real z);

      private :
         /** matrice du bruit de perlin pour la texture en calcule */
Loading