Translucent material is not working

Im making a 2d game which uses custom tilemap. I made a material to make some colors transparent \ semi-transparent in textures that are used for tiles, which works with everything except my tilemap fo some reason. The material works as intended with Paper2D tilemap, static meshes, etc. It also works with my tilemap until its mode is set to “Translucent” or “Additive” , after that entire tilemap turns fully transparent

  • Opacity, Source texture nodes doesnt affect result anyhow, tryed setting everything to static values

  • My tilemap in the end uses modified version of UPaperTileMapComponent::RebuildRenderData which is called repeatedly to draw cells, thats the only connection with Paper2D module. I dont want to dive deep in there before i get the nature of whats happening.

As i see issue comes not from material but from my mesh that doesnt meet some requirements for use with translucent materials, which are not clear to me

Any idea what can be the reason?
Ty for any help

upd: heres MRE https://github.com/chuckk589/TranslucentSample

The opacity is greyed out, so you can’t use it. Try plugging the result into opacity mask instead.

Original screenshot was accidently made with blend mode set to masked, in translucent mode theres no opacity mask node. Masked mode works but doesnt fit my needs , because my tiles have shadows and need to be semi transparent.

There isn’t much anyone can do to help you without seeing more, I think. Are you able to post a sample project that reproduces the issue?

Added git link

Ah, it looks like you are using 5.2. I haven’t installed that version, so I wasn’t able to build your solution.

I did take a look at the code though, and I think the way you are fetching the material is a bit odd, and I wonder if that might be the issue.

I would create a class derived from Developer Settings and assign the material in that. Then you could use that to retrieve the material.

Example:

#pragma once

#include "CoreMinimal.h"
#include "Engine/DeveloperSettings.h"
#include "MyDeveloperSettings.generated.h"

class UMaterialInterface;

UCLASS(Config = Game, defaultconfig, meta = (DisplayName = "My Developer Settings"))
class WHATEVER_API UMyDeveloperSettings : public UDeveloperSettings
{
	GENERATED_BODY()

public:
	UMyDeveloperSettings();

	UPROPERTY(Config, EditDefaultsOnly)
		TSoftObjectPtr<UMaterialInterface> defaultTileMaterial;
	
};

Then, in your code, you can grab the material from the CDO:

CurrentBatch->Material = GetDefault<UMyDeveloperSettings>()->defaultTileMaterial.LoadSynchronous();

I haven’t tested this code, but it should work.

Found what causes this. For some reason, translucent material requires both GetMaterial and GetNumMaterials methods of MeshComponent interface to be overridden

1 Like

Ty for help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.