Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Simod · Oct 30, 2016 at 05:40 PM · rendererpipelinenative plugincommandbuffer

Using CommandBuffer how to draw Directional Light shadows in native plugin?

Hi there.

Here is task: draw an object from a native plugin with shadows.

What is done: I got a prototype of a working shadows for a Point Light. All rendering is done by a native plugin

What is required: Do the same, but using Directional Light

Two lights are rendering into "shadow map" differently: Point Light renders into CubeMap. Directional light (seems) renders into 2D map

In case of Point Light and CubeMap, you have to select each side of a CubeMap and make a render. T.e. six passes in total.

 // Current render target at the time of the Light rendering is the shadow map
 RenderTargetIdentifier rt = new RenderTargetIdentifier (BuiltinRenderTextureType.CurrentActive);
 
 // Selects one side ...
 this.buffer__.SetRenderTarget (rt, 0, CubemapFace.PositiveX);
 this.buffer__.IssuePluginEvent (RenderFunc, 0);
 
 // Selects second side ...
 this.buffer__.SetRenderTarget (rt, 0, CubemapFace.PositiveY);
 this.buffer__.IssuePluginEvent (RenderFunc, 0);
 
 // More sides here...
 // ...
 
 // Ads command buffer to the light
 this.light__.AddCommandBuffer (this.event__, this.buffer__);

But In case of Directional light it splits 2D map into four pieces (look like mipmaps), and renders on every piece separately. You can clean see this technique by Frame Debugger in the Unity

Question is how can I do the same in the native plugin? It seems like Unity API does not have such control.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ScottieBizzle · Oct 31, 2016 at 02:33 PM 0
Share

I'd love to know this too. I'm trying to render shadows for my procedural mesh ( fur / hair ) using command buffers and adding them to lights with LightEvent.AfterShadow$$anonymous$$ap. It renders into the last target, but I have no way of knowing what the cascade offsets and stuff is so I can manually reset them and the same for point lights and their shadow cube map faces, also the view matrix needs to be reset for each face, among other things. What Unity needs for me is a LightEvent.AfterShadow$$anonymous$$ap_Cascade event for directional lights and a LightEvent.AfterShadow$$anonymous$$ap_CubeFace for a point lights so that all the proper states and shader constants are still setup.

Did you have to set the view matrices manually for each cube face?

avatar image Simod ScottieBizzle · Nov 01, 2016 at 03:58 PM 0
Share

Hi Scottie

Your reply is a comment not an answer. You may need to change this. But yes, technically to render a point light shadows you have to make six passes and setup matrices accordingly.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to use CommandBuffer with RenderPipelineManager to draw a material to fullscreen? 0 Answers

Question about batching and SRP 2 Answers

URP Scene Mentions Built In Renderer 0 Answers

How do you use the "state" with a Rendering CommandBuffer? 0 Answers

Universal Render Pipeline Post processing breaks transparent camera background? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges