X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FShaders%2FShaders_Declarations_glsl.pxx;h=cec68050b481541e71a49c419ec2e8d4501ffebb;hp=d2d9191fbfc6cf163acb80ff4a36279b15ece2b5;hb=b17e5bae1a46be4042d3cd3530ff45e43b32613a;hpb=a1073ae267989cea79ceb5299b4f921da714616d diff --git a/src/Shaders/Shaders_Declarations_glsl.pxx b/src/Shaders/Shaders_Declarations_glsl.pxx index d2d9191fbf..cec68050b4 100644 --- a/src/Shaders/Shaders_Declarations_glsl.pxx +++ b/src/Shaders/Shaders_Declarations_glsl.pxx @@ -16,10 +16,20 @@ static const char Shaders_Declarations_glsl[] = "// Alternatively, this file may be used under the terms of Open CASCADE\n" "// commercial license or contractual agreement.\n" "\n" - "// This files includes definition of common uniform variables in OCCT GLSL programs\n" + "//! @file Declarations.glsl\n" + "//! This files includes definition of common uniform variables in OCCT GLSL programs\n" "\n" - "#define THE_MAX_LIGHTS 8\n" - "#define THE_MAX_CLIP_PLANES 8\n" + "//! @def THE_MAX_LIGHTS\n" + "//! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager.\n" + "// #define THE_MAX_LIGHTS 8\n" + "\n" + "//! @def THE_MAX_CLIP_PLANES\n" + "//! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager.\n" + "// #define THE_MAX_CLIP_PLANES 8\n" + "\n" + "//! @def THE_NB_FRAG_OUTPUTS\n" + "//! Specifies the length of array of Fragment Shader outputs, which is 1 by default. Defined by Shader Manager.\n" + "// #define THE_NB_FRAG_OUTPUTS 1\n" "\n" "// compatibility macros\n" "#if (__VERSION__ >= 130)\n" @@ -27,13 +37,17 @@ static const char Shaders_Declarations_glsl[] = " #define THE_SHADER_IN in\n" " #define THE_SHADER_OUT out\n" " #define THE_OUT out\n" + " #define occTexture1D texture\n" " #define occTexture2D texture\n" + " #define occTexture3D texture\n" "#else\n" " #define THE_ATTRIBUTE attribute\n" " #define THE_SHADER_IN varying\n" " #define THE_SHADER_OUT varying\n" " #define THE_OUT\n" + " #define occTexture1D texture1D\n" " #define occTexture2D texture2D\n" + " #define occTexture3D texture3D\n" "#endif\n" "\n" "#ifdef GL_ES\n" @@ -48,18 +62,46 @@ static const char Shaders_Declarations_glsl[] = " THE_ATTRIBUTE vec3 occNormal;\n" " THE_ATTRIBUTE vec4 occTexCoord;\n" " THE_ATTRIBUTE vec4 occVertColor;\n" - "#elif (__VERSION__ >= 130)\n" - " out vec4 occFragColor;\n" - " #ifdef OCC_ENABLE_draw_buffers\n" - " out vec4 occFragCoverage;\n" + "#elif defined(FRAGMENT_SHADER)\n" + " #if (__VERSION__ >= 130)\n" + " #ifdef OCC_ENABLE_draw_buffers\n" + " out vec4 occFragColorArray[THE_NB_FRAG_OUTPUTS];\n" + " #define occFragColorArrayAlias occFragColorArray\n" + " #define occFragColor0 occFragColorArray[0]\n" + " #else\n" + " out vec4 occFragColor0;\n" + " #endif\n" + " #else\n" + " #ifdef OCC_ENABLE_draw_buffers\n" + " #define occFragColorArrayAlias gl_FragData\n" + " #define occFragColor0 gl_FragData[0]\n" + " #else\n" + " #define occFragColor0 gl_FragColor\n" + " #endif\n" " #endif\n" - "#else\n" - " #ifdef OCC_ENABLE_draw_buffers\n" - " #define occFragColor gl_FragData[0]\n" - " #define occFragCoverage gl_FragData[1]\n" + "\n" + " #if (THE_NB_FRAG_OUTPUTS >= 2)\n" + " #define occFragColor1 occFragColorArrayAlias[1]\n" + " #else\n" + " vec4 occFragColor1;\n" + " #endif\n" + " #if (THE_NB_FRAG_OUTPUTS >= 3)\n" + " #define occFragColor2 occFragColorArrayAlias[2]\n" + " #else\n" + " vec4 occFragColor2;\n" + " #endif\n" + " #if (THE_NB_FRAG_OUTPUTS >= 4)\n" + " #define occFragColor3 occFragColorArrayAlias[3]\n" " #else\n" - " #define occFragColor gl_FragColor\n" + " vec4 occFragColor3;\n" " #endif\n" + "\n" + " // Built-in outputs notation\n" + " #define occFragColor occFragColor0\n" + " #define occFragCoverage occFragColor1\n" + "\n" + " //! Define the main Fragment Shader output - color value.\n" + " void occSetFragColor (in vec4 theColor);\n" "#endif\n" "\n" "// Matrix state\n" @@ -86,6 +128,7 @@ static const char Shaders_Declarations_glsl[] = "\n" "// Light sources\n" "uniform vec4 occLightAmbient; //!< Cumulative ambient color\n" + "#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n" "uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n" "int occLight_Type (in int theId); //!< Type of light source\n" "int occLight_IsHeadlight (in int theId); //!< Is light a headlight?\n" @@ -97,6 +140,7 @@ static const char Shaders_Declarations_glsl[] = "float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source\n" "float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)\n" "float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)\n" + "#endif\n" "\n" "// Front material properties accessors\n" "vec4 occFrontMaterial_Emission(void); //!< Emission color\n" @@ -114,10 +158,13 @@ static const char Shaders_Declarations_glsl[] = "float occBackMaterial_Shininess(void); //!< Specular exponent\n" "float occBackMaterial_Transparency(void); //!< Transparency coefficient\n" "\n" + "#define occActiveSampler occSampler0 //!< alias for backward compatibility\n" + "#define occSamplerBaseColor occSampler0 //!< alias to a base color texture\n" + "uniform sampler2D occSampler0; //!< current active sampler;\n" + " //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing\n" "uniform vec4 occColor; //!< color value (in case of disabled lighting)\n" "uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?\n" "uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?\n" - "uniform sampler2D occActiveSampler; //!< Current active sampler\n" "uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters\n" "uniform float occPointSize; //!< point size\n" "\n" @@ -126,5 +173,7 @@ static const char Shaders_Declarations_glsl[] = "uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment\n" "\n" "//! Parameters of clipping planes\n" + "#if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)\n" "uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];\n" - "uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n"; + "uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n" + "#endif\n";