Skip to content

Commit 5be3958

Browse files
author
Haydelj
committed
resolved merge conflicts in colorMap.cc an removed version.cc
2 parents 003a717 + 5deb514 commit 5be3958

File tree

14 files changed

+139
-288
lines changed

14 files changed

+139
-288
lines changed

src/Core/Application/Version.cc

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Graphics/Datatypes/GeometryImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ namespace SCIRun {
109109
POINTS,
110110
LINES,
111111
TRIANGLES,
112+
QUADS
112113
};
113114

114115
SpireIBO() : indexSize(0), prim(PRIMITIVE::POINTS) {}

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ namespace fs = spire;
7777
namespace SCIRun {
7878
namespace Render {
7979

80+
81+
static glm::vec4 inverseGammaCorrect(glm::vec4 in)
82+
{
83+
return glm::vec4(glm::pow(glm::vec3(in), glm::vec3(2.2)), in.a);
84+
}
85+
86+
static glm::vec3 inverseGammaCorrect(glm::vec3 in)
87+
{
88+
return glm::pow(in, glm::vec3(2.2));
89+
}
90+
8091
//----------------------------------------------------------------------------------------------
8192
SRInterface::SRInterface(std::shared_ptr<Gui::GLContext> context, int frameInitLimit) :
8293
mContext(context),
@@ -442,18 +453,21 @@ namespace SCIRun {
442453
GLenum primitive = GL_TRIANGLES;
443454
switch (ibo.prim)
444455
{
445-
case SpireIBO::PRIMITIVE::POINTS:
446-
primitive = GL_POINTS;
447-
break;
456+
case SpireIBO::PRIMITIVE::POINTS:
457+
primitive = GL_POINTS;
458+
break;
448459

449-
case SpireIBO::PRIMITIVE::LINES:
450-
primitive = GL_LINES;
451-
break;
460+
case SpireIBO::PRIMITIVE::LINES:
461+
primitive = GL_LINES;
462+
break;
452463

453-
case SpireIBO::PRIMITIVE::TRIANGLES:
454-
default:
455-
primitive = GL_TRIANGLES;
456-
break;
464+
case SpireIBO::PRIMITIVE::TRIANGLES:
465+
primitive = GL_TRIANGLES;
466+
break;
467+
468+
case SpireIBO::PRIMITIVE::QUADS:
469+
primitive = GL_QUADS;
470+
break;
457471
}
458472

459473
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
@@ -1036,18 +1050,21 @@ namespace SCIRun {
10361050
GLenum primitive = GL_TRIANGLES;
10371051
switch (ibo.prim)
10381052
{
1039-
case SpireIBO::PRIMITIVE::POINTS:
1040-
primitive = GL_POINTS;
1041-
break;
1053+
case SpireIBO::PRIMITIVE::POINTS:
1054+
primitive = GL_POINTS;
1055+
break;
10421056

1043-
case SpireIBO::PRIMITIVE::LINES:
1044-
primitive = GL_LINES;
1045-
break;
1057+
case SpireIBO::PRIMITIVE::LINES:
1058+
primitive = GL_LINES;
1059+
break;
10461060

1047-
case SpireIBO::PRIMITIVE::TRIANGLES:
1048-
default:
1049-
primitive = GL_TRIANGLES;
1050-
break;
1061+
case SpireIBO::PRIMITIVE::TRIANGLES:
1062+
primitive = GL_TRIANGLES;
1063+
break;
1064+
1065+
case SpireIBO::PRIMITIVE::QUADS:
1066+
primitive = GL_QUADS;
1067+
break;
10511068
}
10521069

10531070
if (mRenderSortType == RenderState::TransparencySortType::LISTS_SORT)
@@ -1781,9 +1798,9 @@ namespace SCIRun {
17811798
void SRInterface::applyMatFactors(Graphics::Datatypes::SpireSubPass::Uniform& uniform)
17821799
{
17831800
if (uniform.name == "uAmbientColor")
1784-
uniform.data = glm::vec4(mMatAmbient);
1801+
uniform.data = inverseGammaCorrect(glm::vec4(mMatAmbient));
17851802
else if (uniform.name == "uSpecularColor")
1786-
uniform.data = glm::vec4(mMatSpecular);
1803+
uniform.data = inverseGammaCorrect(glm::vec4(mMatSpecular));
17871804
else if (uniform.name == "uSpecularPower")
17881805
uniform.data = glm::vec4(mMatShine);
17891806
}
@@ -1800,7 +1817,7 @@ namespace SCIRun {
18001817
}
18011818
else if (uniform.name == "uFogColor")
18021819
{
1803-
uniform.data = mFogColor;
1820+
uniform.data = inverseGammaCorrect(mFogColor);
18041821
}
18051822

18061823
uniform.type = Graphics::Datatypes::SpireSubPass::Uniform::UniformType::UNIFORM_VEC4;
@@ -1814,7 +1831,7 @@ namespace SCIRun {
18141831
StaticWorldLight* light = mCore.getStaticComponent<StaticWorldLight>();
18151832
if (light)
18161833
{
1817-
light->lightColor[index] = glm::vec3(r, g, b);
1834+
light->lightColor[index] = inverseGammaCorrect(glm::vec3(r, g, b));
18181835
}
18191836
}
18201837

src/Interface/Modules/Render/ES/SRInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ namespace SCIRun {
381381
std::vector<glm::vec3> mLightDirectionView {};
382382
std::vector<bool> mLightsOn {};
383383

384-
glm::vec2 autoRotateVector {0.0, 0.0};
385-
float autoRotateSpeed {0.01f};
384+
glm::vec2 autoRotateVector {0.0, 0.0};
385+
float autoRotateSpeed {0.01f};
386386

387387
const int frameInitLimit_ {};
388388
std::unique_ptr<SRCamera> mCamera; // Primary camera.

src/Interface/Modules/Render/ES/shaders/Flat.vs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ varying vec4 vPosView;
4141

4242
void main( void )
4343
{
44-
// Todo: Add gamma correction factor of 2.2. For textures, we assume that it
45-
// was generated in gamma space, and we need to convert it to linear space.
4644
vPosWorld = uModel * vec4(aPos, 1.0);
4745
vPosView = uView * uModel * vPosWorld;
4846

src/Interface/Modules/Render/ES/shaders/Flat_Color.vs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ varying vec4 vColor;
4242

4343
void main( void )
4444
{
45-
// Todo: Add gamma correction factor of 2.2. For textures, we assume that it
46-
// was generated in gamma space, and we need to convert it to linear space.
4745
vPosWorld = uModel * vec4(aPos, 1.0);
4846
vPosView = uView * uModel * vPosWorld;
4947
vColor = aColor;

src/Interface/Modules/Render/ES/shaders/Flat_ColorMap.vs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ varying vec2 vTexCoords;
4242

4343
void main( void )
4444
{
45-
// Todo: Add gamma correction factor of 2.2. For textures, we assume that it
46-
// was generated in gamma space, and we need to convert it to linear space.
4745
vPosWorld = uModel * vec4(aPos, 1.0);
4846
vPosView = uView * uModel * vPosWorld;
4947
vTexCoords = aTexCoords;

src/Interface/Modules/Render/ES/shaders/Phong.fs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,86 +74,80 @@ varying vec3 vNormal;
7474
varying vec4 vPosWorld;
7575
varying vec4 vPosView;
7676

77-
vec4 calculate_lighting(vec3 N, vec3 L, vec3 V, vec3 diffuseColor, vec3 specularColor, vec3 lightColor)
77+
vec3 calculate_lighting(vec3 N, vec3 L, vec3 V, vec3 diffuseColor, vec3 specularColor, vec3 lightColor)
7878
{
7979
vec3 H = normalize(V + L);
8080
float diffuse = max(0.0, dot(N, L));
8181
float specular = max(0.0, dot(N, H));
8282
specular = pow(specular, uSpecularPower);
8383

84-
return vec4(lightColor * (diffuse * diffuseColor + specular * specularColor), 0.0);
84+
return lightColor * (diffuse * diffuseColor + specular * specularColor);
8585
}
8686

8787
void main()
8888
{
8989
if(uUseClippingPlanes)
9090
{
9191
float fPlaneValue;
92-
if (uClippingPlaneCtrl0.x > 0.5)
92+
if(uClippingPlaneCtrl0.x > 0.5)
9393
{
9494
fPlaneValue = dot(vPosWorld, uClippingPlane0);
9595
fPlaneValue = uClippingPlaneCtrl0.z > 0.5 ? -fPlaneValue : fPlaneValue;
96-
if (fPlaneValue < 0.0)
97-
discard;
96+
if(fPlaneValue < 0.0) discard;
9897
}
99-
if (uClippingPlaneCtrl1.x > 0.5)
98+
if(uClippingPlaneCtrl1.x > 0.5)
10099
{
101100
fPlaneValue = dot(vPosWorld, uClippingPlane1);
102101
fPlaneValue = uClippingPlaneCtrl1.z > 0.5 ? -fPlaneValue : fPlaneValue;
103-
if (fPlaneValue < 0.0)
104-
discard;
102+
if(fPlaneValue < 0.0) discard;
105103
}
106-
if (uClippingPlaneCtrl2.x > 0.5)
104+
if(uClippingPlaneCtrl2.x > 0.5)
107105
{
108106
fPlaneValue = dot(vPosWorld, uClippingPlane2);
109107
fPlaneValue = uClippingPlaneCtrl2.z > 0.5 ? -fPlaneValue : fPlaneValue;
110-
if (fPlaneValue < 0.0)
111-
discard;
108+
if(fPlaneValue < 0.0) discard;
112109
}
113-
if (uClippingPlaneCtrl3.x > 0.5)
110+
if(uClippingPlaneCtrl3.x > 0.5)
114111
{
115112
fPlaneValue = dot(vPosWorld, uClippingPlane3);
116113
fPlaneValue = uClippingPlaneCtrl3.z > 0.5 ? -fPlaneValue : fPlaneValue;
117-
if (fPlaneValue < 0.0)
118-
discard;
114+
if(fPlaneValue < 0.0) discard;
119115
}
120-
if (uClippingPlaneCtrl4.x > 0.5)
116+
if(uClippingPlaneCtrl4.x > 0.5)
121117
{
122118
fPlaneValue = dot(vPosWorld, uClippingPlane4);
123119
fPlaneValue = uClippingPlaneCtrl4.z > 0.5 ? -fPlaneValue : fPlaneValue;
124-
if (fPlaneValue < 0.0)
125-
discard;
120+
if(fPlaneValue < 0.0) discard;
126121
}
127-
if (uClippingPlaneCtrl5.x > 0.5)
122+
if(uClippingPlaneCtrl5.x > 0.5)
128123
{
129124
fPlaneValue = dot(vPosWorld, uClippingPlane5);
130125
fPlaneValue = uClippingPlaneCtrl5.z > 0.5 ? -fPlaneValue : fPlaneValue;
131-
if (fPlaneValue < 0.0)
132-
discard;
126+
if(fPlaneValue < 0.0) discard;
133127
}
134128
}
135129

136-
vec3 diffuseColor = uDiffuseColor.rgb;
130+
vec3 diffuseColor = pow(uDiffuseColor.rgb, vec3(2.2));
137131
vec3 specularColor = uSpecularColor.rgb;
138132
vec3 ambientColor = uAmbientColor.rgb;
139133
float transparency = uTransparency;
140134

141135
vec3 normal = normalize(vNormal);
142-
if (gl_FrontFacing) normal = -normal;
136+
if(gl_FrontFacing) normal = -normal;
143137
vec3 cameraVector = -normalize(vPosView.xyz);
144138

145139
gl_FragColor = vec4(ambientColor * diffuseColor, transparency);
146-
if (length(uLightDirectionView0) > 0.0)
147-
gl_FragColor += calculate_lighting(normal, uLightDirectionView0, cameraVector, diffuseColor, specularColor, uLightColor0);
148-
if (length(uLightDirectionView1) > 0.0)
149-
gl_FragColor += calculate_lighting(normal, uLightDirectionView1, cameraVector, diffuseColor, specularColor, uLightColor1);
150-
if (length(uLightDirectionView2) > 0.0)
151-
gl_FragColor += calculate_lighting(normal, uLightDirectionView2, cameraVector, diffuseColor, specularColor, uLightColor2);
152-
if (length(uLightDirectionView3) > 0.0)
153-
gl_FragColor += calculate_lighting(normal, uLightDirectionView3, cameraVector, diffuseColor, specularColor, uLightColor3);
140+
if(length(uLightDirectionView0) > 0.0) gl_FragColor.rgb += calculate_lighting(normal,
141+
uLightDirectionView0, cameraVector, diffuseColor, specularColor, uLightColor0);
142+
if(length(uLightDirectionView1) > 0.0) gl_FragColor.rgb += calculate_lighting(normal,
143+
uLightDirectionView1, cameraVector, diffuseColor, specularColor, uLightColor1);
144+
if(length(uLightDirectionView2) > 0.0) gl_FragColor.rgb += calculate_lighting(normal,
145+
uLightDirectionView2, cameraVector, diffuseColor, specularColor, uLightColor2);
146+
if(length(uLightDirectionView3) > 0.0) gl_FragColor.rgb += calculate_lighting(normal,
147+
uLightDirectionView3, cameraVector, diffuseColor, specularColor, uLightColor3);
154148

155149
//calculate fog
156-
if (uUseFog && uFogSettings.x > 0.0)
150+
if(uUseFog && uFogSettings.x > 0.0)
157151
{
158152
vec4 fp;
159153
fp.x = uFogSettings.x;
@@ -165,7 +159,9 @@ void main()
165159
fog_factor = (fp.z-fp.w)/(fp.z-fp.y);
166160
fog_factor = 1.0 - clamp(fog_factor, 0.0, 1.0);
167161
fog_factor = 1.0 - exp(-pow(fog_factor*2.5, 2.0));
168-
gl_FragColor.xyz = mix(clamp(gl_FragColor.xyz, 0.0, 1.0),
169-
clamp(uFogColor.xyz, 0.0, 1.0), fog_factor);
162+
gl_FragColor.rgb = mix(clamp(gl_FragColor.rgb, 0.0, 1.0),
163+
clamp(uFogColor.rgb, 0.0, 1.0), fog_factor);
170164
}
165+
166+
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0/2.2));
171167
}

src/Interface/Modules/Render/ES/shaders/Phong.vs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ varying vec4 vPosView;
4343

4444
void main( void )
4545
{
46-
// Todo: Add gamma correction factor of 2.2. For textures, we assume that it
47-
// was generated in gamma space, and we need to convert it to linear space.
4846
vPosWorld = uModel * vec4(aPos, 1.0);
49-
vPosView = uView * vPosWorld;
50-
vNormal = normalize((uView * vec4(aNormal, 0.0)).xyz);
51-
47+
vPosView = uView * uModel * vPosWorld;
48+
vNormal = normalize((uView * uModel * vec4(aNormal, 0.0)).xyz);
49+
5250
gl_Position = uModelViewProjection * vec4(aPos, 1.0);
5351
}

0 commit comments

Comments
 (0)