Skip to content

Conversation

adrien-de-tocqueville
Copy link
Contributor

@adrien-de-tocqueville adrien-de-tocqueville commented Jul 13, 2021

Added a public function to get the sun light from script in HDRP:

var sunLight = (RenderPipelineManager.currentPipeline as HDRenderPipeline).GetMainLight();

or simply

var sunLight = HDRenderPipeline.currentPipeline.GetMainLight();

Note: This will return null until hdrp renders a camera.

A SG node doing the same thing will be added by #5086

@github-actions
Copy link

Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

HDRP
/.yamato%252Fall-hdrp.yml%2523PR_HDRP_2021.2

Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure.

@github-actions github-actions bot added the HDRP label Jul 13, 2021
@github-actions
Copy link

It appears that you made a non-draft PR!
Please convert your PR to draft (button on the right side of the page).
See the PR template for more information.
Thank you!

@adrien-de-tocqueville adrien-de-tocqueville changed the title GetMainLight function Added public GetMainLight API for HDRP Jul 13, 2021
@mert-dev-acc
Copy link

mert-dev-acc commented Jul 13, 2021

@adrien-de-tocqueville This is not just adding an api callback for GetMainLight but replaces/removes GetCurrentSunLight function. Adding a notice about "this replaces GetCurrentSunLight" to change log would be useful, unless adding a stub for


[System.Obsolete]
GetCurrentSunLight()=>GetMainLight() 

is an intention. Otherwise, it can be confusing for the people who upgrade from an earlier version. (Or for the asset devs)

@adrien-de-tocqueville
Copy link
Contributor Author

@merpheus-dev That's right, however, the function GetCurrentSunLight was marked as internal, so it was not accessible to users. So I don't think renaming the function will break users project

@mert-dev-acc
Copy link

Ah sorry, I missed that.
Okay, thank you 🙂

/// Main directional Light for the HD Render Pipeline.
/// </summary>
/// <returns>The main directional Light.</returns>
public Light GetMainLight() { return m_CurrentSunLight; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Guess is weird to expose this Method inside the LightLoop class. Guess it should be in another location, maybe HDRenderPipeline. What are your thought?

Copy link
Contributor Author

@adrien-de-tocqueville adrien-de-tocqueville Jul 21, 2021

Choose a reason for hiding this comment

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

There isn't actually any lightloop class, it's just the name of the file. The function is inside the class HDRenderPipeline, which is partial, so defined in multiple files.

For user it will be accessible this way:

var sunLight = HDRenderPipeline.currentPipeline.GetMainLight();

Copy link
Contributor

Choose a reason for hiding this comment

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

ah right :)

@sebastienlagarde sebastienlagarde merged commit 2d6c49c into master Jul 22, 2021
@sebastienlagarde sebastienlagarde deleted the hd/sun-light-api branch July 22, 2021 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants