Salome HOME
a1e25e7fc8666fee05f0324921a83dff7c4931d8
[tools/sat_salome.git] / products / patches / paraview.0008-ParaView_coincident_rendering.patch
1 diff -Naur ParaView-5.9.0_SRC_orig/Remoting/Views/Resources/utilities_remotingviews.xml ParaView-5.9.0_SRC_modif/Remoting/Views/Resources/utilities_remotingviews.xml
2 --- ParaView-5.9.0_SRC_orig/Remoting/Views/Resources/utilities_remotingviews.xml
3 +++ ParaView-5.9.0_SRC_modif/Remoting/Views/Resources/utilities_remotingviews.xml
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.9.0_SRC_orig/VTK/Rendering/Core/vtkMapper.cxx ParaView-5.9.0_SRC_modif/VTK/Rendering/Core/vtkMapper.cxx
32 --- ParaView-5.9.0_SRC_orig/VTK/Rendering/Core/vtkMapper.cxx
33 +++ ParaView-5.9.0_SRC_modif/VTK/Rendering/Core/vtkMapper.cxx
34 @@ -36,11 +36,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  vtkCxxSetObjectMacro(vtkMapper, Selection, vtkSelection);
50  
51 diff -Naur ParaView-5.9.0_SRC_orig/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx ParaView-5.9.0_SRC_modif/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
52 --- ParaView-5.9.0_SRC_orig/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
53 +++ ParaView-5.9.0_SRC_modif/VTK/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
54 @@ -2430,42 +2430,26 @@
55    {
56      std::string FSSource = shaders[vtkShader::Fragment]->GetSource();
57  
58 -    if (ren->GetActiveCamera()->GetParallelProjection())
59 -    {
60 -      vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec", "uniform float cCValue;");
61 -      if (this->DrawingTubesOrSpheres(*this->LastBoundBO, actor))
62 -      {
63 -        vtkShaderProgram::Substitute(
64 -          FSSource, "//VTK::Depth::Impl", "gl_FragDepth = gl_FragDepth + cCValue;\n");
65 -      }
66 -      else
67 -      {
68 -        vtkShaderProgram::Substitute(
69 -          FSSource, "//VTK::Depth::Impl", "gl_FragDepth = gl_FragCoord.z + cCValue;\n");
70 -      }
71 +    if (factor != 0.0)
72 +    {
73 +      vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec", 
74 +        "uniform float cfactor;\n"
75 +        "uniform float coffset;");
76 +       vtkShaderProgram::Substitute(
77 +        FSSource, 
78 +        "//VTK::UniformFlow::Impl",
79 +        "float cscale = length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));\n"
80 +        "  //VTK::UniformFlow::Impl\n" // for other replacements
81 +        );
82 +        vtkShaderProgram::Substitute(FSSource, "//VTK::Depth::Impl",
83 +        "gl_FragDepth = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;\n");
84      }
85      else
86      {
87 -      vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec",
88 -        "uniform float cCValue;\n"
89 -        "uniform float cSValue;\n"
90 -        "uniform float cDValue;");
91 -      if (this->DrawingTubesOrSpheres(*this->LastBoundBO, actor))
92 -      {
93 -        vtkShaderProgram::Substitute(FSSource, "//VTK::Depth::Impl",
94 -          "float Zdc = gl_FragDepth*2.0 - 1.0;\n"
95 -          "  float Z2 = -1.0*cDValue/(Zdc + cCValue) + cSValue;\n"
96 -          "  float Zdc2 = -1.0*cCValue - cDValue/Z2;\n"
97 -          "  gl_FragDepth = Zdc2*0.5 + 0.5;\n");
98 -      }
99 -      else
100 -      {
101 -        vtkShaderProgram::Substitute(FSSource, "//VTK::Depth::Impl",
102 -          "float Zdc = gl_FragCoord.z*2.0 - 1.0;\n"
103 -          "  float Z2 = -1.0*cDValue/(Zdc + cCValue) + cSValue;\n"
104 -          "  float Zdc2 = -1.0*cCValue - cDValue/Z2;\n"
105 -          "  gl_FragDepth = Zdc2*0.5 + 0.5;\n");
106 -      }
107 +       vtkShaderProgram::Substitute(FSSource, "//VTK::Coincident::Dec",
108 +        "uniform float coffset;");
109 +      vtkShaderProgram::Substitute(
110 +        FSSource, "//VTK::Depth::Impl", "gl_FragDepth = gl_FragCoord.z + 0.000016*coffset;\n");
111      }
112      shaders[vtkShader::Fragment]->SetSource(FSSource);
113    }
114 @@ -2586,14 +2570,13 @@
115    // Have the renderpasses changed?
116    vtkMTimeType renderPassMTime = this->GetRenderPassStageMTime(actor);
117  
118 -  vtkOpenGLCamera* cam = (vtkOpenGLCamera*)(ren->GetActiveCamera());
119  
120    // shape of input data changed?
121    float factor, offset;
122    this->GetCoincidentParameters(ren, actor, factor, offset);
123    unsigned int scv = (this->CurrentInput->GetPointData()->GetNormals() ? 0x01 : 0) +
124      (this->HaveCellScalars ? 0x02 : 0) + (this->HaveCellNormals ? 0x04 : 0) +
125 -    ((cam->GetParallelProjection() != 0.0) ? 0x08 : 0) + ((offset != 0.0) ? 0x10 : 0) +
126 +    ((factor != 0.0) ? 0x08 : 0) + ((offset != 0.0) ? 0x10 : 0) +
127      (this->VBOs->GetNumberOfComponents("scalarColor") ? 0x20 : 0) +
128      (vtkOpenGLRenderer::SafeDownCast(ren)->GetUseSphericalHarmonics() ? 0x40 : 0) +
129      (actor->GetProperty()->GetCoatStrength() > 0.0 ? 0x80 : 0) +
130 @@ -2910,6 +2893,19 @@
131      lineWidth[1] = 2.0 * propLineWidth / vp[3];
132      cellBO.Program->SetUniform2f("lineWidthNVC", lineWidth);
133    }
134 +   
135 +  // handle coincident
136 +  if (cellBO.Program->IsUniformUsed("coffset"))
137 +  {
138 +    float factor, offset;
139 +    this->GetCoincidentParameters(ren, actor,factor,offset);
140 +    cellBO.Program->SetUniformf("coffset",offset);
141 +    // cfactor isn't always used when coffset is.
142 +    if (cellBO.Program->IsUniformUsed("cfactor"))
143 +    {
144 +      cellBO.Program->SetUniformf("cfactor", factor);
145 +    }
146 +  }
147    vtkOpenGLCheckErrorMacro("failed after UpdateShader");
148  }
149  
150 @@ -2995,25 +2991,6 @@
151      }
152    }
153  
154 -  // handle coincident
155 -  if (cellBO.Program->IsUniformUsed("cCValue"))
156 -  {
157 -    float diag = actor->GetLength();
158 -    float factor, offset;
159 -    this->GetCoincidentParameters(ren, actor, factor, offset);
160 -    if (cam->GetParallelProjection())
161 -    {
162 -      // one unit of offset is based on 1/1000 of bounding length
163 -      cellBO.Program->SetUniformf("cCValue", -2.0 * 0.001 * diag * offset * vcdc->GetElement(2, 2));
164 -    }
165 -    else
166 -    {
167 -      cellBO.Program->SetUniformf("cCValue", vcdc->GetElement(2, 2));
168 -      cellBO.Program->SetUniformf("cDValue", vcdc->GetElement(3, 2));
169 -      cellBO.Program->SetUniformf("cSValue", -0.001 * diag * offset);
170 -    }
171 -  }
172 -
173    vtkNew<vtkMatrix3x3> env;
174    if (program->IsUniformUsed("envMatrix"))
175    {
176