diff --git a/Apps/Tuto/tp_master.cpp b/Apps/Tuto/tp_master.cpp index 6361650a1905c4413db34925cabd3ecb7eec504a..5312b546d7951877a394cb193fd1fa4ca0e5f31e 100644 --- a/Apps/Tuto/tp_master.cpp +++ b/Apps/Tuto/tp_master.cpp @@ -522,7 +522,7 @@ void MyQT::cb_keyPress(int keycode) if (!d_vertices.empty()) { std::stringstream ss; - ss << "Sommet: dart: " << d_vertices[0].index << ": " << position[d_vertices[0]]; + ss << "Sommet: dart: " << d_vertices[0].index << ": " << position[d_vertices[0]]<< "( id emb:"<< myMap.getEmbedding(VERTEX,d_vertices[0])<<")"<< std::endl; ; statusMsg(ss.str().c_str()); updateGL(); diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index cd733e6655454d6940d7dd224e6fa6373b9e488e..a26842d44dc9df414d7bd2cc4494431469f7f999 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -20,6 +20,7 @@ IF(WIN32) add_subdirectory(gzstream/Build) add_subdirectory(Numerical) add_subdirectory(Assimp/code) + add_subdirectory(Tools) # if(CMAKE_CONFIGURATION_TYPES) # set(CMAKE_CONFIGURATION_TYPES Release) # set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Use only Release configuration for ThirdParty" FORCE) @@ -34,5 +35,6 @@ ELSE(WIN32) add_subdirectory(AntTweakBar) add_subdirectory(Numerical) add_subdirectory(Assimp) + add_subdirectory(Tools) ENDIF(WIN32) diff --git a/ThirdParty/Tools/CMakeLists.txt b/ThirdParty/Tools/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..28c61a423dee31b471a527bfb06717d2265fba4c --- /dev/null +++ b/ThirdParty/Tools/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 2.6) + +project(Tools) + +SET (CMAKE_BUILD_TYPE Release) + +SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/ThirdParty/Tools) + +add_executable( shader_to_h shader_to_h.cpp ) +target_link_libraries( shader_to_h ) + diff --git a/ThirdParty/Tools/shader_to_h.cpp b/ThirdParty/Tools/shader_to_h.cpp new file mode 100644 index 0000000000000000000000000000000000000000..89fef7ad1b6239d06576be341d313953ecf2691a --- /dev/null +++ b/ThirdParty/Tools/shader_to_h.cpp @@ -0,0 +1,93 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + char buffer[512]; + for (int i=1; i< argc; ++i) + { + std::string filename(argv[i]); + + std::ifstream fs(filename.c_str(), std::ios::in); + if (!fs.good()) + { + std::cerr << "Unable to open file " << filename << std::endl; + return 1; + } + + size_t last_slash = filename.rfind('/'); + if (last_slash == std::string::npos) + { + last_slash = filename.rfind('\\'); + if (last_slash == std::string::npos) + last_slash = 0; + else + ++last_slash; + } + else + ++last_slash; + + std::string outName = filename.substr(last_slash,filename.size()-last_slash); + + std::stringstream ssi; + std::stringstream sso; + + std::ifstream fsi(outName.c_str(),std::ios::in); + if (fsi.good()) + { + while (!fsi.eof()) + { + fsi.getline(buffer,512); + if (!fsi.eof()) + ssi << buffer << std::endl ; + } + fsi.close(); + } + + + // fist line + fs.getline(buffer,512); + char *sub=buffer; + while ((*sub=='/') || (*sub==' ')) + ++sub; + sso << "std::string "< 0.0) + ColorFS += diffuse * lambertTerm; + int i; + for(i=0; i< NBVERTS_IN; i++) + { + vec4 pos = explode * POSITION_IN(i) + (1.0-explode)* vec4(center,1.0); + gl_Position = ModelViewProjectionMatrix * pos; + EmitVertex(); + } + EndPrimitive(); +} diff --git a/include/Utils/Shaders/shaderFlat.vert b/include/Utils/Shaders/shaderFlat.vert new file mode 100644 index 0000000000000000000000000000000000000000..96e60462a81e6b1e5d5a130814d6fcd7474fd024 --- /dev/null +++ b/include/Utils/Shaders/shaderFlat.vert @@ -0,0 +1,6 @@ +// ShaderFlat::vertexShaderText +ATTRIBUTE vec3 VertexPosition; +void main() +{ + gl_Position = vec4(VertexPosition, 1.0); +} diff --git a/include/Utils/Shaders/shaderPhong.frag b/include/Utils/Shaders/shaderPhong.frag new file mode 100644 index 0000000000000000000000000000000000000000..ac5883b922b6e3c119a8dd3ea9ce0d5627be48ef --- /dev/null +++ b/include/Utils/Shaders/shaderPhong.frag @@ -0,0 +1,33 @@ +//ShaderPhong::fragmentShaderText + +PRECISON; +VARYING_FRAG vec3 EyeVector, Normal, LightDir; +#ifdef WITH_COLOR +VARYING_FRAG vec3 Color; +#endif +uniform vec4 materialDiffuse; +uniform vec4 materialSpecular; +uniform vec4 materialAmbient; +uniform float shininess; +FRAG_OUT_DEF; +void main() +{ + vec3 N = normalize (Normal); + vec3 L = normalize (LightDir); + float lambertTerm = dot(N,L); + + vec4 finalColor = materialAmbient; + if(lambertTerm > 0.0) + { + #ifndef WITH_COLOR + finalColor += materialDiffuse * lambertTerm; + #else + finalColor += vec4((Color*lambertTerm),0.0) ; + #endif + vec3 E = normalize(EyeVector); + vec3 R = reflect(-L, N); + float specular = pow( max(dot(R, E), 0.0), shininess ); + finalColor += materialSpecular * specular; + } + gl_FragColor=finalColor; +} diff --git a/include/Utils/Shaders/shaderPhong.vert b/include/Utils/Shaders/shaderPhong.vert new file mode 100644 index 0000000000000000000000000000000000000000..3272c6f03f9b91f244032e390f466e58bd7d6228 --- /dev/null +++ b/include/Utils/Shaders/shaderPhong.vert @@ -0,0 +1,26 @@ +//ShaderPhong::vertexShaderText + +ATTRIBUTE vec3 VertexPosition, VertexNormal; +#ifdef WITH_COLOR +ATTRIBUTE vec3 VertexColor; +#endif +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 ModelViewMatrix; +uniform mat4 NormalMatrix; +uniform vec3 lightPosition; +VARYING_VERT vec3 EyeVector, Normal, LightDir; +#ifdef WITH_COLOR +VARYING_VERT vec3 Color; +#endif +INVARIANT_POS; +void main () +{ + Normal = vec3 (NormalMatrix * vec4 (VertexNormal, 0.0)); + vec3 Position = vec3 (ModelViewMatrix * vec4 (VertexPosition, 1.0)); + LightDir = lightPosition - Position; + EyeVector = -Position; + #ifdef WITH_COLOR + Color = VertexColor; + #endif + gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); +} diff --git a/include/Utils/Shaders/shaderSimpleColor.frag b/include/Utils/Shaders/shaderSimpleColor.frag new file mode 100644 index 0000000000000000000000000000000000000000..394442dcaf327b942b3c84bd73b34a6b045ffd97 --- /dev/null +++ b/include/Utils/Shaders/shaderSimpleColor.frag @@ -0,0 +1,9 @@ +// ShaderSimpleColor::fragmentShaderText + +PRECISON; +uniform vec4 color; +FRAG_OUT_DEF; +void main() +{ + gl_FragColor=color; +} diff --git a/include/Utils/Shaders/shaderSimpleColor.vert b/include/Utils/Shaders/shaderSimpleColor.vert new file mode 100644 index 0000000000000000000000000000000000000000..9fc30390e9b37fd57e8a253cc3e7e1bb630f2123 --- /dev/null +++ b/include/Utils/Shaders/shaderSimpleColor.vert @@ -0,0 +1,9 @@ +// ShaderSimpleColor::vertexShaderText + +ATTRIBUTE vec3 VertexPosition, VertexNormal; +uniform mat4 ModelViewProjectionMatrix; + +void main () +{ + gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); +} diff --git a/include/Utils/Shaders/shaderSimpleTexture.frag b/include/Utils/Shaders/shaderSimpleTexture.frag new file mode 100644 index 0000000000000000000000000000000000000000..cd86a8f71b38262744673da584c93aa7aeda5745 --- /dev/null +++ b/include/Utils/Shaders/shaderSimpleTexture.frag @@ -0,0 +1,10 @@ +// ShaderSimpleTexture::fragmentShaderText + +PRECISON; +VARYING_FRAG vec2 texCoord; +uniform sampler2D textureUnit; +FRAG_OUT_DEF; +void main() +{ + gl_FragColor=texture2D(textureUnit,texCoord); +} \ No newline at end of file diff --git a/include/Utils/Shaders/shaderSimpleTexture.vert b/include/Utils/Shaders/shaderSimpleTexture.vert new file mode 100644 index 0000000000000000000000000000000000000000..88a0eaf5f1aa33d7540321fe4f49c852615893f1 --- /dev/null +++ b/include/Utils/Shaders/shaderSimpleTexture.vert @@ -0,0 +1,13 @@ +// ShaderSimpleTexture::vertexShaderText + +ATTRIBUTE vec3 VertexPosition; +ATTRIBUTE vec2 VertexTexCoord; +uniform mat4 ModelViewProjectionMatrix; +VARYING_VERT vec2 texCoord; +INVARIANT_POS; +void main () +{ + gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); + texCoord = VertexTexCoord; +} + diff --git a/include/Utils/Shaders/shaderTextureMask.frag b/include/Utils/Shaders/shaderTextureMask.frag new file mode 100644 index 0000000000000000000000000000000000000000..c3786cf5c52f38f50b2e4b0513b46f0d3bf64ad5 --- /dev/null +++ b/include/Utils/Shaders/shaderTextureMask.frag @@ -0,0 +1,14 @@ +// ShaderTextureMask::fragmentShaderText + +PRECISON; +VARYING_FRAG vec2 texCoord; +uniform sampler2D textureUnit; +uniform sampler2D textureUnitMask; +FRAG_OUT_DEF; +void main() +{ + float m = texture2D(textureUnitMask,texCoord).r; + if (m < 0.5) + discard; + gl_FragColor=texture2D(textureUnit,texCoord)*m; +} diff --git a/include/Utils/Shaders/shaderTextureMask.vert b/include/Utils/Shaders/shaderTextureMask.vert new file mode 100644 index 0000000000000000000000000000000000000000..090b3668219c7dfb1bdf5a23375478489358668c --- /dev/null +++ b/include/Utils/Shaders/shaderTextureMask.vert @@ -0,0 +1,12 @@ +// ShaderTextureMask::vertexShaderText + +ATTRIBUTE vec3 VertexPosition; +ATTRIBUTE vec2 VertexTexCoord; +uniform mat4 ModelViewProjectionMatrix; +VARYING_VERT vec2 texCoord; +INVARIANT_POS; +void main () +{ + gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); + texCoord = VertexTexCoord; +} \ No newline at end of file diff --git a/include/Utils/Shaders/shaderVectorPerVertex.frag b/include/Utils/Shaders/shaderVectorPerVertex.frag new file mode 100644 index 0000000000000000000000000000000000000000..aec2b6739385ed515827406433fcc3a826ca3404 --- /dev/null +++ b/include/Utils/Shaders/shaderVectorPerVertex.frag @@ -0,0 +1,9 @@ +// ShaderVectorPerVertex::fragmentShaderText + +PRECISON; +uniform vec4 vectorColor; +FRAG_OUT_DEF; +void main() +{ + gl_FragColor = vectorColor; +} diff --git a/include/Utils/Shaders/shaderVectorPerVertex.geom b/include/Utils/Shaders/shaderVectorPerVertex.geom new file mode 100644 index 0000000000000000000000000000000000000000..8f48c93d16f2d5baf75c2e837a2eb763a06144af --- /dev/null +++ b/include/Utils/Shaders/shaderVectorPerVertex.geom @@ -0,0 +1,13 @@ +// ShaderVectorPerVertex::geometryShaderText + +uniform float vectorScale; +uniform mat4 ModelViewProjectionMatrix; +VARYING_IN vec3 VectorAttrib[]; +void main() +{ + gl_Position = ModelViewProjectionMatrix * POSITION_IN(0); + EmitVertex(); + gl_Position = ModelViewProjectionMatrix * (POSITION_IN(0) + vec4(VectorAttrib[0] * vectorScale, 0.0)); + EmitVertex(); + EndPrimitive(); +} diff --git a/include/Utils/Shaders/shaderVectorPerVertex.vert b/include/Utils/Shaders/shaderVectorPerVertex.vert new file mode 100644 index 0000000000000000000000000000000000000000..c30a9c1b159aa329690af73359f94d8486db8131 --- /dev/null +++ b/include/Utils/Shaders/shaderVectorPerVertex.vert @@ -0,0 +1,11 @@ +// ShaderVectorPerVertex::vertexShaderText + +ATTRIBUTE vec3 VertexPosition; +ATTRIBUTE vec3 VertexVector; +VARYING_VERT vec3 VectorAttrib; +INVARIANT_POS; +void main () +{ + VectorAttrib = VertexVector; + gl_Position = vec4(VertexPosition, 1.0); +} diff --git a/include/Utils/pointSprite.frag b/include/Utils/pointSprite.frag new file mode 100644 index 0000000000000000000000000000000000000000..3fb54e2776633a21bd8e0bc3a8018d60a91029bc --- /dev/null +++ b/include/Utils/pointSprite.frag @@ -0,0 +1,18 @@ +// PointSprite::fragmentShaderText +uniform sampler2D SpriteTexture; +uniform float size; +uniform vec3 color; +VARYING_FRAG vec2 texCoord; +VARYING_FRAG vec2 positionFragIn; +VARYING_FRAG vec4 mvpFragIn; +void main(void) +{ + float lum = texture2D(SpriteTexture, texCoord).s; + if (lum==0.0) + discard; + vec2 v = texCoord-vec2(0.5,0.5); + float z = size * sqrt(1.0-dot(v,v)); + vec2 zfrag = positionFragIn + vec2(z,0.0); + gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw); + gl_FragColor = vec4(color,0.0)*lum; +} \ No newline at end of file diff --git a/include/Utils/pointSprite.geom b/include/Utils/pointSprite.geom new file mode 100644 index 0000000000000000000000000000000000000000..7bb849d9f592b9d8a23f96304796f14c938329d1 --- /dev/null +++ b/include/Utils/pointSprite.geom @@ -0,0 +1,34 @@ +// PointSprite::geometryShaderText + +uniform float size; +uniform mat4 ModelViewMatrix; +uniform mat4 ProjectionMatrix; +VARYING_OUT vec2 texCoord; +VARYING_OUT vec2 positionFragIn; +VARYING_OUT vec4 mvpFragIn; +void main() +{ + vec4 posCenter = ModelViewMatrix * POSITION_IN(0); + vec4 pos = posCenter + vec4(-size, size, 0.0, 0.0); + positionFragIn = posCenter.zw; + mvpFragIn.x = ProjectionMatrix[2][2]; + mvpFragIn.y = ProjectionMatrix[3][2]; + mvpFragIn.z = ProjectionMatrix[2][3]; + mvpFragIn.w = ProjectionMatrix[3][3]; + texCoord = vec2(0.0,1.0); + gl_Position = ProjectionMatrix * pos; + EmitVertex(); + pos = posCenter + vec4(-size, -size, 0.0, 0.0); + texCoord = vec2(0.0,0.0); + gl_Position = ProjectionMatrix * pos; + EmitVertex(); + pos = posCenter + vec4( size, size, 0.0, 0.0); + texCoord = vec2(1.0,1.0); + gl_Position = ProjectionMatrix * pos; + EmitVertex(); + pos = posCenter + vec4( size,-size, 0.0, 0.0); + texCoord = vec2(1.0,0.0); + gl_Position = ProjectionMatrix * pos; + EmitVertex(); + EndPrimitive(); +} diff --git a/include/Utils/pointSprite.vert b/include/Utils/pointSprite.vert new file mode 100644 index 0000000000000000000000000000000000000000..2e3eff771df1bd4f1c68920e3a533e89b2ea2ba5 --- /dev/null +++ b/include/Utils/pointSprite.vert @@ -0,0 +1,6 @@ +// PointSprite::vertexShaderText +ATTRIBUTE vec3 VertexPosition; +void main () +{ + gl_Position = vec4(VertexPosition,1.0); +} diff --git a/include/Utils/text3d.frag b/include/Utils/text3d.frag new file mode 100644 index 0000000000000000000000000000000000000000..658a2ae763732b657aec70e639702fd3976ce9cc --- /dev/null +++ b/include/Utils/text3d.frag @@ -0,0 +1,10 @@ +//Strings3D::fragmentShaderText1 + +VARYING_FRAG vec2 tex_coord; +uniform sampler2D FontTexture; +uniform vec3 color; +FRAG_OUT_DEF; +void main (void) +{ + float lum = texture2D(FontTexture, tex_coord).s;; +// no "}" because it is added in the shader class code (with other things) diff --git a/include/Utils/text3d.vert b/include/Utils/text3d.vert new file mode 100644 index 0000000000000000000000000000000000000000..4cf09b459ba359b5f34826602223d708253d0e02 --- /dev/null +++ b/include/Utils/text3d.vert @@ -0,0 +1,16 @@ +//Strings3D::vertexShaderText + +ATTRIBUTE vec4 VertexPosition; +uniform mat4 ModelViewMatrix; +uniform mat4 ProjectionMatrix; +uniform vec3 strPos; +uniform float scale; +VARYING_VERT vec2 tex_coord; +INVARIANT_POS; +void main () +{ + vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0); + tex_coord = vec2(VertexPosition[2],VertexPosition[3]); + gl_Position = ProjectionMatrix * pos; +} + diff --git a/src/Utils/Shaders/shaderColorPerVertex.cpp b/src/Utils/Shaders/shaderColorPerVertex.cpp index 3c4721bcb588465cf3a3a849db6a34abcaf9d618..e714dc7b8d076f4439902e7c74e66fb77c4b4a3f 100644 --- a/src/Utils/Shaders/shaderColorPerVertex.cpp +++ b/src/Utils/Shaders/shaderColorPerVertex.cpp @@ -32,27 +32,30 @@ namespace CGoGN namespace Utils { -std::string ShaderColorPerVertex::vertexShaderText = - "ATTRIBUTE vec3 VertexPosition;\n" - "ATTRIBUTE vec3 VertexColor;\n" - "uniform mat4 ModelViewProjectionMatrix;\n" - "VARYING_VERT vec3 color;\n" - "INVARIANT_POS;\n" - "void main ()\n" - "{\n" - " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" - " color = VertexColor;\n" - "}"; - - -std::string ShaderColorPerVertex::fragmentShaderText = - "PRECISON;\n" - "VARYING_FRAG vec3 color;\n" - "FRAG_OUT_DEF;\n" - "void main()\n" - "{\n" - " gl_FragColor=vec4(color,0.0);\n" - "}"; +#include "shaderColorPerVertex.vert" +#include "shaderColorPerVertex.frag" + +//std::string ShaderColorPerVertex::vertexShaderText = +// "ATTRIBUTE vec3 VertexPosition;\n" +// "ATTRIBUTE vec3 VertexColor;\n" +// "uniform mat4 ModelViewProjectionMatrix;\n" +// "VARYING_VERT vec3 color;\n" +// "INVARIANT_POS;\n" +// "void main ()\n" +// "{\n" +// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" +// " color = VertexColor;\n" +// "}"; +// +// +//std::string ShaderColorPerVertex::fragmentShaderText = +// "PRECISON;\n" +// "VARYING_FRAG vec3 color;\n" +// "FRAG_OUT_DEF;\n" +// "void main()\n" +// "{\n" +// " gl_FragColor=vec4(color,0.0);\n" +// "}"; ShaderColorPerVertex::ShaderColorPerVertex() diff --git a/src/Utils/Shaders/shaderFlat.cpp b/src/Utils/Shaders/shaderFlat.cpp index 5bf01bdeb2166606128de1a38ecaa14fb20bac37..c5597c92e0473597d7e7f58cf7ccdf9d685ba47d 100644 --- a/src/Utils/Shaders/shaderFlat.cpp +++ b/src/Utils/Shaders/shaderFlat.cpp @@ -31,54 +31,57 @@ namespace CGoGN namespace Utils { - -std::string ShaderFlat::vertexShaderText = -"ATTRIBUTE vec3 VertexPosition;\n" -"void main()\n" -"{\n" -" gl_Position = vec4(VertexPosition, 1.0);\n" -"}"; - - -std::string ShaderFlat::geometryShaderText = -"uniform float explode;\n" -"uniform mat4 ModelViewProjectionMatrix;\n" -"uniform mat4 NormalMatrix;\n" -"uniform mat4 ModelViewMatrix;\n" -"uniform vec3 lightPosition;\n" -"uniform vec4 diffuse;\n" -"uniform vec4 ambient;\n" -"VARYING_OUT vec4 ColorFS;\n" -"void main(void)\n" -"{\n" -" vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;\n" -" vec3 v2 = POSITION_IN(2).xyz - POSITION_IN(0).xyz;\n" -" vec3 N = cross(v1,v2);\n" -" N = normalize (vec3(NormalMatrix*vec4(N,0.0))); \n" -" vec3 center = POSITION_IN(0).xyz + POSITION_IN(1).xyz + POSITION_IN(2).xyz; \n" -" center /= 3.0;\n" -" vec4 newPos = ModelViewMatrix * vec4(center,0.0);\n" -" vec3 L = normalize (lightPosition - newPos.xyz);\n" -" float lambertTerm = dot(N,L);\n" -" ColorFS = ambient;\n" -" if(lambertTerm > 0.0)\n" -" ColorFS += diffuse * lambertTerm;\n" -" int i;\n" -" for(i=0; i< NBVERTS_IN; i++)\n" -" {\n" -" vec4 pos = explode * POSITION_IN(i) + (1.0-explode)* vec4(center,1.0);\n" -" gl_Position = ModelViewProjectionMatrix * pos;\n" -" EmitVertex();\n" -" }\n" -" EndPrimitive();\n" -"}"; - -std::string ShaderFlat::fragmentShaderText = -"VARYING_FRAG vec4 ColorFS; \n" -"void main()\n" -"{\n" -" gl_FragColor = ColorFS;\n" -"}"; +#include "shaderFlat.vert" +#include "shaderFlat.frag" +#include "shaderFlat.geom" + +//std::string ShaderFlat::vertexShaderText = +//"ATTRIBUTE vec3 VertexPosition;\n" +//"void main()\n" +//"{\n" +//" gl_Position = vec4(VertexPosition, 1.0);\n" +//"}"; + + +//std::string ShaderFlat::geometryShaderText = +//"uniform float explode;\n" +//"uniform mat4 ModelViewProjectionMatrix;\n" +//"uniform mat4 NormalMatrix;\n" +//"uniform mat4 ModelViewMatrix;\n" +//"uniform vec3 lightPosition;\n" +//"uniform vec4 diffuse;\n" +//"uniform vec4 ambient;\n" +//"VARYING_OUT vec4 ColorFS;\n" +//"void main(void)\n" +//"{\n" +//" vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;\n" +//" vec3 v2 = POSITION_IN(2).xyz - POSITION_IN(0).xyz;\n" +//" vec3 N = cross(v1,v2);\n" +//" N = normalize (vec3(NormalMatrix*vec4(N,0.0))); \n" +//" vec3 center = POSITION_IN(0).xyz + POSITION_IN(1).xyz + POSITION_IN(2).xyz; \n" +//" center /= 3.0;\n" +//" vec4 newPos = ModelViewMatrix * vec4(center,0.0);\n" +//" vec3 L = normalize (lightPosition - newPos.xyz);\n" +//" float lambertTerm = dot(N,L);\n" +//" ColorFS = ambient;\n" +//" if(lambertTerm > 0.0)\n" +//" ColorFS += diffuse * lambertTerm;\n" +//" int i;\n" +//" for(i=0; i< NBVERTS_IN; i++)\n" +//" {\n" +//" vec4 pos = explode * POSITION_IN(i) + (1.0-explode)* vec4(center,1.0);\n" +//" gl_Position = ModelViewProjectionMatrix * pos;\n" +//" EmitVertex();\n" +//" }\n" +//" EndPrimitive();\n" +//"}"; + +//std::string ShaderFlat::fragmentShaderText = +//"VARYING_FRAG vec4 ColorFS; \n" +//"void main()\n" +//"{\n" +//" gl_FragColor = ColorFS;\n" +//"}"; ShaderFlat::ShaderFlat() diff --git a/src/Utils/Shaders/shaderPhong.cpp b/src/Utils/Shaders/shaderPhong.cpp index 090e106842e761c7c3af12eee9e4d5ec2a8f2186..96e0d15b77c1d5e7ce1dd5c203843213c4f5c1d4 100644 --- a/src/Utils/Shaders/shaderPhong.cpp +++ b/src/Utils/Shaders/shaderPhong.cpp @@ -30,66 +30,67 @@ namespace CGoGN 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::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" -"}"; +//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(): diff --git a/src/Utils/Shaders/shaderSimpleColor.cpp b/src/Utils/Shaders/shaderSimpleColor.cpp index c0bb3e50d0ae09d4b378ee4cccf82315a1cbce27..e187c3532b7ed469a360de03190a3ad4c0a9a069 100644 --- a/src/Utils/Shaders/shaderSimpleColor.cpp +++ b/src/Utils/Shaders/shaderSimpleColor.cpp @@ -30,25 +30,27 @@ namespace CGoGN namespace Utils { - -std::string ShaderSimpleColor::vertexShaderText = - "ATTRIBUTE vec3 VertexPosition, VertexNormal;\n" - "uniform mat4 ModelViewProjectionMatrix;\n" -// "INVARIANT_POS;\n" - "void main ()\n" - "{\n" - " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" - "}"; - - -std::string ShaderSimpleColor::fragmentShaderText = - "PRECISON;\n" - "uniform vec4 color;\n" - "FRAG_OUT_DEF;\n" - "void main()\n" - "{\n" - " gl_FragColor=color;\n" - "}"; +#include "shaderSimpleColor.vert" +#include "shaderSimpleColor.frag" + +//std::string ShaderSimpleColor::vertexShaderText = +// "ATTRIBUTE vec3 VertexPosition, VertexNormal;\n" +// "uniform mat4 ModelViewProjectionMatrix;\n" +//// "INVARIANT_POS;\n" +// "void main ()\n" +// "{\n" +// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" +// "}"; +// +// +//std::string ShaderSimpleColor::fragmentShaderText = +// "PRECISON;\n" +// "uniform vec4 color;\n" +// "FRAG_OUT_DEF;\n" +// "void main()\n" +// "{\n" +// " gl_FragColor=color;\n" +// "}"; ShaderSimpleColor::ShaderSimpleColor() diff --git a/src/Utils/Shaders/shaderSimpleTexture.cpp b/src/Utils/Shaders/shaderSimpleTexture.cpp index adccffcc645e2e91a0aae6ae73f9cf5c1bdd3db9..bf7895eb7ffaf484d4302dc84756c8fc79b6fd58 100644 --- a/src/Utils/Shaders/shaderSimpleTexture.cpp +++ b/src/Utils/Shaders/shaderSimpleTexture.cpp @@ -31,29 +31,31 @@ namespace CGoGN namespace Utils { - -std::string ShaderSimpleTexture::vertexShaderText = - "ATTRIBUTE vec3 VertexPosition;\n" - "ATTRIBUTE vec2 VertexTexCoord;\n" - "uniform mat4 ModelViewProjectionMatrix;\n" - "VARYING_VERT vec2 texCoord;\n" - "INVARIANT_POS;\n" - "void main ()\n" - "{\n" - " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" - " texCoord = VertexTexCoord;\n" - "}"; - - -std::string ShaderSimpleTexture::fragmentShaderText = - "PRECISON;\n" - "VARYING_FRAG vec2 texCoord;\n" - "uniform sampler2D textureUnit;\n" - "FRAG_OUT_DEF;\n" - "void main()\n" - "{\n" - " gl_FragColor=texture2D(textureUnit,texCoord);\n" - "}"; +#include "shaderSimpleTexture.vert" +#include "shaderSimpleTexture.frag" + +//std::string ShaderSimpleTexture::vertexShaderText = +// "ATTRIBUTE vec3 VertexPosition;\n" +// "ATTRIBUTE vec2 VertexTexCoord;\n" +// "uniform mat4 ModelViewProjectionMatrix;\n" +// "VARYING_VERT vec2 texCoord;\n" +// "INVARIANT_POS;\n" +// "void main ()\n" +// "{\n" +// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" +// " texCoord = VertexTexCoord;\n" +// "}"; +// +// +//std::string ShaderSimpleTexture::fragmentShaderText = +// "PRECISON;\n" +// "VARYING_FRAG vec2 texCoord;\n" +// "uniform sampler2D textureUnit;\n" +// "FRAG_OUT_DEF;\n" +// "void main()\n" +// "{\n" +// " gl_FragColor=texture2D(textureUnit,texCoord);\n" +// "}"; ShaderSimpleTexture::ShaderSimpleTexture() diff --git a/src/Utils/Shaders/shaderTextureMask.cpp b/src/Utils/Shaders/shaderTextureMask.cpp index dc272dc391ebb64b108ec595b13001d1de00b077..dadc0a8f40f2445fa6be2e9edcb93c62e23e9bbb 100644 --- a/src/Utils/Shaders/shaderTextureMask.cpp +++ b/src/Utils/Shaders/shaderTextureMask.cpp @@ -32,32 +32,35 @@ namespace CGoGN namespace Utils { -std::string ShaderTextureMask::vertexShaderText = - "ATTRIBUTE vec3 VertexPosition;\n" - "ATTRIBUTE vec2 VertexTexCoord;\n" - "uniform mat4 ModelViewProjectionMatrix;\n" - "VARYING_VERT vec2 texCoord;\n" - "INVARIANT_POS;\n" - "void main ()\n" - "{\n" - " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" - " texCoord = VertexTexCoord;\n" - "}"; - - -std::string ShaderTextureMask::fragmentShaderText = - "PRECISON;\n" - "VARYING_FRAG vec2 texCoord;\n" - "uniform sampler2D textureUnit;\n" - "uniform sampler2D textureUnitMask;\n" - "FRAG_OUT_DEF;\n" - "void main()\n" - "{\n" - " float m = texture2D(textureUnitMask,texCoord).r;\n" - " if (m < 0.5)" - " discard;" - " gl_FragColor=texture2D(textureUnit,texCoord)*m;\n" - "}"; +#include "shaderTextureMask.vert" +#include "shaderTextureMask.frag" + +//std::string ShaderTextureMask::vertexShaderText = +// "ATTRIBUTE vec3 VertexPosition;\n" +// "ATTRIBUTE vec2 VertexTexCoord;\n" +// "uniform mat4 ModelViewProjectionMatrix;\n" +// "VARYING_VERT vec2 texCoord;\n" +// "INVARIANT_POS;\n" +// "void main ()\n" +// "{\n" +// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" +// " texCoord = VertexTexCoord;\n" +// "}"; +// +// +//std::string ShaderTextureMask::fragmentShaderText = +// "PRECISON;\n" +// "VARYING_FRAG vec2 texCoord;\n" +// "uniform sampler2D textureUnit;\n" +// "uniform sampler2D textureUnitMask;\n" +// "FRAG_OUT_DEF;\n" +// "void main()\n" +// "{\n" +// " float m = texture2D(textureUnitMask,texCoord).r;\n" +// " if (m < 0.5)" +// " discard;" +// " gl_FragColor=texture2D(textureUnit,texCoord)*m;\n" +// "}"; ShaderTextureMask::ShaderTextureMask() diff --git a/src/Utils/Shaders/shaderVectorPerVertex.cpp b/src/Utils/Shaders/shaderVectorPerVertex.cpp index fba2c5bc67d215961282994dabd02ad81360f0c1..83e45989390a7194a03c41bc989111b579e1471d 100644 --- a/src/Utils/Shaders/shaderVectorPerVertex.cpp +++ b/src/Utils/Shaders/shaderVectorPerVertex.cpp @@ -30,41 +30,44 @@ namespace CGoGN namespace Utils { - -std::string ShaderVectorPerVertex::vertexShaderText = - "ATTRIBUTE vec3 VertexPosition;\n" - "ATTRIBUTE vec3 VertexVector;\n" - "VARYING_VERT vec3 VectorAttrib;\n" - "INVARIANT_POS;\n" - "void main ()\n" - "{\n" - " VectorAttrib = VertexVector;\n" - " gl_Position = vec4(VertexPosition, 1.0);\n" - "}"; - - -std::string ShaderVectorPerVertex::geometryShaderText = - "uniform float vectorScale;\n" - "uniform mat4 ModelViewProjectionMatrix;\n" - "VARYING_IN vec3 VectorAttrib[];\n" - "void main()\n" - "{\n" - " gl_Position = ModelViewProjectionMatrix * POSITION_IN(0);\n" - " EmitVertex();\n" - " gl_Position = ModelViewProjectionMatrix * (POSITION_IN(0) + vec4(VectorAttrib[0] * vectorScale, 0.0));\n" - " EmitVertex();\n" - " EndPrimitive();\n" - "}"; - - -std::string ShaderVectorPerVertex::fragmentShaderText = - "PRECISON;\n" - "uniform vec4 vectorColor;\n" - "FRAG_OUT_DEF;\n" - "void main()\n" - "{\n" - " gl_FragColor = vectorColor;\n" - "}"; +#include "shaderVectorPerVertex.vert" +#include "shaderVectorPerVertex.geom" +#include "shaderVectorPerVertex.frag" + +//std::string ShaderVectorPerVertex::vertexShaderText = +// "ATTRIBUTE vec3 VertexPosition;\n" +// "ATTRIBUTE vec3 VertexVector;\n" +// "VARYING_VERT vec3 VectorAttrib;\n" +// "INVARIANT_POS;\n" +// "void main ()\n" +// "{\n" +// " VectorAttrib = VertexVector;\n" +// " gl_Position = vec4(VertexPosition, 1.0);\n" +// "}"; +// +// +//std::string ShaderVectorPerVertex::geometryShaderText = +// "uniform float vectorScale;\n" +// "uniform mat4 ModelViewProjectionMatrix;\n" +// "VARYING_IN vec3 VectorAttrib[];\n" +// "void main()\n" +// "{\n" +// " gl_Position = ModelViewProjectionMatrix * POSITION_IN(0);\n" +// " EmitVertex();\n" +// " gl_Position = ModelViewProjectionMatrix * (POSITION_IN(0) + vec4(VectorAttrib[0] * vectorScale, 0.0));\n" +// " EmitVertex();\n" +// " EndPrimitive();\n" +// "}"; +// +// +//std::string ShaderVectorPerVertex::fragmentShaderText = +// "PRECISON;\n" +// "uniform vec4 vectorColor;\n" +// "FRAG_OUT_DEF;\n" +// "void main()\n" +// "{\n" +// " gl_FragColor = vectorColor;\n" +// "}"; ShaderVectorPerVertex::ShaderVectorPerVertex() : diff --git a/src/Utils/pointSprite.cpp b/src/Utils/pointSprite.cpp index 6e821acdb0d264a26ef7b2b2faec364a3bd58d03..c7501c3b957a34e5f657f3e47d93ea2a062d352b 100644 --- a/src/Utils/pointSprite.cpp +++ b/src/Utils/pointSprite.cpp @@ -30,72 +30,77 @@ namespace CGoGN namespace Utils { +#include "pointSprite.vert" +#include "pointSprite.frag" +#include "pointSprite.geom" + GLuint PointSprite::m_idTexture = 0; GLuint PointSprite::m_uniform_texture = 0; unsigned char* PointSprite::m_ptrSphere = NULL; -std::string PointSprite::vertexShaderText = -"ATTRIBUTE vec3 VertexPosition;\n" -"void main ()\n" -"{\n" -" gl_Position = vec4(VertexPosition,1.0);\n" -"}"; - - -std::string PointSprite::geometryShaderText = -"uniform float size;\n" -"uniform mat4 ModelViewMatrix;\n" -"uniform mat4 ProjectionMatrix;\n" -"VARYING_OUT vec2 texCoord;\n" -"VARYING_OUT vec2 positionFragIn;\n" -"VARYING_OUT vec4 mvpFragIn;\n" -"void main()\n" -"{\n" -" vec4 posCenter = ModelViewMatrix * POSITION_IN(0);\n" -" vec4 pos = posCenter + vec4(-size, size, 0.0, 0.0);\n" -" positionFragIn = posCenter.zw;\n" -" mvpFragIn.x = ProjectionMatrix[2][2];\n" -" mvpFragIn.y = ProjectionMatrix[3][2];\n" -" mvpFragIn.z = ProjectionMatrix[2][3];\n" -" mvpFragIn.w = ProjectionMatrix[3][3];\n" -" texCoord = vec2(0.0,1.0);\n" -" gl_Position = ProjectionMatrix * pos;\n" -" EmitVertex();\n" -" pos = posCenter + vec4(-size, -size, 0.0, 0.0);\n" -" texCoord = vec2(0.0,0.0);\n" -" gl_Position = ProjectionMatrix * pos;\n" -" EmitVertex();\n" -" pos = posCenter + vec4( size, size, 0.0, 0.0);\n" -" texCoord = vec2(1.0,1.0);\n" -" gl_Position = ProjectionMatrix * pos;\n" -" EmitVertex();\n" -" pos = posCenter + vec4( size,-size, 0.0, 0.0);\n" -" texCoord = vec2(1.0,0.0);\n" -" gl_Position = ProjectionMatrix * pos;\n" -" EmitVertex();\n" -" EndPrimitive();\n" -"}"; - - -std::string PointSprite::fragmentShaderText = -"uniform sampler2D SpriteTexture;\n" -"uniform float size;\n" -"uniform vec3 color;\n" -"VARYING_FRAG vec2 texCoord;\n" -"VARYING_FRAG vec2 positionFragIn;\n" -"VARYING_FRAG vec4 mvpFragIn;\n" -"void main(void)\n" -"{\n" -" float lum = texture2D(SpriteTexture, texCoord).s;\n" -" if (lum==0.0)\n" -" discard;\n" -" vec2 v = texCoord-vec2(0.5,0.5);\n" -" float z = size * sqrt(1.0-dot(v,v));\n" -" vec2 zfrag = positionFragIn + vec2(z,0.0);\n" -" gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw);\n" -" gl_FragColor = vec4(color,0.0)*lum;\n" -"}"; + +//std::string PointSprite::vertexShaderText = +//"ATTRIBUTE vec3 VertexPosition;\n" +//"void main ()\n" +//"{\n" +//" gl_Position = vec4(VertexPosition,1.0);\n" +//"}"; + + +//std::string PointSprite::geometryShaderText = +//"uniform float size;\n" +//"uniform mat4 ModelViewMatrix;\n" +//"uniform mat4 ProjectionMatrix;\n" +//"VARYING_OUT vec2 texCoord;\n" +//"VARYING_OUT vec2 positionFragIn;\n" +//"VARYING_OUT vec4 mvpFragIn;\n" +//"void main()\n" +//"{\n" +//" vec4 posCenter = ModelViewMatrix * POSITION_IN(0);\n" +//" vec4 pos = posCenter + vec4(-size, size, 0.0, 0.0);\n" +//" positionFragIn = posCenter.zw;\n" +//" mvpFragIn.x = ProjectionMatrix[2][2];\n" +//" mvpFragIn.y = ProjectionMatrix[3][2];\n" +//" mvpFragIn.z = ProjectionMatrix[2][3];\n" +//" mvpFragIn.w = ProjectionMatrix[3][3];\n" +//" texCoord = vec2(0.0,1.0);\n" +//" gl_Position = ProjectionMatrix * pos;\n" +//" EmitVertex();\n" +//" pos = posCenter + vec4(-size, -size, 0.0, 0.0);\n" +//" texCoord = vec2(0.0,0.0);\n" +//" gl_Position = ProjectionMatrix * pos;\n" +//" EmitVertex();\n" +//" pos = posCenter + vec4( size, size, 0.0, 0.0);\n" +//" texCoord = vec2(1.0,1.0);\n" +//" gl_Position = ProjectionMatrix * pos;\n" +//" EmitVertex();\n" +//" pos = posCenter + vec4( size,-size, 0.0, 0.0);\n" +//" texCoord = vec2(1.0,0.0);\n" +//" gl_Position = ProjectionMatrix * pos;\n" +//" EmitVertex();\n" +//" EndPrimitive();\n" +//"}"; + + +//std::string PointSprite::fragmentShaderText = +//"uniform sampler2D SpriteTexture;\n" +//"uniform float size;\n" +//"uniform vec3 color;\n" +//"VARYING_FRAG vec2 texCoord;\n" +//"VARYING_FRAG vec2 positionFragIn;\n" +//"VARYING_FRAG vec4 mvpFragIn;\n" +//"void main(void)\n" +//"{\n" +//" float lum = texture2D(SpriteTexture, texCoord).s;\n" +//" if (lum==0.0)\n" +//" discard;\n" +//" vec2 v = texCoord-vec2(0.5,0.5);\n" +//" float z = size * sqrt(1.0-dot(v,v));\n" +//" vec2 zfrag = positionFragIn + vec2(z,0.0);\n" +//" gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw);\n" +//" gl_FragColor = vec4(color,0.0)*lum;\n" +//"}"; PointSprite::PointSprite(float radius) diff --git a/src/Utils/text3d.cpp b/src/Utils/text3d.cpp index 2f080590df96319e7dec688616ace4c0419a47bd..964ac001c5888e652b502cd2a0b98445617ca3bb 100644 --- a/src/Utils/text3d.cpp +++ b/src/Utils/text3d.cpp @@ -31,31 +31,33 @@ namespace CGoGN namespace Utils { - -std::string Strings3D::vertexShaderText = -"ATTRIBUTE vec4 VertexPosition;\n" -"uniform mat4 ModelViewMatrix;\n" -"uniform mat4 ProjectionMatrix;\n" -"uniform vec3 strPos;\n" -"uniform float scale;\n" -"VARYING_VERT vec2 tex_coord;\n" -"INVARIANT_POS;\n" -"void main ()\n" -"{\n" -" vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0);\n" -" tex_coord = vec2(VertexPosition[2],VertexPosition[3]);\n" -" gl_Position = ProjectionMatrix * pos;\n" -"}"; - - -std::string Strings3D::fragmentShaderText1 = -"VARYING_FRAG vec2 tex_coord;\n" -"uniform sampler2D FontTexture;\n" -"uniform vec3 color;\n" -"FRAG_OUT_DEF;\n" -"void main (void)\n" -"{\n" -" float lum = texture2D(FontTexture, tex_coord).s;\n"; +#include "text3d.vert" +#include "text3d.frag" + +//std::string Strings3D::vertexShaderText = +//"ATTRIBUTE vec4 VertexPosition;\n" +//"uniform mat4 ModelViewMatrix;\n" +//"uniform mat4 ProjectionMatrix;\n" +//"uniform vec3 strPos;\n" +//"uniform float scale;\n" +//"VARYING_VERT vec2 tex_coord;\n" +//"INVARIANT_POS;\n" +//"void main ()\n" +//"{\n" +//" vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0);\n" +//" tex_coord = vec2(VertexPosition[2],VertexPosition[3]);\n" +//" gl_Position = ProjectionMatrix * pos;\n" +//"}"; +// +// +//std::string Strings3D::fragmentShaderText1 = +//"VARYING_FRAG vec2 tex_coord;\n" +//"uniform sampler2D FontTexture;\n" +//"uniform vec3 color;\n" +//"FRAG_OUT_DEF;\n" +//"void main (void)\n" +//"{\n" +//" float lum = texture2D(FontTexture, tex_coord).s;\n"; std::string Strings3D::fragmentShaderText2 = " gl_FragColor = vec4(color,0.0)*lum;\n"