Guest User

Untitled

a guest
Feb 23rd, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. [12:53] <ChickenBones> I am now
  2. [12:56] <ChickenBones> I see you've done your research
  3. [12:58] <ChickenBones> I'm just reading the code to be sure
  4. [13:00] <ChickenBones> you are correct, they are not particles
  5. [13:00] <ChickenBones> they are similar to TESRs but to work the best with other translucent objects, they render after everything
  6. [13:01] <ChickenBones> using the RenderWorldLast event (let me check what it's called now)
  7. [13:02] <ChickenBones> so, backfaced culling disabled, blending set to GL_SRC_ALPHA, GL_ONE
  8. [13:02] <ChickenBones> (basically additive)
  9. [13:02] <ChickenBones> lasers work best with additive blending
  10. [13:03] <ChickenBones> the actual laser is made up of 16 quads
  11. [13:03] <ChickenBones> edit, 12 quads
  12. [13:04] <ChickenBones> starting at one end, we draw a square with normal perpendicular to the laser axis, with texture coordinates for the cap
  13. [13:04] <ChickenBones> and colour set to the colour at one end
  14. [13:04] <ChickenBones> then we draw a long stretched quad along the middle
  15. [13:05] <ChickenBones> and then the other square at the end with the other cap
  16. [13:05] <ChickenBones> so that's 3 quads, all in the one plane, running along the laser, but it's not quite a billboard, because it doesn't face the player
  17. [13:05] <ChickenBones> so, copy that 3 times, at 45 degree angles
  18. [13:06] <ChickenBones> these will face at varying angles to the player, depending on how they're lookoing, but that's ok, because with the additive blending, there'll be on average the same amount of geometry facing the player
  19. [13:07] <ChickenBones> and the alpha is tweaked so that the colours and brightness add up appropriately
  20. [13:07] <ChickenBones> now, if that was all, the laser would look rather still and boring, and the individual quads would be obvious up close
  21. [13:07] <ChickenBones> so I spin it along the axis
  22. [13:08] <ChickenBones> that gives it a little bit of a shimmering effect (because the texture isn't perfectly symmetrical, and the area of the quads on the screen changes as they rotate)
  23. [13:08] <ChickenBones> there's 2 other things that combine to create the final look
  24. [13:09] <ChickenBones> they're integrated into the shader
  25. [13:10] <ChickenBones> one is a flow texture, which is just some wrapped noise that is repeated along the length of the laser, and animated to flow with time
  26. [13:10] <ChickenBones> it makes the laser look like power is moving in a direction
  27. [13:10] <ChickenBones> the texture coordinate is calculated in the shader along the length using the texture coordinates
  28. [13:11] <ChickenBones> *vertex coordinates
  29. [13:11] <ChickenBones> and then the blur, fade and bright textures are combined in the shader, with colours calculated
  30. [13:12] <ChickenBones> one last thing, is that the center of the laser looks white, to create that bright effect, when the laser is up close you can see the faded coloured glow
  31. [13:12] <ChickenBones> but as you go futher away, it just beomces a white line, beause the glow is too small and the white becomes dominant
  32. [13:12] <ChickenBones> so the shader calculates the depth in the screen (how far from the camera it is) and moves from white to solid colour for the center bright beam
  33. [13:13] <ChickenBones> that way lasers in the background look like bright coloured lines, rather than white lines, but gain detail as you get near them
  34. [13:13] <ChickenBones> /rant
  35. [13:17] <ChickenBones> it's just all the little things that I added that combine to give the full effect
  36. [13:17] <ChickenBones> at least now you know what they are
Advertisement
Add Comment
Please, Sign In to add comment