google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.75k stars 1.88k forks source link

How can the gl_position be modified #7664

Closed wddl closed 7 months ago

wddl commented 7 months ago

Is your feature request related to a problem? Please describe. I need to set gl_Position in the vertex shader, but in device domain cannot change z value through clipSpaceTransform matrix and only in device domain clipSpaceTransform can be set, how can the gl_position be modified? refer to https://github.com/google/filament/issues/7662#issue-2183061747

Describe the solution you'd like engine support modify gl_Position in vertex shader

Describe alternatives you've considered

OS and backend

romainguy commented 7 months ago

Sorry for the miscommunication earlier, clipSpaceTransform is the right parameter to use in device domain. You can see for yourself that it's a mat4 applied to the position written out to gl_Position.

romainguy commented 7 months ago

Note however that we do the following:

if defined(VERTEX_DOMAIN_DEVICE)

// GL convention to inverted DX convention (must happen after clipSpaceTransform)
position.z = position.z * -0.5 + 0.5;

endif

So when you expect a Z position in clip space at 0.0 it will actually be at 0.5 (in the domain 0..1).

wddl commented 7 months ago

@romainguy thank you very much! I understand!