PageRenderTime 542ms CodeModel.GetById 529ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl

https://bitbucket.org/lindenlab/viewer-beta/
text | 72 lines | 54 code | 18 blank | 0 comment | 0 complexity | 64e69ae13d27279531fbadca7a2d9dba MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file terrainV.glsl
  3. *
  4. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2007, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. void calcAtmospherics(vec3 inPositionEye);
  26. vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
  27. vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
  28. {
  29. vec4 tcoord;
  30. tcoord.x = dot(vpos, tp0);
  31. tcoord.y = dot(vpos, tp1);
  32. tcoord.z = tc.z;
  33. tcoord.w = tc.w;
  34. tcoord = mat * tcoord;
  35. return tcoord;
  36. }
  37. void main()
  38. {
  39. //transform vertex
  40. gl_Position = ftransform();
  41. vec4 pos = gl_ModelViewMatrix * gl_Vertex;
  42. vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
  43. /// Potentially better without it for water.
  44. pos /= pos.w;
  45. calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
  46. vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0));
  47. gl_FrontColor = color;
  48. // Transform and pass tex coords
  49. gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
  50. vec4 t = gl_MultiTexCoord1;
  51. gl_TexCoord[0].zw = t.xy;
  52. gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0);
  53. gl_TexCoord[1].zw = t.xy-vec2(1.0, 0.0);
  54. }