Skip to content

Broken PR: RangeFog and DensityFog#17355

Closed
EliasHasle wants to merge 1 commit intomrdoob:devfrom
EliasHasle:dev
Closed

Broken PR: RangeFog and DensityFog#17355
EliasHasle wants to merge 1 commit intomrdoob:devfrom
EliasHasle:dev

Conversation

@EliasHasle
Copy link
Copy Markdown
Contributor

@EliasHasle EliasHasle commented Aug 26, 2019

Update: #17592 replaces this PR.

Step 2 of the plan in #17264, adapted to comply with #17420 (comment).

OutdatedAlso correct typescript docstring and misspelled name in test file for FogExp2, as well as docs for standard Fog.

Includes the change to distance-based depth, as well as corrections to better support mediump and avoid unnecessary squaring of a square root. Makes #17316 and #17324 obsolete.

Requires new build, update to the library build used in the editor, doc build, examples build.

I added an example named webgl_geometry_terrain_fog_types, which is basically webgl_geometry_terrain_fog without flight and with a GUI to try different fog setups. Everything seems to work.

Outdated link... Will be updated soonRunning version here: https://eliashasle.github.io/testing/fog_types/ (I think FogExp looks much more natural than the others.)

I have added additional versions of the new example, that test legacy signatures, mediump and lowp, respectively. They should probably be removed before merging.

I am currently struggling with git. Hoping to get everything in order soon.

ResolvedSome examples give an apparently unrelated warning message about using `pow` with negative input. I would really appreciate pointers into what goes wrong, as I am not using `pow` in my code or, as far as I can see, outputting anything that can be negative.

@aardgoose
Copy link
Copy Markdown
Contributor

See #4834 for discussion about the pow() warnings, it's a known issue, and actually a DirectX warning from the Angle translation of shaders.

@EliasHasle EliasHasle force-pushed the dev branch 2 times, most recently from 0e922a8 to 41c0bdb Compare August 26, 2019 16:37
@EliasHasle
Copy link
Copy Markdown
Contributor Author

@aardgoose Good to know it is a known problem, at least. Not introduced by me now.

This is (properly) ready for review.

@EliasHasle
Copy link
Copy Markdown
Contributor Author

@gogoend This PR modifies existing docs and adds a new class FogExp, but adds no corresponding Chinese doc page. I linked to the English version in the list, as a fallback.

Copy link
Copy Markdown
Contributor Author

@EliasHasle EliasHasle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR introduces FogExp in a straightforward, copy-paste, search-replace way.

The additional changes to documentation are needed. They may need a couple more critical eyes on them, though.

It felt natural to include the GLSL optimizations in the same PR. Comment #17316 (comment) by @WestLangley (and the following discussion) applies to this PR too, to the extent that it is a valid point:

Be aware that this PR, as currently-written, is going to significantly change fog behavior for users who use linear fog with and an OrthographicCamera and a negative value for near plane.

I will not be surprised if there are complaints.

I replied that the docs do not seem to allow negative near plane, and that multiplying sign(fogPosition.z) into fogDepth may be a simple solution if negative near is to be supported. I suggest continuing the discussion here, since @supereggbert has expressed support for pursuing my PR as first choice.


float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );

vec3 scaledFogPosition = fogDensity * fogPosition;
Copy link
Copy Markdown
Contributor Author

@EliasHasle EliasHasle Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following lines avoid computing a precisionSafeLength just to square it (which would invariably fail in exactly the same cases where length would fail). Proposed in #17316 (comment)

import { FogExp2 } from '../../../../src/scenes/FogExp2';

export default QUnit.module( 'FoxExp2', () => {
export default QUnit.module( 'FogExp2', () => {
Copy link
Copy Markdown
Contributor Author

@EliasHasle EliasHasle Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a typo that I discovered when doing search&replace. It should be fixed whether or not the PR is merged.

@EliasHasle
Copy link
Copy Markdown
Contributor Author

@titansoftime Would you like to test this? Considering how #14786 ended.

@titansoftime
Copy link
Copy Markdown
Contributor

I can test once merged.

@EliasHasle
Copy link
Copy Markdown
Contributor Author

@mrdoob Any chance of getting a review/merge soon? I try not to nag people too much, but FogExp was accepted by you as a good addition, so I went ahead with implementing it for common good. #17264 (comment) #17264 (comment)

Are any of the additional changes problematic? I think I have justified them well, but I am sure more perspectives may improve them further. @Mugen87 @WestLangley

@EliasHasle
Copy link
Copy Markdown
Contributor Author

EliasHasle commented Sep 26, 2019

@titansoftime

I can test once merged.

Would you like to test the https://eliashasle.github.io/testing/fog_types/ demo on your mobile device before I start refactoring to the new API?

I guess part of the refactoring update will also be to make examples that explicitly set precision mediump and lowp for testing.

@titansoftime
Copy link
Copy Markdown
Contributor

Would you like to test the https://eliashasle.github.io/testing/fog_types/ demo on your mobile device before I start refactoring to the new API?

Looks good. Though without an orbit cam, it's kinda difficult to be sure. Previously I would rotate the camera to reveal "fail areas" in the fog.

@EliasHasle
Copy link
Copy Markdown
Contributor Author

Thanks!

Did you get to test all three fog types and different param values? (dat.gui isn't the most mobile-friendly) And are you certain that you were running in mediump?

without an orbit cam, it's kinda difficult to be sure.

I think I disabled it to avoid some event-handling conflicts.

@EliasHasle EliasHasle changed the title Introduce FogExp with class, GLSL, docs and current applications RangeFog and DensityFog Sep 27, 2019
@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Sep 27, 2019

Um, the diff from the PR looks strange.

image

Can you please rebase it so it is based on the latest commit in dev?

author Elias Hasle <elias.hasle@gmail.com> 1566822048 +0200
committer Elias Hasle <elias.hasle@gmail.com> 1569597690 +0200

RangeFog(color, near, far) and DensityFog(color, density, squared)

Added fog types example.
Currently includes some extra examples that show functionality of legacy signatures, and mediump and lowp operation for all fog types.

Includes the change to distance-based depth, as well as corrections to better support mediump. Makes mrdoob#17316 and mrdoob#17324 obsolete.

Force update when squared is changed.

Fix legacy example and mediump example

Attempted fixes for editor
@EliasHasle
Copy link
Copy Markdown
Contributor Author

This gets worse and worse. Until a few minutes ago there was a monster diff, and now there is no diff at all, and the PR was "merged" and automatically closed. 😛

I will just have to go on...

@EliasHasle EliasHasle reopened this Sep 27, 2019
@EliasHasle EliasHasle changed the title RangeFog and DensityFog Broken PR: RangeFog and DensityFog Sep 27, 2019
@EliasHasle
Copy link
Copy Markdown
Contributor Author

#17592 is a new try... I will clean it up a bit before I mark it as ready for review.

@EliasHasle EliasHasle closed this Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants