question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using custom material variable to pass parameters to PointLine shaders

See original GitHub issue

I am trying to pass custom parameters (state) to my own point and line shaders, so that I can color the geometry depending on whether it is in a selected/unselected state, etc. For this I tried to use the pfParams field from the PointLineMaterialStruct in the shader for which I did the following steps:

  1. Overrode PointNode.OnCreateRenderCore to create a custom PointLineRenderCore
  2. Defined a render technique using my custom .hlsl shaders and added to a custom EffectsManager class
  3. Defined a custom MaterialCore class with an overridden CreateMaterialVariables method to initialize …
  4. A custom MaterialVariable class in which I overrode the OnInitialPropertyBindings method to add my custom property bindings for the above states

However, this doesn’t seem to work. The CreateMaterialVariables does not seem to be getting invoked in the first place. The above changes can be found here: https://github.com/DynamoDS/Dynamo/pull/10709

Any advice on whether the above approach is correct or any documentation on how to write a custom material variable to pass additional data to the pointline shaders would be really useful.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
holancecommented, Jun 1, 2020

I added an example to show how to use your own constant buffer. #1360 You may need to use the nightly build, otherwise you may have to duplicate the codes for PointMaterialCore/PointMaterialVariables/PointMaterial.

1reaction
holancecommented, May 30, 2020

It depends on whether you want to create a special scene node or material. The point line constant buffer still have 2 empty padding slots you can use.

In PointLineRenderCore, you can add some properties to set PointLineModelStruct padding fields. And then you can use those two fields in your pixel shader.

Or create a new constant buffer for your pixel shader, adds a new ConstantBufferComponent like in MaterialVariableBase. Set values for the constant buffer and bind it during BindMaterialResources to the constant buffer slot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing Shader Variables of Custom Pass Volume's ...
Hello, You can access the material of a pass with the customPasses accessor in the Custom Pass Volume. Each element in this list...
Read more >
Unity Shader Graph - Changing Parameters in Script - YouTube
... to show you how to change a shader's parameters in a C# script. ... the video then please respond with a like...
Read more >
ARKit Tutorial: How to attach Custom Variables to a Metal ...
To use custom input variables in a Metal shader, first declare those variables as input parameters to your Metal shader functions, using an ......
Read more >
Accessing and Modifying Material parameters via script
SetInt, Set an integer value in the material ... shader to another that use the same textures or properties and values will be...
Read more >
Cocos Creator 3.8 Manual - Optional Pass Parameters
Optional Pass Parameters. The parameters in Pass are mainly divided into two parts: Developer-customizable Inspector panel parameter properties .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found