1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0026665: Visualization, TKOpenGl - specify precision for integer uniforms explicitly within OpenGL ES

Use lowp for enumerations / Boolean uniforms.
Define default integer precision to highp in Fragment Shader when available.
This commit is contained in:
kgv 2015-09-09 10:29:43 +03:00 committed by bugmaster
parent 598f4391a8
commit 8a53d1c486
3 changed files with 21 additions and 13 deletions

View File

@ -227,7 +227,9 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
#if defined(GL_ES_VERSION_2_0)
TCollection_AsciiString aPrefix (theCtx->hasHighp
? "precision highp float;\n"
: "precision mediump float;\n");
"precision highp int;\n"
: "precision mediump float;\n"
"precision mediump int;\n");
aSource = aHeader + aPrefix + aSource;
#else
aSource = aHeader + aSource;

View File

@ -33,6 +33,12 @@
#define occTexture2D texture2D
#endif
#ifdef GL_ES
#define THE_PREC_ENUM lowp // enumerations should fit into lowp range
#else
#define THE_PREC_ENUM
#endif
// Vertex attributes
#ifdef VERTEX_SHADER
THE_ATTRIBUTE vec4 occVertex;
@ -68,8 +74,8 @@ const int OccLightType_Point = 2; //!< isotropic point light source
const int OccLightType_Spot = 3; //!< spot light source
// Light sources
uniform vec4 occLightAmbient; //!< Cumulative ambient color
uniform int occLightSourcesCount; //!< Total number of light sources
uniform vec4 occLightAmbient; //!< Cumulative ambient color
uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
int occLight_Type (in int theId); //!< Type of light source
int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
@ -97,17 +103,17 @@ vec4 occBackMaterial_Specular(void); //!< Specular reflection
float occBackMaterial_Shininess(void); //!< Specular exponent
float occBackMaterial_Transparency(void); //!< Transparency coefficient
uniform vec4 occColor; //!< color value (in case of disabled lighting)
uniform int occDistinguishingMode; //!< Are front and back faces distinguished?
uniform int occTextureEnable; //!< Is texture enabled?
uniform sampler2D occActiveSampler; //!< Current active sampler
uniform float occPointSize; //!< point size
uniform vec4 occColor; //!< color value (in case of disabled lighting)
uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
uniform sampler2D occActiveSampler; //!< Current active sampler
uniform float occPointSize; //!< point size
// clipping planes state
const int OccEquationCoords_View = 0; //!< view-space clipping plane
const int OccEquationCoords_World = 1; //!< world-space clipping plane
//! Parameters of clipping planes
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
uniform int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
uniform int occClipPlaneCount; //!< Total number of clip planes
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
uniform THE_PREC_ENUM int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes

View File

@ -16,8 +16,8 @@
// This file includes implementation of common functions and properties accessors
// arrays of light sources
uniform ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
// light source properties accessors
int occLight_Type (in int theId) { return occLightSourcesTypes[theId].x; }