Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
195 stars 9 forks source link

Projected light cookies can misbehave if viewed at some angles #1939

Closed Zyzyl closed 3 years ago

Zyzyl commented 3 years ago

Describe the bug

Light cookie projections from a spot light can repeat on illuminated surfaces if not viewed head-on. See attached images.

Relevant issues

Nothing obvious.

To Reproduce

1) Create new GridSpace world. 2) With standard developer tooltip create new quad. 3) Inspect quad, reset rotation, set Size to 2x2 in the QuadMesh component 4) Create a child slot under the quad, attach a Light component, and set LightType enum to Spot. 5) Set Z position transform of this slot with Light component to -1. The spot light should be visible on the surface of the quad. 5) Open inventory and spawn: Neos Essentials > Textures & Sprites > Particle Effects > Snowflake.png 6) Drag and drop Snowflake image into the Light Cookie field on the Light component. 7) Look directly at the projected snowflake and move a meter or two backward - projection looks fine, a single snowflake. 8) Rotate the camera and notice that, at more extreme angles, the projection repeats on the quad surface.

This is most obvious if in Screen mode and using a very high FOV (e.g. 120). However, it can also be observed at lower FOVs on Screen mode, and VR (tested on Reverb G2). This appears to be related to the WrapModeU and WrapModeV values on the cookie's StaticTexture2D component.

Expected behavior

Only a single projected image should be visible regardless of viewing angle.

Screenshots / Video

Expected behaviour, viewed head-on Screenshot 2021-04-03 185546

Unexpected behaviour, viewed from an angle Screenshot 2021-04-03 185645

Bug information (please complete the following information):

Reporters:

Zyzyl#1441

InsaneGrox commented 3 years ago

This (probably) isn't a "bug"... more of a problem with how light cookies work with tiled textures... change the texture tiling from repeat to clamp and it should fix the problem. (this should still probably be fixed somehow if it's possible)

Zyzyl commented 3 years ago

Yeah, setting WrapModeU and WrapModeV to Clamp does seem to fix the issue in the case of the snowflake image. Though in other cases weird bugs can still occur e.g. Neos Essentials > Textures & Sprites > UIX 9 Slice Profiles > Ethnocentric_logo_white icon Screenshot 2021-04-03 193355

shadowpanther commented 3 years ago

Yeah, you have to have a clear border around your texture for Clamp to work properly.

Frooxius commented 3 years ago

Yeah @InsaneGrox and @shadowpanther are correct, this is not a bug, you simply need to set the texture wrapping to clamp and make sure there's enough clearance at the borders so the edge pixels don't get stretched like that.