Advertisement
Guest User

Untitled

a guest
Sep 18th, 2015
123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //*****************************************************************************
  2. // Torque -- GLSL procedural shader
  3. //*****************************************************************************
  4. #include "shaders/common/gl/hlslCompat.glsl"
  5.  
  6. // Dependencies:
  7. #include "shaders/common/gl/imposter.glsl"
  8. #include "shaders/common/gl/torque.glsl"
  9.  
  10. // Features:
  11. // Imposter Vert
  12. // Paraboloid Vert Transform
  13. // Base Texture
  14. // Alpha Test
  15. // Visibility
  16. // Depth (Out)
  17.  
  18. struct VertexData
  19. {
  20.    vec4 position;
  21.    vec2 tcImposterParams;
  22.    vec3 tcImposterUpVec;
  23.    vec3 tcImposterRightVec;
  24. } IN;
  25.  
  26. in vec4 vPosition;
  27. #define IN_position IN.position
  28. in vec2 vTexCoord0;
  29. #define IN_tcImposterParams IN.tcImposterParams
  30. in vec3 vTexCoord1;
  31. #define IN_tcImposterUpVec IN.tcImposterUpVec
  32. in vec3 vTexCoord2;
  33. #define IN_tcImposterRightVec IN.tcImposterRightVec
  34.  
  35. out float _TEXCOORD0_;
  36. out float2 _TEXCOORD1_;
  37. out vec2 _TEXCOORD2_;
  38. out vec4 _TEXCOORD3_;
  39. out float _TEXCOORD4_;
  40.  
  41. // Struct defines
  42. #define OUT_imposterFade _TEXCOORD0_
  43. #define OUT_posXY _TEXCOORD1_
  44. #define OUT_out_texCoord _TEXCOORD2_
  45. #define OUT_outVpos _TEXCOORD3_
  46. #define OUT_depth _TEXCOORD4_
  47.  
  48. //-----------------------------------------------------------------------------
  49. // Main                                                                        
  50. //-----------------------------------------------------------------------------
  51. uniform vec4     imposterLimits ;
  52. uniform vec4     imposterUVs    [64];
  53. uniform vec3     eyePosWorld    ;
  54. uniform vec2     atlasScale     ;
  55. uniform float4x4 worldViewOnly  ;
  56. uniform vec4     lightParams    ;
  57. uniform vec2     atlasXOffset   ;
  58.  
  59.  
  60. void main()
  61. {
  62.  
  63.    //-------------------------
  64.    IN.position = vPosition;
  65.    IN.tcImposterParams = vTexCoord0;
  66.    IN.tcImposterUpVec = vTexCoord1;
  67.    IN.tcImposterRightVec = vTexCoord2;
  68.    //-------------------------
  69.  
  70.    // Imposter Vert
  71.    vec3 inPosition;
  72.    vec2 texCoord;
  73.    float3x3 worldToTangent;
  74.    OUT_imposterFade = IN_tcImposterParams.y;
  75.    imposter_v( IN_position.xyz, int(IN_position.w), IN_tcImposterParams.x * length(IN_tcImposterRightVec), normalize(IN_tcImposterUpVec), normalize(IN_tcImposterRightVec), int(imposterLimits.y), int(imposterLimits.x), imposterLimits.z, bool(imposterLimits.w), eyePosWorld, imposterUVs, inPosition, texCoord, worldToTangent );
  76.    vec3 wsPosition = inPosition.xyz;
  77.    float3x3 viewToTangent = worldToTangent;
  78.    
  79.    // Paraboloid Vert Transform
  80.    gl_Position = tMul(worldViewOnly, float4(inPosition.xyz,1)).xzyw;
  81.    float L = length(gl_Position.xyz);
  82.    gl_Position /= L;
  83.    gl_Position.z = gl_Position.z + 1.0;
  84.    gl_Position.xy /= gl_Position.z;
  85.    gl_Position.z = L / lightParams.x;
  86.    gl_Position.w = 1.0;
  87.    OUT_posXY = gl_Position.xy;
  88.    gl_Position.xy *= atlasScale.xy;
  89.    gl_Position.xy += atlasXOffset;
  90.    
  91.    // Base Texture
  92.    OUT_out_texCoord = vec2(texCoord);
  93.    
  94.    // Alpha Test
  95.    
  96.    // Visibility
  97.    OUT_outVpos = gl_Position;
  98.    
  99.    // Depth (Out)
  100.    OUT_depth = gl_Position.z / gl_Position.w;
  101.    
  102.    gl_Position.y *= -1;
  103. }
Advertisement
RAW Paste Data Copied
Advertisement