Results 1 to 8 of 8
  1. #1
    Iron Guard
    Join Date
    Dec 2009
    Location
    South of cheese
    Posts
    775

    Default How To Reverse Light Vector

    Hello,

    I have the need to reverse a light vector.

    I have a scope on my weapon that when aimed, I want a streaking texture to appear when you look at the sun. I'm using a dot product between my normal map and a light vector and it works perfectly except that it's showing up only when I look directly away from the light. I need to flip it so that it happens when I look at the light instead.

    I tried a thousand combinations of appends, masks, one-minus, subtracts and multiply by -1 in every channel and it all seems to affect the preview on a sphere but doesn't change it in the game. I even tried 3 copies of the light vector, each masked to R, then G, then B and then appended them all together and again, multiplying any of those channels by -1 definitely seems to change the preview on the sphere, but in game it just appears to be making the effect stronger or weaker, not actually changing what angle I have to look at for it to show up. When looking directly at the sun, it's black.

    Light vector seems to be the only options since in 1p view, the scope is locked to the camera so reflection vectors and camera vectors never change when I'm mousing around.

    Again, the desired effect is working flawlessly, just at 180 from the light. I need to flip the yaw and pitch on that vector.

    Any clues? This is a little advanced for me.

    Here's a video of the issue.

    Last edited by Hitpawz; 05-22-2012 at 10:01 PM.

  2. #2
    Veteran
    Join Date
    Sep 2006
    Location
    Newcastle, UK
    Posts
    6,937
    Gamer IDs

    Gamertag: ambershee

    Default

    A vector in the reverse direction is a vector with all components facing in the opposite direction. Before doing your dot-product, normalise it and multiply it by -1.
    - Please do not send me questions regarding programming or implementing things in UDK via Private Message. I do not have time to respond and they are much better answered in the forums. -

  3. #3
    Iron Guard
    Join Date
    Dec 2009
    Location
    South of cheese
    Posts
    775

    Default

    Thanks Ambershee, that makes a lot of sense and actually much cleaner than what I attempted. Unfortunately this isn't solving the problem.

    See on all my attempts to correct this, and using your suggestion, everything is working correctly in the material preview window. The light actually reverses direction with all of these changes. It leads me to believe that it's solved. However, when I get into game, it makes no changes to what's happening on the scope at all. I think this is an issue with the fact that it's an overlay mesh that's attached to the camera. Perhaps this object isn't actually officially "in" the world and isn't updating its angles based on light or reflection vectors. I think I'm going to just ditch the concept and keep the scope clean.

  4. #4
    Iron Guard
    Join Date
    Aug 2009
    Posts
    818

    Default

    I don't have a specific solution but just a thought. You mention that you have a mesh attached to the camera as an overlay to achieve the effect. Is it maybe very close?.. too close?.. maybe it's getting clipped?.

  5. #5
    Iron Guard
    Join Date
    Dec 2009
    Location
    South of cheese
    Posts
    775

    Default

    You can actually see what I'm talking about in the video. The 1st person weapon is attached and placed in the foreground layer. It's close, but it's not clipping.

  6. #6
    Veteran
    Join Date
    Sep 2006
    Location
    Newcastle, UK
    Posts
    6,937
    Gamer IDs

    Gamertag: ambershee

    Default

    It should still accept lighting. I suspect a light environment may perhaps be causing unexpected results.
    - Please do not send me questions regarding programming or implementing things in UDK via Private Message. I do not have time to respond and they are much better answered in the forums. -

  7. #7

    Default

    Your shader is fine (although you could just multiply by a scalar -1, and you'll want to saturate the result of the dot product).

    I'm guessing that your objects are still casting shadows. The self-shadowing would prevent any light from being reflected on the new "front" side of your objects with the light direction reversed.
    Last edited by kirk89; 06-11-2012 at 09:13 PM.

  8. #8
    Veteran
    Join Date
    Sep 2006
    Location
    Newcastle, UK
    Posts
    6,937
    Gamer IDs

    Gamertag: ambershee

    Default

    ^ That sounds very plausible.
    - Please do not send me questions regarding programming or implementing things in UDK via Private Message. I do not have time to respond and they are much better answered in the forums. -


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.