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.

Customising Shaders

See original GitHub issue

Currently we can set material.vert and material.frag but that breaks as we also include them in the depth prepass shaders vert: material.vert || DEPTH_PASS_VERT. The correct (needs testing) way is to define all 3 shaders and use preprocessor to support all 3 cases

#ifdef DEPTH_PRE_PASS_ONLY
//copy pre pass shader
#elseif DEPTH_PASS_ONLY
//copy depth shader
#else
//pbr shader
#endif

That’s painful.

Related

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:33 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
vorgcommented, Nov 4, 2022

TLDR: not aiming for fully dynamic gpu compute graphs, just avoiding yet-another-pbr-version-with-this-one-small-change

To answer concern about hooks

naming things is hard, no way I’ll remember these names without checking docs how do we choose where to insert them, do we add one hook after each function/stage?

We could limit it to those touch points VERT_BEFORE_TRANSFORM //after reading from attributes like aNormal VERT_AFTER_TRANSFORM //after skinning skinning, moving to world space etc FRAG_BEFORE_TEXTURES //after reading from varyings and uniforms but before reading from textures FRAG_BEFORE_PBR //before doing lighting math FRAG_AFTER_PBR //after pbr math, allows for individual direct/indirect/emissive overwrites FRAG_END //before writing to screen

What would probably cover 90% of cases for me.

how would they be injected? Shaders are strings so we’d need to clutter shaders with comment/pragma/include/custom syntax #include AFTER_DECLARATIONS + regex replace

Just few. See above

make shaders source function where we pass hooks as options?

No need. Entry points should be limited.

doesn’t allow to modify existing parts of a material

Not desired IMO. Any example use cases?

reliance on vert/frag to have these hooks

To be available only in standard PBR material.

1reaction
pailheadcommented, Feb 14, 2020

I don’t understand the idea of compiling shader graphs on the web. It seems that three’s NodeMaterial is struggling with just that. I really like the scene kit approach to this problem. I think that after you’ve made some graph, in some application, you should generate some GLSL, in three’s case something compatible with it (specific uniform/attribute names and such).

Heh i also didn’t realize i wasn’t on three’s page anymore 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complementary Shaders v4 - Customization - CurseForge
Complementary Shaders v4 is a Minecraft Java Edition shader pack based on Capt Tatsu's "BSL Shaders". The goal of Complementary v4 is being...
Read more >
Custom Shaders | Learn PlayCanvas
This tutorial uses a custom shader on a material to create a dissolve effect in GLSL. Complete project can be found here.
Read more >
Custom shaders | Stride
You can write your own shaders in Visual Studio and use them in material attributes. For example, you can write a shader to...
Read more >
Writing Custom Shaders For Toolbag - Marmoset
Learn how to create custom shaders for Toolbag 3. Replace shading models, add new effects and more!
Read more >
Custom Shaders - LightAct
Custom shaders are loaded with a Custom Shader node. At its most basic configuration, it has just 2 inputs: Resolution and Filepath.
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