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

FogExp2 doesn't affect Sprites #6444

Closed
mstrater opened this issue Apr 22, 2015 · 6 comments
Closed

FogExp2 doesn't affect Sprites #6444

mstrater opened this issue Apr 22, 2015 · 6 comments
Labels

Comments

@mstrater
Copy link
Contributor

FogExp2 is not affecting Sprites even when the SpriteMaterial has "fog: true".
To reproduce, add this snippet to the "misc_controls_orbit" example and zoom out until the sprite disappears. It won't fade with the fog.

var mapB = THREE.ImageUtils.loadTexture( "textures/sprite1.png" );
var materialB = new THREE.SpriteMaterial( { map: mapB, color: 0xffffff, fog: true } );
var sprite = new THREE.Sprite( materialB );
sprite.scale.set(50, 50, 50);
scene.add(sprite);

I'm running Windows 7, Chrome 42.0.2311.90 m
I reproduced in r71 and r72dev.

Is this a bug? I didn't see any reference that it's not supposed to work. If this is intentional, maybe there should be a note in the documentation.

Thanks,
Max

@WestLangley
Copy link
Collaborator

Thanks.

I believe the bug is here

'float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );',

fogFactor is declared a float for a second time.

@mstrater
Copy link
Contributor Author

Good catch! That seems to fix it.

mstrater added a commit to mstrater/three.js that referenced this issue Apr 22, 2015
@mstrater
Copy link
Contributor Author

I made a pull request for the fix. #6445
Feel free to make the pull yourself if you prefer, though.
Thanks,
Max

mrdoob added a commit that referenced this issue Apr 22, 2015
Fixing: Sprites aren't affected by FogExp2 (#6444)
@WestLangley
Copy link
Collaborator

Yes, the second declaration of float fogFactor has scope only within the if-statement.

@WestLangley
Copy link
Collaborator

Thanks for the PR.

@mrdoob
Copy link
Owner

mrdoob commented Apr 22, 2015

Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants