Skip to content
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

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

Open
yuxinabc opened this issue May 7, 2024 · 3 comments

Comments

@yuxinabc
Copy link

yuxinabc commented May 7, 2024

⚠️ 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
@romainguy
Copy link
Collaborator

Looks like a problem with refraction

@yuxinabc
Copy link
Author

yuxinabc commented May 7, 2024

Looks like a problem with refraction

The material becomes 100% transparent under orthogonal projection, as if it turned into air. How should I set the refraction?

@yuxinabc yuxinabc closed this as completed May 7, 2024
@yuxinabc yuxinabc reopened this May 7, 2024
@pixelflinger
Copy link
Collaborator

I'm not sure refraction works with an ortho projection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants