-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Displacement Effect #5573
base: main
Are you sure you want to change the base?
Displacement Effect #5573
Conversation
Would you have any way to use this? Engine example or Editor project? |
Scene for changing transformVS |
Hi @defektu - any thoughts / progress on this? It'd be great to finish off if possible, thanks. |
Sorry @mvaligursky, nowadays are a bit rough workwise. Using heights was possible but uv's and texture is not passing through to shadowpass. (vertex's are displacing but shadow pass won't in this case.) Shadows are rendered through Standart material shader as far as I inspected. Build process won't take the litOption arguments (like I can explore any thoughts in my spare time. |
Today I noticed standart.js has |
Yep, we'll need to adjust this to pass on the height if used as well. |
Also |
I suspect the StandardMaterialOptionsBuilder will need to be updated to generate required options in the shadow pass - probably in _updateSharedOptions, which I think is shared between forward and shadow pass, but not sure now based on you seeing litOptions being undefined. Perhaps update the PR with what you have, using the height texture, and I'll see how I can fix the shadows using your example. |
mesh-displacement example added.
Rolled back previous changes and added |
Somehow I got it working with shared options. I will cleanup everything and send PR. |
This change is for temporary purposes. DISPLACEMENT definition is must (otherwise displacementVS must be created) minimalOptions is disabled due to shaderpass definitions.
Effect fully works for now but noticed env goes blank (weird frustrum culling behaviour causes that) |
I fixed the culling that few days ago .. you're just probably not up to date. |
Yes it is up and running @mvaligursky. UV transformations are not implemented. |
Displacement offset is introduced as material attribute.
Pushed new commit for |
forgot console.log
mesh-displacement example added.
This change is for temporary purposes. DISPLACEMENT definition is must (otherwise displacementVS must be created) minimalOptions is disabled due to shaderpass definitions.
There is |
#endif | ||
vec4 getPosition() { | ||
dModelMatrix = getModelMatrix(); | ||
|
||
#ifdef DISPLACEMENT | ||
vec4 dMapSample = texture2D(texture_heightMap, vertex_texCoord0.xy); | ||
float displacer = dMapSample.r * material_heightMapFactor * 10.; | ||
float displacer = dMapSample.r * material_heightMapFactor * 10. + material_displacementOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the *10
part here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can be removed when material_heightMapFactor
is replaced with new attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more useful for vertex displacement to be implemented as an overridable shader chunk instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, you are the guys to call the shot.
yeah actually, I missed you added an offset too. Sounds good in that case to me. |
useDisplacement flag is setting from `displacementFactor !== 0`
- Fixed useDisplacement flag - Minified mesh-displacement example
Hey @mvaligursky, Updated PR & ready for review. Decided to keep I guess it is good to keep Not a code dev mainly so ignore commit chains <3 |
Added draft docs for attributes. Things to consider:
|
Hey @mvaligursky and @slimbuck - can we sync on this PR? I'm keen to make a decision on what to do with it. |
Is there a way to change heightMap channel for displacement? Another question, will it be viable/common when devs use displacement in combination with parallax? In such case the heightMap textures might be different or the same? |
Hi @Maksims, I think this vertex shader needs some special attributes for offsetting and tiling (which is totally possible). Concurrent options are bound to fragment shader. Don't think that back propagation is not possible unless changing where uniforms defined. Not really experienced with engine, so this needs crosscheck. |
Back from service. Ready to do changes if needed. |
Fixes #5554
@mvaligursky requested PR from #5554 to look into it.
Known issues with PR is in issues thread.
It might be a poor implementation in terms of engine's workflow.
LitShader-forward-proc
&LitShader-ShadowPass_1_0-proc
does not get#define DISPLACEMENT
argument possibly because of my poor implementation.Project file in #5554 works perfectly (probably due to shader chunk rebuilds when replacing a chunk)
Did not implemented checks for implementation cause of draft PR
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.