StrataSource / Portal-2-Community-Edition

Task tracker for Portal 2: Community Edition
https://www.portal2communityedition.com
148 stars 3 forks source link

Gravity Gun sprites render incorrectly #1106

Open vrad-exe opened 1 year ago

vrad-exe commented 1 year ago

Describe the bug

The sprites on the gravity gun appear to be rendered in the main world space instead of the viewmodel space, causing them draw behind the viewmodel and clip through geometry in front of the player. They also only rotate around the Z axis, making them appear wrong when looking up/down.

https://user-images.githubusercontent.com/19228201/211984995-97f5b0a1-1f0e-420b-96bc-c446beb8f86c.mp4

Issue Map

Any

To Reproduce

  1. Give+use gravity gun on any map
  2. Look up and down
  3. Walk up to a wall

Operating System

Tested on Windows 10

vrad-exe commented 1 year ago

They also seem to be a lot brighter, they might be using the wrong textures or scaled wrong.

AWildErin commented 1 year ago

I noted this on the internal discord but didn't really get much of a response about it. I'm not sure why this happens since the code should be identical to hl2. As for it being brighter, the textures should also be the same, unless portal 2 ships the same textures which I doubt, they'll be loaded from hl2.

vrad-exe commented 1 year ago

Thinking about it, we should maybe just replace this with a particle system so mods can customize it.

AWildErin commented 1 year ago

Probably a good idea to do that

vrad-exe commented 1 year ago

I just checked, it seems to actually be a problem with the materials. In HL2 they all use the sprite shader with $ignorez set, but Portal 2 has changed two of them (glow04_noz.vmt and orangecore2.vmt) to UnlitGeneric without $ignorez set. Unsure how to fix this, since those materials are probably used elsewhere in Portal 2, it might still be best to just make it a particle system - I think that would require adding new copies of the matertials anyway.

AWildErin commented 1 year ago

As you said, a particle system would be better in general for modding. So I think that's the approach we should go with instead of just sprites and w/e it uses

pivotman319-owo commented 1 year ago

I just checked, it seems to actually be a problem with the materials. In HL2 they all use the sprite shader with $ignorez set, but Portal 2 has changed two of them (glow04_noz.vmt and orangecore2.vmt) to UnlitGeneric without $ignorez set. Unsure how to fix this, since those materials are probably used elsewhere in Portal 2, it might still be best to just make it a particle system - I think that would require adding new copies of the matertials anyway.

mega physcannon is unaffected by this issue

image

MyGamepedia commented 1 year ago

I found that this can sometimes cause bugs that can scare unprepared person

https://github.com/StrataSource/Portal-2-Community-Edition/assets/103366204/95767df2-a085-41be-80eb-88766fc2ee0b

vrad-exe commented 1 year ago

That seems like an unrelated bug somehow caused by sprites going through portals

MyGamepedia commented 1 year ago

That seems like an unrelated bug somehow caused by sprites going through portals

this happen in Portal too, but portalgun also use sprites.

vrad-exe commented 1 year ago

The gravity gun renders sprites differently, it renders them in the world space on the serverside, while the portal gun renders them in the viewmodel layer on the client - that's actually the whole reason this issue happens in the first place, that particular sprite glow04_noz is also used by the portal gun in P1, so it was changed to work correctly for viewmodel layer rendering, breaking it when rendered in world space.

So the issue you're referring to is probably caused by world space/serverside sprites passing through portals. Either way it's most likely not related to the issue I originally described here, so you should test it with other things (e.g. env_sprites parented to physics props) and open a new issue for it.

MyGamepedia commented 1 year ago

I found that in old Mapbase builds was same problem with sprites, in latest builds this fine. May be useful to check Mapbase gravity gun code.

Half Life  Source Screenshot 2023 08 19 - 10 16 13 29

vrad-exe commented 1 year ago

We already know what the issue is