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

Examples: use .texture of input render targets. #8787

Merged
merged 2 commits into from May 3, 2016
Merged

Examples: use .texture of input render targets. #8787

merged 2 commits into from May 3, 2016

Conversation

vanruesc
Copy link
Contributor

@vanruesc vanruesc commented May 2, 2016

Updated examples according to the changes in #8658.

case 'RGBM16': newEnvMap = rgbmCubeRenderTarget; break;
case 'LDR': newEnvMap = ldrCubeRenderTarget ? ldrCubeRenderTarget.texture : undefined; break;
case 'HDR': newEnvMap = hdrCubeRenderTarget ? hdrCubeRenderTarget.texture : undefined; break;
case 'RGBM16': newEnvMap = rgbmCubeRenderTarget ? rgbmCubeRenderTarget.texture : undefined; break;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would try to never assign undefined. Either use null or use if and don't assign at all (I guess not possible here).

Copy link
Owner

Choose a reason for hiding this comment

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

Yes. null is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I usually avoid assigning undefined, too. When I was refactoring this example a couple of weeks ago, I initially did assign null, but then the envMap didn't get rendered. I now tried assigning null again and it works just fine. I think that the issue I encountered back then must have had to do with the PMREM files.

Anyway, I went a little bit further while adjusting this example and moved the logic out of the render loop. As you can see here, the dat.GUI parameters are evaluated in there. Would you prefer a solution that avoids that or do you like the current setup (just with null instead of undefined)?

Copy link
Contributor

Choose a reason for hiding this comment

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

When it's tidying / shows better practice, I guess it's fine. Where's the code?

Just forward-push it in a separate commit? Then you can easily take it out again via git reset HEAD~1 (or git rebase -i <base commit> if it's not the last - I recently wrote a Wiki page that explains changing the history in a little more detail).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't know this was possible inside of PRs, but I guess it makes sense! I've read your Git-guide and it helped me make my first feature branch for this PR :D

Copy link
Contributor

@tschw tschw May 3, 2016

Choose a reason for hiding this comment

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

@vanruesc

Oh, I didn't know this was possible inside of PRs

Moving your branches' HEADs "randomly" is especially useful in PRs! Same happens when you rebase. We wouldn't want Ricardo to do it with dev, though - it'd be trouble :)

@tschw
Copy link
Contributor

tschw commented May 2, 2016

Other than that looks good to me.

Did you test all the examples you edited?

@vanruesc
Copy link
Contributor Author

vanruesc commented May 2, 2016

Did you test all the examples you edited?

Yes, I checked every single example first to find the ones that used render target inputs. Then I applied the changes individually and checked them again.

I also encountered some examples that were already broken. For example, the Sky shader example fails to run because the GridHelper doesn't have public color properties anymore. But that's out of the scope of this PR.

case 'HDR': newEnvMap = hdrCubeRenderTarget.texture; break;
case 'RGBM16': newEnvMap = rgbmCubeRenderTarget.texture; break;

}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I messed up here: it's still necessary to check if the *CubeRenderTarget variables are undefined. Otherwise, selecting a different envMap in the GUI while textures are still loading would result in an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

The updateEnvMap refactor is slightly tidying, but, hey, it's just an example. I'd just take the commit out and replace undefined with null. Then let's merge it :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I agree. I'll try that now.

@tschw
Copy link
Contributor

tschw commented May 3, 2016

Yes, I checked every single example first to find the ones that used render target inputs. Then I applied the changes individually and checked them again.

Good!

I also encountered some examples that were already broken. For example, the Sky shader example fails to run because the GridHelper doesn't have public color properties anymore. But that's out of the scope of this PR.

Yes.

I've read your Git-guide and it helped me make my first feature branch for this PR :D

Oh! Your dev branch was held for granted by the other PR? This explains why it took forever to get merged - Murphy's law typically kicks in mercilessly in that case ;).

@vanruesc
Copy link
Contributor Author

vanruesc commented May 3, 2016

Looks like it worked :) Thanks for the help!

@mrdoob mrdoob merged commit 4fc3af0 into mrdoob:dev May 3, 2016
@mrdoob
Copy link
Owner

mrdoob commented May 3, 2016

Thanks thanks!

@vanruesc vanruesc deleted the rendertarget-texture branch May 4, 2016 09:56
carlosanunes pushed a commit to carlosanunes/three.js that referenced this pull request May 18, 2016
* Examples: use .texture of input render targets.

* Assign null instead of undefined.
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.

None yet

3 participants