Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Transparency in Craft

A question about transparency: I have a png image that includes some transparency, and shows as such if I render it as a sprite (i.e. I can see the background where things are supposed to be transparent). On the other hand, if I map it to a material for a craft entity, then what should be transparent comes across as black. I figure this has to do with the base material I’m choosing (i.e. any of the built-in options in craft.material) and all that that implies (shaders, etc.). So, what is the correct way to texture an entity with an image that includes some transparent sections? Thanks!

Tagged:

Comments

  • edited October 30 Posts: 616
    @iam3o5am have you tried looking at this example physics demo in Craft by @dave1707 .

    physix

    https://codea.io/talk/discussion/8800/craft-physics-example#latest
  • Posts: 39

    Thanks @Bri_G - I hadn't seen that example. As always, nice work @dave1707 ! So in that demo the opacity of the material is set. That makes the entire texture have the given level of opacity. I just want the alpha level of the original texture images to be respected.

    As a concrete example, imagine I have a small image of a yellow sun, where the yellow circle has alpha = 255, and the alpha level around the sun set to 0, so as not to see the square outline of the image. I then would want to map this image onto a craft.material.plane. I want to see the sun only, and whatever is behind it come through around it.

  • Posts: 616

    @iam3o5am - under normal circumstances I think you would be able to achieve that with a shader replacing a colour in the image with the colour behind it. This may not operate at the moment within Craft, I understand there are a few aspects with shaders to follow later.

    But there is a simpler way - make an image of your sun in a sprite with a colourless background, several art packages can do this. Save as a png with opacity included and you can fade/enhance the sun image as you wish with the a clear background.

  • Posts: 39
    Thanks @Bri_G - thats what Iv'e been able to do so far, but that limits me to 2D placement, and not in 3D world coordinates, as a craft entity would allow. I suppose i could just work out the transformation from 3D to 2D space and give the impression of proper 3D placement.

    Thanks for the ideas! I'll keep tossing it around and see what I come up with.
  • Posts: 299

    Try putting material.blendMode = NORMAL on the entity.

  • Posts: 39

    Bingo. So simple! Thanks @LoopSpace ! That did the trick. Time to go do my blendMode homework...

Sign In or Register to comment.