ericwa / ericw-tools

Quake/Hexen 2 Map compiling tools - branch of http://disenchant.net/utils
http://ericwa.github.io/ericw-tools
GNU General Public License v2.0
309 stars 56 forks source link

Phong does not seem to be working right. #405

Open bstordeur opened 5 months ago

bstordeur commented 5 months ago

If you put phong 1 on a cube, you will get some light bleeding on the edges despite the angles being 90 degrees. Visible here, 2 cubes, the one in back has phong 1 and default phong_angle, the one on the front has phong 0, you can see the one in the back has some leaking on the edges. image

I'm using the new compiler, but this seems to also happen in 0.18.2. I'm pretty doubtful this has always been the case...

On a side note, maybe this is "as designed", but if phong is set to 0, but the phong_angle value is set to anything other than the default, the brushes will be phonged. I feel the phong value should take precedence and phong_angle should be ignored on brushes that have phong 0. Example here, a cube with phong 0, but phong_angle set to 45 (again you can see the bug from before) image

4LT commented 5 months ago

You're right, according to the documentation setting _phong 1 should default the _phong_angle to 89 (at that angle or less apply phong shading)

https://ericw-tools.readthedocs.io/en/latest/light.html#bmodel-key-_phong

ericwa commented 5 months ago

Yeah, looks like a bug. I think the _phong 1 might be causing the luxel placement code to wrap the luxels around the cube, regardless of whether each specific edge is phonged, but instead that behaviour should be decided per-edge. Need to check the code to confirm but think that is what’s happening.

For the second issue: agreed it would be more consistent if _phong 0 disable phong even if an explicit phong angle is set.

I wonder if it would break too many maps if setting_phong_angle didn’t automatically enable _phong.. ie if they were decoupled and you had to set _phong 1 and optionally adjust the default phong angle.

thanks for testing the alpha builds!

bstordeur commented 5 months ago

@ericwa I don't think it would break many preexisting maps, because very few mappers actually play with phong angle, mostly just use the boolean, but it's not a huge deal either way I think, could be left unchanged and just mentioned in the documentation that having phong angle force phong on.

I'd like to test the alpha more, but it's kind of hard because of https://github.com/ericwa/ericw-tools/issues/404. :\

ericwa commented 4 months ago

I think the bug in the screenshots is coming from this line in particular:

https://github.com/ericwa/ericw-tools/blob/53850d94ac2c53c80a64da95d05ac2d0a761936b/light/ltface.cc#L1394

For sunlight on a phonged object, even if the luxel normal is pointing away from the sunlight, it's still allowed to receive light (defaulting to 50% of the full amount, as dictated by -anglescale) as long as it has line-of-sight to the sky.

Will need to experiment a bit with different fixes.