Guest User

Untitled

a guest
Nov 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. void vs_main(
  2. // INs
  3. in float3 inPos : POSITION0,
  4. in float2 inTexCoord : TEXCOORD0,
  5. in float3 inNormal : NORMAL0,
  6. in float3 inTangent : TANGENT0,
  7. // OUTs
  8. out float4 outPos : POSITION,
  9. out float2 outTexCoord : TEXCOORD0,
  10. out float4 outLightDir : TEXCOORD1,
  11. // Uniforms
  12. uniform float4x4 worldInvTrans,
  13. uniform float4x4 worldViewProjection,
  14. uniform float terrainTilingFactor,
  15. uniform float3 sunlightDir
  16. )
  17. {
  18. float3 n = mul((float3x3)worldInvTrans, inNormal);
  19. float3 t = mul((float3x3)worldInvTrans, inTangent);
  20. float3 b = cross(n,t);
  21. float3x3 tbnMatrix = float3x3(t.x, b.x, n.x,
  22. t.y, b.y, n.y,
  23. t.z, b.z, n.z);
  24.  
  25. outPos = mul(worldViewProjection, float4(inPos, 1.0f));
  26.  
  27. outTexCoord = inTexCoord * terrainTilingFactor;
  28.  
  29. outLightDir.xyz = -sunlightDir;
  30. outLightDir.xyz = mul(tbnMatrix, outLightDir.xyz);
  31.  
  32. // Store the terrain height at this vertex position.
  33. // The terrain height will be used to generate the terrain texture.
  34. outLightDir.w = inPos.y;
  35. }
Add Comment
Please, Sign In to add comment