The same material and the same setting parameters result in different display effects between perspective projection and orthographic projection.
- Dominant language
- C++
- Stars
- 20.5k
- Forks
- 2.3k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 83
Description
⚠️ **Issues not using this template will be systematically closed.**
**Describe the bug**
A clear and concise description of what the bug is.
The same material and the same setting parameters result in different display effects between perspective projection and orthographic projection.
**To Reproduce**
Set perspective projection:
```val width = view.viewport.width
val height = view.viewport.height
val aspect = width.toDouble() / height.toDouble()
camera.setLensProjection(
cameraFocalLength.toDouble(),
aspect,
cameraNear.toDouble(),
cameraFar.toDouble())
```
Set up orthographic projection:
```
val width = view.viewport.width
val height = view.viewport.height
val aspect = width.toDouble() / height.toDouble()
val scale = 2.0
val left = -scale * aspect
val right = scale * aspect
val bottom = -scale
val top = scale
val near = cameraNear.toDouble()
val far = cameraFar.toDouble()
camera.setProjection(
Camera.Projection.ORTHO,
left,
right,
bottom,
top,
near,
far
)
```
Set material parameters:
```
setParameter("ior", 1.517f)
setParameter("roughness", 0.38f)
setParameter("transmission", 1f)
setParameter("reflectance", 0.0f)
```
material.mat:
```
material {
name : TransparentMaterial,
requires : [
uv0
],
shadingModel : lit,
refractionMode : screenspace, // Choose a refraction mode: none, cubemap, or screenspace
refractionType : thin, // Choose refraction type: solid or thin
depthWrite : true, // Changed to true to properly handle depth for refractive materials
parameters : [
{
type : "float3",
name : "baseColor"
},
{
type : "float",
name : "roughness"
},
{
type : "float",
name : "ior"
}
,
{
type : "float",
name : "transmission"
},
{
type : float,
name : reflectance
}
,
{
type : float,
name : microThickness
}
],
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
material.metallic = 0.0;
material.baseColor.rgb = materialParams.baseColor;
material.roughness = materialParams.roughness;
material.ior = materialParams.ior;
material.transmission = materialParams.transmission;
material.reflectance = materialParams.reflectance;
material.microThickness = materialParams.microThickness;
}
}
```
**Expected behavior**
The display effect of orthogonal projection is the same as that of perspective projection.
**Screenshots**
https://github.com/google/filament/assets/6195253/ee60cd2c-2e22-453d-883c-565f77e20e93
https://github.com/google/filament/assets/6195253/0abadbe3-95c4-4726-9288-996f7caa26c0
**Smartphone (please complete the following information):**
- Device: OnePlus 9 5G
- OS: Android13
- filament version 1.49.2
Contributor guide
Research direction
No source files or tests are named. Start by reproducing the discrepancy with the supplied perspective and orthographic projection setup and transparent material parameters on the reported Android configuration. Done means determining and correcting the projection-dependent display difference so both modes produce the expected matching effect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp, kotlin
- Domain
- computer-graphics, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100