-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
KHR_parallax_mapping #2196
Closed
maierlars
wants to merge
2
commits into
KhronosGroup:main
from
maierlars:KHR_materials_parallax_mapping
+82
−0
Closed
KHR_parallax_mapping #2196
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
extensions/2.0/Khronos/KHR_materials_parallax_mapping/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!-- | ||
Copyright 2015-2022 The Khronos Group Inc. | ||
SPDX-License-Identifier: CC-BY-4.0 | ||
--> | ||
|
||
# KHR\_materials\_parallax\_mapping | ||
|
||
## Contributors | ||
|
||
|
||
## Status | ||
|
||
Draft | ||
|
||
## Dependencies | ||
|
||
Written against the glTF 2.0 spec. | ||
|
||
## Overview | ||
|
||
Many materials provide a height-map that can either be used for real geometry displacement or for parallax-mapping. | ||
This extension defines a way to specify a texture as a height map. | ||
|
||
## glTF Schema Updates | ||
|
||
The height at a given position is calculated by sampling the given texture and using the red channel. The sampled value is then multiplied with the `heightFactor`. | ||
The result is used in an implementation defined way to offset all other texture lookups. (See Resources) | ||
|
||
This extension does _not_ require the geometry of the object this material is applied to to be modified. | ||
|
||
```json | ||
{ | ||
"materials":[ | ||
{ | ||
"extension": { | ||
"KHR_material_parallax_mapping": { | ||
"heightTexture": 0, | ||
"heightFactor": 0.5, | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### JSON Schema | ||
|
||
- [parallaxMapping.schema.json](schema/parallaxMapping.schema.json) | ||
|
||
## Known Implementations | ||
|
||
Although no implementations of this extension are known, these techniques are used widely by the industry. | ||
|
||
## Resources | ||
* [Introduction](https://en.wikipedia.org/wiki/Parallax_mapping) | ||
* [Discussion about different implementations](https://learnopengl.com/Advanced-Lighting/Parallax-Mapping) | ||
* [GPU Gems 2 - Per-Pixel Displacement Mapping with Distance Functions](https://developer.nvidia.com/gpugems/gpugems2/part-i-geometric-complexity/chapter-8-pixel-displacement-mapping-distance-functions) | ||
* [GPU Gems 3 - Relaxed Cone Stepping for Relief Mapping](https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping) | ||
* [SIGGRAPH Asia 2021 - Tessellation-Free Displacement Mapping for Ray Tracing](https://perso.telecom-paristech.fr/boubek/papers/TFDM/) |
23 changes: 23 additions & 0 deletions
23
extensions/2.0/Khronos/KHR_materials_parallax_mapping/schema/parallaxMapping.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema", | ||
"title": "parallaxMapping", | ||
"type": "object", | ||
"description": "Reference to a heightmap for parallax mapping.", | ||
"allOf": [ { "$ref": "glTFChildOfRootProperty.schema.json" } ], | ||
"properties": { | ||
"heightTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "A texture that describes the surface height.", | ||
}, | ||
"heightFactor": { | ||
"type": "number", | ||
"description": "Used to scale the height map.", | ||
"default": 1.0, | ||
"minimum": 0.0, | ||
"gltf_detailedDescription": "This parameter scales the heightmap. A smaller number makes the effect less noticable, a higher number more prominent." | ||
|
||
}, | ||
"extensions": { }, | ||
"extras": { } | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It might be worthwhile to specify the direction of the offset. (is white the topmost height or bottommost height?) Afaik Godot has white goes down, and calls the texture a "depth map"
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.
Good point! I will add that. Would it make sense to fix a certain behavior (i.e. 0 is lowest, 1 is highest) or have it configurable. Translating one to the other is trivial.
Alternatively, one could allow the
heightFactor
to be negative.Not sure what is best. Any opinions/ideas?
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 spent the two last days on the question lol.
Given it's a height map, of course white should be top (when height is at high value, it should be tall etc.). This goes against Godot's implementation (my own, and I imagine most people's), but it's just a question of doing1.0 - height
in the shader, which I doubt would introduce an unacceptable overhead, especially given that parallax mapping algorithm oftentimes sample multiple times at different positions the height map per fragment.The alternative would be to call it
depth_map
. I actually think this might be worth considering. Given that parallax mapping oftentimes (at least unity/unreal/godot) insets the depth, rather that "push out". However, this depends on the implementation. Hull-based parallax mapping algorithms do push out the fake geometry, and would warrant the nameheight_map
.