Skip to content

The same material and the same setting parameters result in different display effects between perspective projection and orthographic projection. #7832

Open

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 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

perspective_projection.mp4
orthographic_projection.mp4

Smartphone (please complete the following information):

  • Device: OnePlus 9 5G
  • OS: Android13
  • filament version 1.49.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions