Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [12:53] <ChickenBones> I am now
- [12:56] <ChickenBones> I see you've done your research
- [12:58] <ChickenBones> I'm just reading the code to be sure
- [13:00] <ChickenBones> you are correct, they are not particles
- [13:00] <ChickenBones> they are similar to TESRs but to work the best with other translucent objects, they render after everything
- [13:01] <ChickenBones> using the RenderWorldLast event (let me check what it's called now)
- [13:02] <ChickenBones> so, backfaced culling disabled, blending set to GL_SRC_ALPHA, GL_ONE
- [13:02] <ChickenBones> (basically additive)
- [13:02] <ChickenBones> lasers work best with additive blending
- [13:03] <ChickenBones> the actual laser is made up of 16 quads
- [13:03] <ChickenBones> edit, 12 quads
- [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:04] <ChickenBones> and colour set to the colour at one end
- [13:04] <ChickenBones> then we draw a long stretched quad along the middle
- [13:05] <ChickenBones> and then the other square at the end with the other cap
- [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
- [13:05] <ChickenBones> so, copy that 3 times, at 45 degree angles
- [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
- [13:07] <ChickenBones> and the alpha is tweaked so that the colours and brightness add up appropriately
- [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
- [13:07] <ChickenBones> so I spin it along the axis
- [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)
- [13:08] <ChickenBones> there's 2 other things that combine to create the final look
- [13:09] <ChickenBones> they're integrated into the shader
- [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
- [13:10] <ChickenBones> it makes the laser look like power is moving in a direction
- [13:10] <ChickenBones> the texture coordinate is calculated in the shader along the length using the texture coordinates
- [13:11] <ChickenBones> *vertex coordinates
- [13:11] <ChickenBones> and then the blur, fade and bright textures are combined in the shader, with colours calculated
- [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
- [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
- [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
- [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
- [13:13] <ChickenBones> /rant
- [13:17] <ChickenBones> it's just all the little things that I added that combine to give the full effect
- [13:17] <ChickenBones> at least now you know what they are
Advertisement
Add Comment
Please, Sign In to add comment