| 101 | } |
| 102 | |
| 103 | std::string getVolumeFragmentShader() |
| 104 | { |
| 105 | return MR_GLSL_VERSION_LINE R"( |
| 106 | precision highp float; |
| 107 | precision highp int; |
| 108 | |
| 109 | uniform mat4 model; |
| 110 | uniform mat4 view; |
| 111 | uniform mat4 proj; |
| 112 | uniform mat4 normal_matrix; |
| 113 | |
| 114 | uniform int shadingMode; // 0-none,1-dense grad,2-alpha grad |
| 115 | uniform float specExp; // (in from base) lighting parameter |
| 116 | uniform vec3 ligthPosEye; // (in from base) light position transformed by view only (not proj) |
| 117 | uniform float ambientStrength; // (in from base) non-directional lighting |
| 118 | uniform float specularStrength; // (in from base) reflection intensity |
| 119 | |
| 120 | uniform vec4 viewport; |
| 121 | uniform vec3 voxelSize; |
| 122 | uniform vec3 minCorner; |
| 123 | uniform float minValue; |
| 124 | uniform float maxValue; |
| 125 | uniform float step; |
| 126 | |
| 127 | uniform highp sampler3D volume; |
| 128 | uniform highp sampler2D denseMap; |
| 129 | uniform highp usampler2D activeVoxels; // (in from base) selection BitSet |
| 130 | |
| 131 | uniform bool useClippingPlane; // (in from base) clip primitive by plane if true |
| 132 | uniform vec4 clippingPlane; // (in from base) clipping plane |
| 133 | |
| 134 | out vec4 outColor; |
| 135 | )" |
| 136 | + getVolumeShaderCommonFunctions() + |
| 137 | R"( |
| 138 | vec3 normalEye( in vec3 textCoord, in vec3 dimStepVoxel, in bool alphaGrad ) |
| 139 | { |
| 140 | float minXVal = getVal( texture( volume, textCoord - vec3(dimStepVoxel.x,0,0)).r ); |
| 141 | float maxXVal = getVal( texture( volume, textCoord + vec3(dimStepVoxel.x,0,0)).r ); |
| 142 | float minYVal = getVal( texture( volume, textCoord - vec3(0,dimStepVoxel.y,0)).r ); |
| 143 | float maxYVal = getVal( texture( volume, textCoord + vec3(0,dimStepVoxel.y,0)).r ); |
| 144 | float minZVal = getVal( texture( volume, textCoord - vec3(0,0,dimStepVoxel.z)).r ); |
| 145 | float maxZVal = getVal( texture( volume, textCoord + vec3(0,0,dimStepVoxel.z)).r ); |
| 146 | if ( alphaGrad ) |
| 147 | { |
| 148 | minXVal = getGradAlphaVal( minXVal ); |
| 149 | maxXVal = getGradAlphaVal( maxXVal ); |
| 150 | minYVal = getGradAlphaVal( minYVal ); |
| 151 | maxYVal = getGradAlphaVal( maxYVal ); |
| 152 | minZVal = getGradAlphaVal( minZVal ); |
| 153 | maxZVal = getGradAlphaVal( maxZVal ); |
| 154 | } |
| 155 | vec3 grad = -vec3( maxXVal - minXVal, maxYVal - minYVal, maxZVal - minZVal ); |
| 156 | if ( dot( grad, grad ) < 1.0e-5 ) |
| 157 | return vec3(0,0,0); |
| 158 | grad = vec3( normal_matrix *vec4( normalize(grad),0.0 ) ); |
| 159 | grad = normalize( grad ); |
| 160 | return grad; |
no test coverage detected