   HLSL to GLSL converter for tex2D
  Hello people,I'm trying to convert a HLSL shader into GLSL one, but I have this problem:float shiftTex = tex2D(specularShiftTexture, texCoord) - 0.5;I know "texture2D" in GLSL is same as "tex2D" but it returns a vec4 not a float, but here tex2D returns a float!!!could someone help me please   
  tex2D also returns a float4, it's just implicitely casted to float1 in this case. To my knowledge, vector operations do work the same in GLSL and therefore this line of code should translate well.   ;  tnx for the reply, but could you please tell me how do u cast float4 into float?   ;  No. That's what the documentation is for.   ;  Try this:float shiftTex = texture2D(specularShiftTexture, texCoord.xy).r;   ;  thank you sk8beast but why "r" why not "s" or "t"?   ;  r is from rgba ( or xyzw or stpq), but whatever, you get the same. while the specular texture is a greyscale image the r,g,b (or x,y,z or s,t,p) is equal.i hope you can understand my english. :D   ;  thank youQuote:Original post by sk8beastr is from rgba ( or xyzw or stpq), but whatever, you get the same. while the specular texture is a greyscale image the r,g,b (or x,y,z or s,t,p) is equal.i hope you can understand my english. :D