Skip to content

GLTF Glass Materials Render Without Volume on Windows/OpenGL (v1.68.4) #9630

@0xcode-lasagna

Description

@0xcode-lasagna

Description:

I'm experiencing an issue where GLTF models with glass materials appear to render without any volume-they look flat or like dull plastic-when using Filament 1.68.4 on Windows with OpenGL as the backend.

Platform:

Windows
OpenGL backend
Filament version: 1.68.4

Repro Steps:

  1. Apply graphics setting to AR's View, that renders GLTF model (attached below).
  2. Render an AR model and feed to a texture using an image.mat material (attached below).
  3. Use this texture as a parameter for another on-screen material.
  4. Use the Dragon Attenuation model for testing.
  5. The rendering pipeline uses multiple render targets in the same render loop.

Expected Behavior:

The glass material should appear volumetric, as it does in the minimal boilerplate project (it uses the same settings, and the model renders correctly there.).

Image

Actual Behavior:

The glass material looks flat, similar to dull plastic.
This effect can also be reproduced by setting hasVolume, hasVolumeThicknessTexture, and hasDispersion to false in the filament::gltfio::MaterialKey config.
setScreenSpaceRefractionEnabled is enabled for the view.
The same behavior occurs with both Ubershader and JIT material providers.

Image

Additional Info:

GraphicsSettings

struct GraphicsSettings
{
  // standalone View settings
  filament::AntiAliasing antiAliasing = filament::AntiAliasing::FXAA;
  filament::Dithering dithering = filament::Dithering::TEMPORAL;
  filament::ShadowType shadowType = filament::ShadowType::PCF;
  bool postProcessingEnabled = true;

  // View Options (sorted)
  filament::AmbientOcclusionOptions ssao = { .enabled = true };
  filament::ScreenSpaceReflectionsOptions screenSpaceReflections = { .enabled = true };
  filament::BloomOptions bloom = {
    .strength = 1.0f,
    .enabled = true,
    .lensFlare = true,
    .ghostThreshold = 2.f,
    .haloThreshold = 2.f,
  };

  filament::DepthOfFieldOptions dof = { .enabled = true, .nativeResolution = true };
  filament::DynamicResolutionOptions dsr = { .minScale = { 1.f, 1.f },
                                             .maxScale = { 2.0f, 2.0f },
                                             .sharpness = 0.9f,
                                             .enabled = false,
                                             .quality = filament::QualityLevel::LOW };
  filament::FogOptions fog;
  // #  if !defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
  filament::MultiSampleAntiAliasingOptions msaa = { .enabled = true, .sampleCount = 4 };
  // #  else
  //   filament::MultiSampleAntiAliasingOptions msaa = { .enabled = false };
  // #  endif
  filament::RenderQuality renderQuality;
  filament::TemporalAntiAliasingOptions taa = { .enabled = true };
  filament::VignetteOptions vignette = { .enabled = false };
  filament::VsmShadowOptions vsmShadowOptions = { .anisotropy = 0 };
  filament::GuardBandOptions guardBand;
  filament::BlendMode blendMode = filament::BlendMode::TRANSLUCENT;

  filament::View* Apply(filament::View* view) const;
};

// Actual graphics settings for AR model rendering
{
  .postProcessingEnabled = true,
  .ssao = { .enabled = false },
  .screenSpaceReflections = { .enabled = false },
  .bloom = {
    .dirtStrength = 1.0f,
    .strength = 1.0f,
    .blendMode = filament::BloomOptions::BlendMode::INTERPOLATE,
    .threshold = true,
    .enabled = true,
    .lensFlare = false,
    .chromaticAberration = 0.03f,
    .ghostThreshold = 0.000000002f,
    .haloThreshold = 0.000000002f,
  },
  .dof = { .enabled = false, .nativeResolution = true },
  .dsr = { .minScale = { 1.f, 1.f }, .maxScale = { 2.0f, 2.0f }, .sharpness = 0.9f, .enabled = false, .quality = filament::QualityLevel::LOW },
  .fog = {},
  .msaa = { .enabled = true, .sampleCount = 4 },
  .renderQuality = {},
  .taa = { .enabled = false },
  .vignette = { .enabled = false },
  .vsmShadowOptions = { .anisotropy = 0 },
  .guardBand = {}
},

image.mat

material {
    name : image,
    parameters : [
        {
            type : ${FEED_SAMPLER},
            name : image
        }
    ],
    requires : [
        uv0
    ],
    flipUV : true,
    depthWrite : false,
    colorWrite : true,
    shadingModel : unlit,
	variantFilter : [ directionalLighting, dynamicLighting, shadowReceiver, skinning, fog, vsm ],
    culling: none,
    depthCulling : false
}


fragment {
#if USE_SAMPLER_EXTERNAL
    vec3 sRGB_to_linear(highp vec3 color) {
	     return  vec3(
            color.r <= 0.04045 ? color.r / 12.92 : pow((color.r + 0.055) / 1.055, 2.4),
             color.g <= 0.04045 ? color.g / 12.92 : pow((color.g + 0.055) / 1.055, 2.4),
             color.b <= 0.04045 ? color.b / 12.92 : pow((color.b + 0.055) / 1.055, 2.4)
         );
        //return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2));
        //return color;
    }
#endif
    
	vec3 imageColor(highp vec2 uv) {
        uv = vec2(uv.s, 1.0 - uv.t);
        // We need to convert extneral texture to linear space 
        // (in case of internal texture - we do it with hardware automatically based RGB8_A8 format)
#if USE_SAMPLER_EXTERNAL
            return sRGB_to_linear(texture(materialParams_image, uv).rgb);
#else
            return texture(materialParams_image, uv).rgb;
#endif
	}
	
    void material(inout MaterialInputs material) {
        prepareMaterial(material);
        highp vec2 imageUV = getUV0();
        if (imageUV.x > 0.0 && imageUV.y > 0.0 && imageUV.x < 1.0 && imageUV.y < 1.0 ) {
            material.baseColor.rgb = imageColor(imageUV);
            material.baseColor.a = 1.0;
        }else{
            material.baseColor = vec4(0.0, 0.0, 0.0, 1.0);
        }
    }
}

I'm happy to provide code snippets or further details if needed.

Question:

Is there something I'm missing in the pipeline or material configuration that could cause this? Any hints or suggestions would be greatly appreciated!

Metadata

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