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

Feature Request - Displacement Map #5554

Open
defektu opened this issue Aug 7, 2023 · 2 comments · May be fixed by #5573
Open

Feature Request - Displacement Map #5554

defektu opened this issue Aug 7, 2023 · 2 comments · May be fixed by #5573
Labels
area: graphics Graphics related issue feature request

Comments

@defektu
Copy link
Contributor

defektu commented Aug 7, 2023

Displacement map vertex shader would be a cool feature to implement.

Managed to prepare a project with displacement effect by replacing transformVS.

Here is the Project Link (Working properly with lights and shadows)

Screenshots

Displacement Effect in use:
image

My try on trying to create it in engine: (can provide a PR but it is not working as intended)

  • Tried to implement the effect with if(options.useDisplacement) code+= #define DISPLACEMENT in shader definition.
  • Thus, in vert/transform.js #ifdef DISPLACEMENT seems not picking while rendering shadows.

Screenshots

image

Issues while engine implementation :

  • Displacement state needs to be stated in transformVS. (matrix_normal * sample_texture will throw error otherwise because of undefined texture)
  • This leads to some issues like lights not getting definitions from lit options. Which is causing lighting artifacts.
  • Another approach might be code += displacementVS.

Recommendations:

  • Soft limiting in UI displacementMapFactor within -2, 2 range would be good.
  • Offsetting displacementMapFactorOffset would be good implementation for manually defining boundaries
@mvaligursky
Copy link
Contributor

Hey ... that's pretty exciting. Feel free to create a PR and we can discuss it there perhaps?

@defektu defektu linked a pull request Aug 17, 2023 that will close this issue
@defektu
Copy link
Contributor Author

defektu commented Aug 17, 2023

Created a draft pull request #5573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants