Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
CGoGN
Commits
21488e7c
Commit
21488e7c
authored
Aug 09, 2011
by
untereiner
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~cgogn/CGoGN
Conflicts: src/Utils/Shaders/shaderPhong.cpp
parents
fe862a0e
4040a77e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
63 deletions
+18
-63
include/Utils/Shaders/shaderPhong.frag
include/Utils/Shaders/shaderPhong.frag
+9
-1
src/Utils/Shaders/shaderPhong.cpp
src/Utils/Shaders/shaderPhong.cpp
+9
-62
No files found.
include/Utils/Shaders/shaderPhong.frag
View file @
21488e7c
...
...
@@ -17,8 +17,16 @@ void main()
float
lambertTerm
=
dot
(
N
,
L
);
vec4
finalColor
=
materialAmbient
;
if
(
lambertTerm
>
0
.
0
)
#ifdef DOUBLE_SIDED
if
(
lambertTerm
<
0
.
0
)
{
N
=
-
1
.
0
*
N
;
lambertTerm
=
-
1
.
0
*
lambertTerm
;
#else
if
(
lambertTerm
>
0
.
0
)
{
#endif
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
...
...
src/Utils/Shaders/shaderPhong.cpp
View file @
21488e7c
...
...
@@ -32,68 +32,9 @@ namespace Utils
{
#include "shaderPhong.vert"
#include "shaderPhong.frag"
//std::string ShaderPhong::vertexShaderText =
//"ATTRIBUTE vec3 VertexPosition, VertexNormal;\n"
//"#ifdef WITH_COLOR\n"
//"ATTRIBUTE vec3 VertexColor;\n"
//"#endif\n"
//"uniform mat4 ModelViewProjectionMatrix;\n"
//"uniform mat4 ModelViewMatrix;\n"
//"uniform mat4 NormalMatrix;\n"
//"uniform vec3 lightPosition;\n"
//"VARYING_VERT vec3 EyeVector, Normal, LightDir;\n"
//"#ifdef WITH_COLOR\n"
//"VARYING_VERT vec3 Color;\n"
//"#endif\n"
//"INVARIANT_POS;\n"
//"void main ()\n"
//"{\n"
//" Normal = vec3 (NormalMatrix * vec4 (VertexNormal, 0.0));\n"
//" vec3 Position = vec3 (ModelViewMatrix * vec4 (VertexPosition, 1.0));\n"
//" LightDir = lightPosition - Position;\n"
//" EyeVector = -Position;\n"
//" #ifdef WITH_COLOR\n"
//" Color = VertexColor;\n"
//" #endif\n"
//" gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n"
//"}";
//std::string ShaderPhong::fragmentShaderText =
//"PRECISON;\n"
//"VARYING_FRAG vec3 EyeVector, Normal, LightDir;\n"
//"#ifdef WITH_COLOR\n"
//"VARYING_FRAG vec3 Color;\n"
//"#endif\n"
//"uniform vec4 materialDiffuse;\n"
//"uniform vec4 materialSpecular;\n"
//"uniform vec4 materialAmbient;\n"
//"uniform float shininess;\n"
//"FRAG_OUT_DEF;\n"
//"void main()\n"
//"{\n"
//" vec3 N = normalize (Normal);\n"
//" vec3 L = normalize (LightDir);\n"
//" float lambertTerm = dot(N,L);\n"
//
//" vec4 finalColor = materialAmbient;\n"
//" if(lambertTerm > 0.0)\n"
//" {\n"
//" #ifndef WITH_COLOR\n"
//" finalColor += materialDiffuse * lambertTerm;\n"
//" #else\n"
//" finalColor += vec4((Color*lambertTerm),0.0) ;\n"
//" #endif\n"
//" vec3 E = normalize(EyeVector);\n"
//" vec3 R = reflect(-L, N);\n"
//" float specular = pow( max(dot(R, E), 0.0), shininess );\n"
//" finalColor += materialSpecular * specular;\n"
//" }\n"
//" gl_FragColor=finalColor;\n"
//"}";
ShaderPhong
::
ShaderPhong
()
:
ShaderPhong
::
ShaderPhong
(
bool
doubleSided
)
:
m_with_color
(
false
),
m_ambiant
(
Geom
::
Vec4f
(
0.05
f
,
0.05
f
,
0.1
f
,
0.0
f
)),
m_diffuse
(
Geom
::
Vec4f
(
0.1
f
,
1.0
f
,
0.1
f
,
0.0
f
)),
...
...
@@ -104,11 +45,19 @@ ShaderPhong::ShaderPhong():
m_vboNormal
(
NULL
),
m_vboColor
(
NULL
)
{
m_nameVS
=
"ShaderPhong_vs"
;
m_nameFS
=
"ShaderPhong_fs"
;
m_nameGS
=
"ShaderPhong_gs"
;
// get choose GL defines (2 or 3)
// ans compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
// Use double sided lighting if set
if
(
doubleSided
)
glxfrag
.
append
(
"#define DOUBLE_SIDED
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
...
...
@@ -233,14 +182,12 @@ void ShaderPhong::restoreUniformsAttribs()
getLocations
();
bind
();
sendParams
();
bindVA_VBO
(
"VertexPosition"
,
m_vboPos
);
bindVA_VBO
(
"VertexNormal"
,
m_vboNormal
);
if
(
m_vboColor
)
bindVA_VBO
(
"VertexColor"
,
m_vboColor
);
unbind
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment