Salome HOME
PERSALYS : implement patch à la EDF - Test
[tools/sat_salome.git] / products / patches / pv_coincident.patch
1 diff -Naur ParaView-5.8.0_SRC_orig/Remoting/Views/Resources/utilities_remotingviews.xml ParaView-5.8.0_SRC_modif/Remoting/Views/Resources/utilities_remotingviews.xml
2 --- ParaView-5.8.0_SRC_orig/Remoting/Views/Resources/utilities_remotingviews.xml        2020-03-23 13:30:04.000000000 +0300
3 +++ ParaView-5.8.0_SRC_modif/Remoting/Views/Resources/utilities_remotingviews.xml       2020-04-27 19:07:56.559333300 +0300
4 @@ -31,7 +31,7 @@
5        <DoubleVectorProperty name="PolygonOffsetParameters"
6          command="SetPolygonOffsetParameters"
7          number_of_elements="2"
8 -        default_values="0.0 0.0"
9 +        default_values="2.0 2.0"
10          panel_visibility="advanced">
11          <DoubleRangeDomain name="range" />
12          <Documentation>
13 @@ -51,7 +51,7 @@
14        <DoubleVectorProperty name="LineOffsetParameters"
15          command="SetLineOffsetParameters"
16          number_of_elements="2"
17 -        default_values="0.0 -4"
18 +        default_values="1.0 1.0"
19          panel_visibility="advanced">
20          <DoubleRangeDomain name="range" />
21          <Documentation>
22 @@ -66,7 +66,7 @@
23        <DoubleVectorProperty name="PointOffsetParameter"
24          command="SetPointOffsetParameter"
25          number_of_elements="1"
26 -        default_values="-8"
27 +        default_values="0"
28          panel_visibility="advanced">
29          <DoubleRangeDomain name="range" />
30          <Documentation>
31 diff -Naur ParaView-5.8.0_SRC_orig/VTK/Rendering/Core/vtkMapper.cxx ParaView-5.8.0_SRC_modif/VTK/Rendering/Core/vtkMapper.cxx
32 --- ParaView-5.8.0_SRC_orig/VTK/Rendering/Core/vtkMapper.cxx    2020-03-23 13:31:28.000000000 +0300
33 +++ ParaView-5.8.0_SRC_modif/VTK/Rendering/Core/vtkMapper.cxx   2020-04-27 18:07:54.639203400 +0300
34 @@ -35,11 +35,11 @@
35  static double vtkMapperGlobalResolveCoincidentTopologyZShift = 0.01;
36  static int vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFaces = 1;
37  
38 -static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor = 0.0;
39 -static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits = 0.0;
40 -static double vtkMapperGlobalResolveCoincidentTopologyLineOffsetFactor = 0.0;
41 -static double vtkMapperGlobalResolveCoincidentTopologyLineOffsetUnits = -4.0;
42 -static double vtkMapperGlobalResolveCoincidentTopologyPointOffsetUnits = -8.0;
43 +static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor = 2.0;
44 +static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits = 2.0;
45 +static double vtkMapperGlobalResolveCoincidentTopologyLineOffsetFactor = 1.0;
46 +static double vtkMapperGlobalResolveCoincidentTopologyLineOffsetUnits = 1.0;
47 +static double vtkMapperGlobalResolveCoincidentTopologyPointOffsetUnits = 0.0;
48  
49  // Construct with initial range (0,1).
50  vtkMapper::vtkMapper()
51 diff -Naur ParaView-5.8.0_SRC_orig/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx ParaView-5.8.0_SRC_modif/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
52 --- ParaView-5.8.0_SRC_orig/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx   2020-03-23 13:31:28.000000000 +0300
53 +++ ParaView-5.8.0_SRC_modif/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx  2020-04-27 18:12:49.486483700 +0300
54 @@ -1963,7 +1963,6 @@
55    float factor = 0.0;
56    float offset = 0.0;
57    this->GetCoincidentParameters(ren, actor, factor, offset);
58 -  vtkOpenGLCamera* cam = (vtkOpenGLCamera*)(ren->GetActiveCamera());
59  
60    // if we need an offset handle it here
61    // The value of .000016 is suitable for depth buffers
62 @@ -1974,23 +1973,26 @@
63    {
64      std::string FSSource = shaders[vtkShader::Fragment]->GetSource();
65  
66 -    if (cam->GetParallelProjection())
67 +    if (factor != 0.0)
68      {
69 -      vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec", "uniform float cCValue;");
70 +      vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec", 
71 +        "uniform float cfactor;\n"
72 +        "uniform float coffset;");
73        vtkShaderProgram::Substitute(
74 -        FSSource, "//VTK::Depth::Impl", "gl_FragDepth = gl_FragCoord.z + cCValue;\n");
75 +        FSSource, 
76 +        "//VTK::UniformFlow::Impl",
77 +        "float cscale = length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));\n"
78 +        "  //VTK::UniformFlow::Impl\n" // for other replacements
79 +        );
80 +        vtkShaderProgram::Substitute(FSSource, "//VTK::Depth::Impl",
81 +        "gl_FragDepth = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;\n");
82      }
83      else
84      {
85        vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec",
86 -        "uniform float cCValue;\n"
87 -        "uniform float cSValue;\n"
88 -        "uniform float cDValue;");
89 -      vtkShaderProgram::Substitute(FSSource, "//VTK::Depth::Impl",
90 -        "float Zdc = gl_FragCoord.z*2.0 - 1.0;\n"
91 -        "  float Z2 = -1.0*cDValue/(Zdc + cCValue) + cSValue;\n"
92 -        "  float Zdc2 = -1.0*cCValue - cDValue/Z2;\n"
93 -        "  gl_FragDepth = Zdc2*0.5 + 0.5;\n");
94 +        "uniform float coffset;");
95 +      vtkShaderProgram::Substitute(
96 +        FSSource, "//VTK::Depth::Impl", "gl_FragDepth = gl_FragCoord.z + 0.000016*coffset;\n");
97      }
98      shaders[vtkShader::Fragment]->SetSource(FSSource);
99    }
100 @@ -2110,14 +2112,12 @@
101    // Have the renderpasses changed?
102    vtkMTimeType renderPassMTime = this->GetRenderPassStageMTime(actor);
103  
104 -  vtkOpenGLCamera* cam = (vtkOpenGLCamera*)(ren->GetActiveCamera());
105 -
106    // shape of input data changed?
107    float factor, offset;
108    this->GetCoincidentParameters(ren, actor, factor, offset);
109    unsigned int scv = (this->CurrentInput->GetPointData()->GetNormals() ? 0x01 : 0) +
110      (this->HaveCellScalars ? 0x02 : 0) + (this->HaveCellNormals ? 0x04 : 0) +
111 -    ((cam->GetParallelProjection() != 0.0) ? 0x08 : 0) + ((offset != 0.0) ? 0x10 : 0) +
112 +    ((factor != 0.0) ? 0x08 : 0) + ((offset != 0.0) ? 0x10 : 0) +
113      (this->VBOs->GetNumberOfComponents("scalarColor") ? 0x20 : 0) +
114      ((this->VBOs->GetNumberOfComponents("tcoord") % 4) << 6);
115  
116 @@ -2381,6 +2381,19 @@
117      lineWidth[1] = 2.0 * actor->GetProperty()->GetLineWidth() / vp[3];
118      cellBO.Program->SetUniform2f("lineWidthNVC", lineWidth);
119    }
120 +  
121 +  // handle coincident
122 +  if (cellBO.Program->IsUniformUsed("coffset"))
123 +  {
124 +    float factor, offset;
125 +    this->GetCoincidentParameters(ren, actor,factor,offset);
126 +    cellBO.Program->SetUniformf("coffset",offset);
127 +    // cfactor isn't always used when coffset is.
128 +    if (cellBO.Program->IsUniformUsed("cfactor"))
129 +    {
130 +      cellBO.Program->SetUniformf("cfactor", factor);
131 +    }
132 +  }
133  }
134  
135  //-----------------------------------------------------------------------------
136 @@ -2436,25 +2449,6 @@
137      }
138    }
139  
140 -  // handle coincident
141 -  if (cellBO.Program->IsUniformUsed("cCValue"))
142 -  {
143 -    float diag = actor->GetLength();
144 -    float factor, offset;
145 -    this->GetCoincidentParameters(ren, actor, factor, offset);
146 -    if (cam->GetParallelProjection())
147 -    {
148 -      // one unit of offset is based on 1/1000 of bounding length
149 -      cellBO.Program->SetUniformf("cCValue", -2.0 * 0.001 * diag * offset * vcdc->GetElement(2, 2));
150 -    }
151 -    else
152 -    {
153 -      cellBO.Program->SetUniformf("cCValue", vcdc->GetElement(2, 2));
154 -      cellBO.Program->SetUniformf("cDValue", vcdc->GetElement(3, 2));
155 -      cellBO.Program->SetUniformf("cSValue", -0.001 * diag * offset);
156 -    }
157 -  }
158 -
159    // If the VBO coordinates were shifted and scaled, apply the inverse transform
160    // to the model->view matrix:
161    vtkOpenGLVertexBufferObject* vvbo = this->VBOs->GetVBO("vertexMC");