Project

General

Profile

« Previous | Next » 

Revision be42e989

Added by Leszek Koltunski over 4 years ago

Fix modifications of normals in VertexEffectScale and VertexEffectShear.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectScale.java
47 47

  
48 48
  static String code()
49 49
    {
50
    return "v *= vUniforms[effect].xyz;";
50
    return
51

  
52
    "v *= vUniforms[effect].xyz;                        \n" +
53
    "float X = vUniforms[effect].y*vUniforms[effect].z; \n" +
54
    "float Y = vUniforms[effect].x*vUniforms[effect].z; \n" +
55
    "float Z = vUniforms[effect].x*vUniforms[effect].y; \n" +
56
    "n *= vec3(X,Y,Z);                                  \n";
51 57
    }
52 58

  
53 59
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/VertexEffectShear.java
45 45
    }
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
// For explanation (esp. about the way we modify vectors n and i) see MatrixEffectShear.
48 49

  
49 50
  static String code()
50 51
    {
51 52
    return
52 53

  
53
      "float sx = vUniforms[effect].x;               \n"
54
    + "float sy = vUniforms[effect].y;               \n"
55
    + "float sz = vUniforms[effect].z;               \n"
56
    + "vec3 center = vUniforms[effect+1].yzw;        \n"
54
      "float sx = vUniforms[effect].x;                  \n"
55
    + "float sy = vUniforms[effect].y;                  \n"
56
    + "float sz = vUniforms[effect].z;                  \n"
57
    + "vec3 center = vUniforms[effect+1].yzw;           \n"
58
    + "float tmp   = sx*sy + 1.0;                       \n"
57 59

  
58
    + "v -= center;                                  \n"
60
    + "v -= center;                                     \n"
59 61

  
60
    + "float new_vx = (1.0+sx*sy)*v.x + sx*v.y;      \n"
61
    + "float new_vy = sy*v.x + v.y;                  \n"
62
    + "float new_vz = sz*v.y + v.z;                  \n"
62
    + "float new_vx = tmp*v.x + sx*v.y;                 \n"
63
    + "float new_vy = sy*v.x + v.y;                     \n"
64
    + "float new_vz = sz*v.y + v.z;                     \n"
63 65

  
64
    + "v.x = new_vx;                                 \n"
65
    + "v.y = new_vy;                                 \n"
66
    + "v.z = new_vz;                                 \n"
66
    + "v.x = new_vx;                                    \n"
67
    + "v.y = new_vy;                                    \n"
68
    + "v.z = new_vz;                                    \n"
67 69

  
68
    + "v += center;                                  \n"
70
    + "v += center;                                     \n"
69 71

  
70
    + "float new_nx = (1.0+sx*sy)*n.x + sx*n.y;      \n"
71
    + "float new_ny = sy*n.x + n.y;                  \n"
72
    + "float new_nz = sz*n.y + n.z;                  \n"
72
    + "float new_nx = n.x - sy*n.y + sy*sz*n.z;         \n"
73
    + "float new_ny =-sx*n.x + tmp*(n.y - sz*n.z);      \n"
74
    + "n.x = new_nx;                                    \n"
75
    + "n.y = new_ny;                                    \n"
73 76

  
74
    + "n.x = new_nx;                                 \n"
75
    + "n.y = new_ny;                                 \n"
76
    + "n.z = new_nz;                                 \n"
77
    + "#ifdef PREAPPLY                                  \n"
77 78

  
78
    + "#ifdef PREAPPLY                               \n"
79
    + "float new_ix = inf.x - sy*inf.y + sy*sz*inf.z;   \n"
80
    + "float new_iy =-sx*inf.x + tmp*(inf.y - sz*inf.z);\n"
81
    + "inf.x = new_ix;                                  \n"
82
    + "inf.y = new_iy;                                  \n"
79 83

  
80
    + "float new_ix = (1.0+sx*sy)*inf.x + sx*inf.y;  \n"
81
    + "float new_iy = sy*inf.x + inf.y;              \n"
82
    + "float new_iz = sz*inf.y + inf.z;              \n"
83

  
84
    + "inf.x = new_ix;                               \n"
85
    + "inf.y = new_iy;                               \n"
86
    + "inf.z = new_iz;                               \n"
87

  
88
    + "#endif                                        \n";
84
    + "#endif                                           \n";
89 85
    }
90 86

  
91 87
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff