Simon.Anderson Posted October 17, 2014 Share Posted October 17, 2014 Hi There, We're getting this shader error on certain machines. On first glance - it looks like a syntax error but on most machines it seems to work fine. There is no error and the objects display properly. However, on certain machines this error appears and the object appears black: GLShader::loadFragment(): error in "shaders/rtvis_raycast_fragment.shader" filedefines: INTEL,INTEL_HD,QUALITY_LOW,QUALITY_MEDIUM,MULTISAMPLE_0,USE_INSTANCING,USE_TESSELLATION,USE_GEOMETRY_SHADER,USE_TEXTURE_3D,USE_TEXTURE_ARRAY,USE_ALPHA_FADE,USE_REFLECTION,USE_PARALLAX,HAS_DEFERRED_COLOR,HAS_DEFERRED_NORMAL,HAS_DEFERRED_PARALLAX,USE_RGB10A2,USE_PHONG_RIM,USE_ENVIRONMENT,USE_NORMALIZATION,USE_DIRECTIONAL_LIGHTMAPS,USE_SHADOW_KERNEL,OPENGL,HAS_ARB_DRAW_INSTANCED,HAS_ARB_TEXTURE_SNORM,SHADING_LANGUAGE=150,USE_ARB_BLEND_FUNC_EXTENDED,USE_ARB_SHADER_BIT_ENCODING,HAS_ARB_GPU_SHADER5,BASE_AMBIENT,AMBIENT,LUT_COLORERROR: 0:819: '&&' : wrong operand types no operation '&&' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)ERROR: 0:819: 'assign' : cannot convert from 'const bool' to '3-component vector of bool'ERROR: 0:825: '||' : wrong operand types no operation '||' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)ERROR: 0:825: 'assign' : cannot convert from 'const bool' to '3-component vector of bool'ERROR: 0:882: '&&' : wrong operand types no operation '&&' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)ERROR: 0:882: 'assign' : cannot convert from 'const bool' to '3-component vector of bool' TY_LOW,QUALITY_MEDIUM,MULTISAMPLE_0,USE_INSTANCING,USE_TESSELLATION,USE_GEOMETRY_SHADER,USE_TEXTURE_3D,USE_TEXTURE_ARRAY,USE_ALPHA_FADE,USE_REFLECTION,USE_PARALLAX,HAS_DEFERRED_COLOR,HAS_DEFERRED_NORMAL,HAS_DEFERRED_PARALLAX,USE_RGB10A2,USE_PHONG_RIM,USE_ENVIRONMENT,USE_NORMALIZATION,USE_DIRECTIONAL_LIGHTMAPS,USE_SHADOW_KERNEL,OPENGL,HAS_ARB_DRAW_INSTANCED,HAS_ARB_TEXTURE_SNORM,SHADING_LANGUAGE=150,USE_ARB_BLEND_FUNC_EXTENDED,USE_ARB_SHADER_BIT_ENCODING,HAS_ARB_GPU_SHADER5,BASE_AMBIENT,AMBIENT,LUT_COLORERROR: 0:819: '&&' : wrong operand types no operation '&&' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)ERROR: 0:819: 'assign' : cannot convert from 'const bool' to '3-component vector of bool'ERROR: 0:825: '||' : wrong operand types no operation '||' ex Link to comment
silent Posted October 17, 2014 Share Posted October 17, 2014 Hi, Is rtvis_raycast_fragment.shader your custom shader? Any sample for reproduction? Also, there are some questions left: On what GPUs this issue appears? Is latest GPU driver installed? What Unigine version are you using? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Simon.Anderson Posted October 20, 2014 Author Share Posted October 20, 2014 Hi, yes it appears to be a custom shader. I'm having the issue on my Intel HD Graphics 4400 (notebook). I've just installed the latest drivers and still having the issue. I thought the shader/opengl version currently installed was the culprit (too old to support the latest language features) but even the latest drivers didn't fix it. I'm running OpenGL 4.3. My other machine with an NVIDia Quadro K1000M is running OpenGL 4.2 and is not having any issues. #include <core/shaders/default/common/fragment_base.h> /* Use DDA voxel walking algorithm to calculate which voxel has beed hit and therefore the frag colour.*/ /******************************************************************************\** OpenGL/OpenGLES*\******************************************************************************/ #ifdef OPENGL || OPENGLES in vec4 fragColor; uniform vec4 voxel_grid_size;uniform vec4 camera_pos; // clipping planeuniform vec4 plane_normal[8];uniform float plane_count; uniform sampler2D s_texture_0;uniform sampler3D s_texture_1;uniform sampler3D s_texture_2; vec3 step_size = vec3(1.0/voxel_grid_size.x, 1.0/voxel_grid_size.y, 1.0/voxel_grid_size.z);ivec3 grid_size = ivec3(voxel_grid_size.xyz);int num_samples = grid_size.x + grid_size.y + grid_size.z; const float epsilon = 0.0001; // perform a ray plane intersection and then return the parametric time of intersection// Note: the plane normals are required to be unit normals i.e length of 1.0bool PlaneRayIntersect(vec3 rayDir, vec3 rayOrigin, int plane_index, out float t1){rayDir = normalize(rayDir); vec4 n = plane_normal[plane_index]; float ray_plane_angle = dot( n.xyz, rayDir );if( ray_plane_angle < 0 ){ t1 = -( dot( rayOrigin, n.xyz) + n.w ) / ray_plane_angle; return true;}else { return false; }} bool InFrontOfPlane(vec3 point, int plane_index){ vec4 n = plane_normal[plane_index]; return dot( point, n.xyz ) + n.w >= 0;} // calculate the correct fragment depth from the cube space// see http://www.arcsynthesis.org/gltut/Illumination/Tut13%20Deceit%20in%20Depth.htmlvoid SetFragDepth( vec4 pos ){ float far = gl_DepthRange.far; float near = gl_DepthRange.near; vec4 eye_space_pos = s_projection * vec4( dot(s_transform[0],pos) , dot(s_transform[1],pos),dot(s_transform[2],pos), 1.0f); float ndc_depth = eye_space_pos.z / eye_space_pos.w; float depth = ( ( ( far - near ) * ndc_depth ) + near + far ) * 0.5; gl_FragDepth = max( near, depth);} // for each clipping plane remember if we start in front or notbool front[8] = bool[](false, false, false, false, false, false, false, false);float onPlane = 0.0; void main(){ // calculate if we are inside // todo: probably should just pass this from the geometry shader bool inside = all(greaterThan(camera_pos.xyz, vec3(-0.5, -0.5, -0.5))) && all(lessThan(camera_pos.xyz, vec3(0.5, 0.5, 0.5))); vec3 pos = s_texcoord_0.xyz - vec3(0.5); vec3 rayPos = s_texcoord_0.xyz * vec3(grid_size); vec3 rayDir = pos - camera_pos.xyz; // if we're inside the volume we need to start the ray from the camera if (inside) { rayPos = (camera_pos.xyz + vec3(0.5)) * vec3(grid_size); pos = camera_pos.xyz; } bool haveClippingPlane = plane_count > 0.5; // if the point is in front of a clipping plane // we need to snap the ray pos onto the plane for( int i = 0; i < int(plane_count); i++ ) { // is the ray moving from the front to the back? front = InFrontOfPlane( pos, i ); if ( haveClippingPlane && front ) { onPlane = 1.0; // don't skip first voxel inside = false; float t; // pos must be in camera space if ( PlaneRayIntersect( rayDir, pos, i, t) ) { pos = pos + vec3(0.5) + normalize(rayDir) * t; // pos now in texutre space // the plane intersection is outside of the volume so discard if ( any( lessThan( pos, vec3(0.0, 0.0, 0.0) ) ) || any( greaterThanEqual(pos, vec3(1.0, 1.0, 1.0)) ) ) { discard; } // re-start the ray from the plane rayPos = pos * vec3(grid_size); // back to camera space pos -= vec3(0.5); } else { discard; } } } ivec3 mapPos = ivec3(floor(rayPos)); // clamp - round down or up into the correct grid cell. mapPos = clamp(mapPos, ivec3(0,0,0), grid_size - ivec3(1, 1, 1)); vec3 deltaDist = abs(vec3(1) / rayDir); ivec3 rayStep = ivec3(sign(rayDir)); vec3 sideDist = (sign(rayDir) * (vec3(mapPos) - rayPos) + (sign(rayDir) * 0.5) + 0.5) * deltaDist; bvec3 mask = bvec3(false); vec3 color; bvec3 boundsCheck = bvec3(false); // grab the first hit value float mask_value = texelFetch(s_texture_2,mapPos,0).r; // edge case - if we're inside we need to skip the first voxel if (mask_value == 0.0 || inside) { onPlane = 0.0; // ray cast for (int i = 0; i < num_samples; i++) { // divide by the grid size to get back to the textCoords i.e (* 1 / grid_size) vec3 adjDist = sideDist * step_size; bvec3 b1 = lessThan(adjDist.xyz, adjDist.yzx); bvec3 b2 = lessThanEqual(adjDist.xyz, adjDist.zxy); mask = b1 && b2; sideDist += vec3(mask) * deltaDist; mapPos += ivec3(mask) * rayStep; // terminate if outside the box boundsCheck = lessThan(mapPos, vec3(0.0)) || lessThanEqual(grid_size, mapPos); i += int(any(boundsCheck)) * num_samples; mask_value = texelFetch(s_texture_2,mapPos,0).r; // terminate if we are going to hit something i += int(mask_value * 256.0) * num_samples; } } // out of bounds if (any(boundsCheck)) { discard; } // no hit - we hit the sample limit if ( mask_value == 0.0) { discard; } // we hit something // calculate the exact hit position // the ray direction vec3 dir = normalize(rayDir); vec3 dirfrac = vec3(1.0) / dir; // calculate the bounding box of the voxel hit vec3 lb = (vec3(mapPos) * step_size) - vec3(0.5); vec3 rt = lb + step_size; // the origin of the ray vec3 orig = (rayPos * step_size) - vec3(0.5); // calculate the parametric time of intersection vec3 tl = (lb - orig) * dirfrac; vec3 tr = (rt - orig) * dirfrac; vec3 mint = min (tl, tr); float t = max ( max ( mint.x, mint.y ), mint.z ) ; // calculate the hit position // special case: if we're on a clipping plane then we already have the correct position vec3 clip_pos = (onPlane * (pos) + ((1.0 - onPlane) * (orig + t * dir))); for( int i = 0; i < int(plane_count); i++ ) { // discard if the ray is moving from the back to the front and the final position is in front of a clipping plane if ( haveClippingPlane && !front && InFrontOfPlane( clip_pos, i ) ) { discard; } } // set the side of the voxel hit in the mask // this basically calculates the maximum component of a vector mask = greaterThan(mint.xyz, mint.yzx) && greaterThan(mint.xyz, mint.zxy); // must have hit something // lookup the color float value = texelFetch(s_texture_1,mapPos,0).r; int lookup_x = int( textureSize(s_texture_0,0).x * value ); color = texelFetch( s_texture_0, ivec2(lookup_x, 0), 0 ).rgb; // calculate shading // special case for shading on a clipping plane - use shade 1.0 float shade = max( onPlane, dot(vec3(mask), vec3(1.0, 0.9, 0.8)) ); s_frag_color.rgb = color * shade; SetFragDepth( vec4(clip_pos, 1.0) );} #endif Link to comment
silent Posted October 20, 2014 Share Posted October 20, 2014 Could you please specify on which SDK version this issue can be reproduced? On which SDK version this shader worked correctly? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Simon.Anderson Posted October 20, 2014 Author Share Posted October 20, 2014 Sorry, Are you talking about the Unigine SDK? If so is there an easy way to figure out the version number? The pre-compiled dlls don't seem to have a version number associated with them. BTW the unigine sdk is the exact same version on both machines. Thanks, Simon Link to comment
silent Posted October 20, 2014 Share Posted October 20, 2014 Yes, I'm talking about the Unigine SDK version. You can check it inside <Unigine_SDK_Install_Dir>/unigine-sdk-version file. Basically, it is the SDK publish date (for example, 2014-07-07). Also, you can check it in <Unigine_SDK_Install_Dir>/bin/log.html file (line start with Binary:). Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Simon.Anderson Posted October 20, 2014 Author Share Posted October 20, 2014 More info - on the machine that works: Renderer: Quadro K1000M/PCIe/SSE2Vendor: NVIDIA CorporationMemory: 2048 MBVersion: 4.2.0Shading language version: 4.20 NVIDIA via Cg compiler The machine with problems: Renderer: Intel® HD Graphics 4400Vendor: IntelMemory: 1024 MBVersion: 4.3.0 - Build 10.18.10.3907Shading language version: 4.30 - Build 10.18.10.3907 Link to comment
unclebob Posted October 28, 2014 Share Posted October 28, 2014 Hey Simon, According to GLSL 4.20.8 spec, logical operators are basically working only with booleans for both lsv and rsv so this code may not compile: bvec3 mask = bvec3(false); ... bvec3 b1 = lessThan(adjDist.xyz, adjDist.yzx); bvec3 b2 = lessThanEqual(adjDist.xyz, adjDist.zxy); mask = b1 && b2; I think it's the main problem here. Try to use * instead of && and max instead of || for bvec type. Link to comment
Simon.Anderson Posted November 5, 2014 Author Share Posted November 5, 2014 Hi unclebob, Unfortunately I tried substituting * and max, and it still didn't compile. Thanks, Simon Link to comment
unclebob Posted November 5, 2014 Share Posted November 5, 2014 Hey Simon, Could you please provide us a simple test scene with your custom shader so we'll be able to test it and see the problem? Thanks! Link to comment
Recommended Posts