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

PhysicalMaterial works with 2D PixelTexture but not with PixelTexture3D #52

Open
elmkni opened this issue Apr 17, 2023 · 1 comment
Open

Comments

@elmkni
Copy link

elmkni commented Apr 17, 2023

Hi Michalis,

it's again me, Elmar!

I've tested the latest view3dscene-4.3.0-win64-x86_64 from 09-Jan-2023 17:27.

PhysicalMaterial works with 2D PixelTexture but not with PixelTexture3D ...

In the following example the upper-left-front should be emissive orange, but it isn't

#X3D V4.0 utf8

PROFILE Full

Shape {
 appearance Appearance {
  material PhysicalMaterial {
   baseTexture PixelTexture3D {
    image [
     3 2 2 2
     0xFFFFFF 0xFF00FF # white, violet
     0x000000 0xFF0000 # black, red
     0xFFFF00 0x0000FF # yellow, blue
     0x00FF00 0x00FFFF # green, turquoise
    ]
    textureProperties DEF TP TextureProperties {
      minificationFilter "NEAREST_PIXEL"
     magnificationFilter "NEAREST_PIXEL"
     boundaryModeR "CLAMP"
     boundaryModeS "CLAMP"
     boundaryModeT "CLAMP"
    }
   }
   emissiveTexture PixelTexture3D {
    image [
     3 2 2 2
     0x000000 0x000000 # black, black
     0xFFC000 0x000000 # orange, black
     0x000000 0x000000 # black, black
     0x000000 0x000000 # black, black
    ]
    textureProperties USE TP
   }
  }
 }
 geometry Box {}
}

Please help!

Regards,

Elmar

view3dscene_issue_52.zip

@michaliskambi
Copy link
Member

Thanks for the report! I tested with latest view3dscene (9th January was long time ago :) ).

Note: To make emissiveTexture visible in case of PhysicalMaterial or Material, you need to set emissiveColor to something non-zero (like 1 1 1 or 0.5 0.5 0.5). The emissiveTexture colors are multiplied by emissiveColor, and emissiveColor is by default just black for PhysicalMaterial or Material.

That said, even after adding non-zero emissiveColor... we indeed have a bug.

I confirm there's something weird in how 3D textures behave (PixelTexture3D or even just ImageTexture3D) when placed in emissiveTexture of PhysicalMaterial or Material. They work fine in emissiveTexture of UnlitMaterial.

I'm pasting here my testcase (using random3d.dds from https://github.com/castle-engine/demo-models .

#X3D V4.0 utf8

PROFILE Full

Shape {
 appearance Appearance {
  material Material {
   diffuseColor 0 0 0
   specularColor 0 0 0
   emissiveColor 0.5 0.5 0.5
   emissiveTextureMapping "3D"
   emissiveTexture ImageTexture3D {
    #url "/home/michalis/sources/castle-engine/demo-models/textures/marblebrick3d.dds"
    url "/home/michalis/sources/castle-engine/demo-models/textures/random3d.dds"
    textureProperties TextureProperties {
     minificationFilter "NEAREST_PIXEL"
     magnificationFilter "NEAREST_PIXEL"
     boundaryModeR "CLAMP"
     boundaryModeS "CLAMP"
     boundaryModeT "CLAMP"
    }
   }
  }
 }
 geometry Box {
    texCoord TextureCoordinateGenerator {
      mode "BOUNDS3D"
      mapping "3D"
    }
 }
}

Note: I also experimented above with explicitly requesting 3D texture mapping, by

 texCoord TextureCoordinateGenerator {
      mode "BOUNDS3D"
      mapping "3D"
    }

though it should not be necessary. Anyway, it doesn't help.

Give me some time, I'll see can I solve this :)

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

2 participants