Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt-applying textures from angled faces causes crooked textures on target face #1995

Closed
mariteaux opened this issue Jan 25, 2018 · 5 comments
Assignees
Labels
Prio:2 Medium priority: Non crash bugs that impede the user, features that add new functionality. Type:Bug Errors and problems

Comments

@mariteaux
Copy link

If you have an angled face and you apply its texture to another angled face, for whatever reason, the texture will appear angled on the second face, despite not having an angle value. It's a bit hard to explain, so here's a visual.

crooked

I think this only happens on faces angled vertically. If you apply it to a horizontally-angled face, it'll appear fine. The easiest way to recreate it is by making the light posts from E1M1 and applying one side's texture to another side.

I'm using the Valve220 format for what it matters; in J.A.C.K., it reports the original face as being a world normal and the weird crooked face as a face normal.

@mariteaux
Copy link
Author

Since it was suggested that I upload the map you see up there, here's an autosave.

@kduske kduske added Type:Bug Errors and problems Platform:All Prio:2 Medium priority: Non crash bugs that impede the user, features that add new functionality. labels Jan 26, 2018
@kduske kduske added this to the TrenchBroom 2.0.0 milestone Jan 26, 2018
@kduske
Copy link
Collaborator

kduske commented Jan 26, 2018

@ericwa is that an easy fix?

@ericwa
Copy link
Collaborator

ericwa commented Jan 26, 2018

I think it's an easy fix, but I'm not sure exactly what to do.

The alt+click code (ParallelTexCoordSystem::doUpdateNormalWithProjection) is detecting that it needs to rotate the source face's texture vectors by 90 degrees in order for it to project on to the dest face.
It currently rotates about cross(source face normal, dest face normal).

  1. We could try rotating 90 degrees about cross(snapToAxis(source face normal), snapToAxis(dest face normal)).
  2. Another possible behaviour is rotating 90 degrees about one of the two texture vectors (try both rotations, and use the first one where both vectors project onto the dest face normal with a non-zero length).

Aside:
These light fixtures have axis-aligned texture vectors ("World alignment" in Jack/Hammer terminology) rather than being on the face plane ("Face alignment" in Jack). Solution 2 would behave differently depending on whether the texture vectors are in the face plane or not.

For reference here is a test case with the left light fixture using world alignment and the right one using face alignment:
worldalignment_facealignment.map.txt

@ericwa
Copy link
Collaborator

ericwa commented Jan 27, 2018

I went with solution 2, as it feels more correct and will work correctly on rotated brushwork.
I think solution 1 is a hack (also, it might be the case that a face has a valid texture projection, but snapping the face normal to the nearest axis causes the texture projection to be invalid).

However, the caveat is that the plane of the texture axes matters. Alt-click will only give the "desired" result on this light fixture if the source face is world aligned, i.e. the texture axes lie on an axial plane and not the face plane. The provided map file has world-aligned texturing since it was converted from vanilla texturing to valve 220, so alt+click gives the desired result with my PR.

I think we'll need a "reset to world/paraxial" button, and ideally some kind of visualization like JACK has. I'll open a separate issue for that.

@ericwa
Copy link
Collaborator

ericwa commented Jan 27, 2018

Here is a summary of the behaviour with my PR. The PR only touches alt-click.

There are 4 cases: (source face is world-aligned, source face is face-aligned) * (alt-click, shift-alt-click):

altclick

shiftaltclick

kduske pushed a commit that referenced this issue Jan 29, 2018
…1996)

* 1995: rewrite ParallelTexCoordSystem::doUpdateNormalWithProjection

Fixes #1995

* 1995: fix whitespace

* 1995: fix case when the source face is sheared

* 1995: Add test (failing on release/v2.0.0)
@ericwa ericwa closed this as completed Jan 29, 2018
@ghost ghost removed the Status:In Progress label Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio:2 Medium priority: Non crash bugs that impede the user, features that add new functionality. Type:Bug Errors and problems
Projects
None yet
Development

No branches or pull requests

3 participants