#Passing Texture3D to shader through EntitiesGraphicsSystem

1 messages · Page 1 of 1 (latest)

main lava
#

Is something wrong with my setup?
Setting the shader by doing:

var material = new Material(Shader.Find("Shader Graphs/VoxelShader"));
material.SetTexture("_VoxelTexture", texture.texture);
var materialID = hybridRenderer.RegisterMaterial(material);

Debug.Log(texture.texture.GetPixel(0, 10, 5));
tex = material.GetTexture("_VoxelTexture") as Texture3D;
Debug.Log(tex.GetPixel(0, 10, 5));

EntityManager.SetComponentData(voxelChunkEntity, new MaterialMeshInfo() { MaterialID = materialID, MeshID = meshID });

But the output is just white. As you can see in the console, the color is correctly Color.red.

#

The shader graph is very simple, but even passing R => Base Color(3) displays a white mesh — is the material even being applied?

heavy crystal
#

Is the name of your texture correct in the Shader?

main lava
#

It is, "_VoxelTexture"

#

I've double checked all the names

heavy crystal
#

no idea sorry, we're using 3d textures and they seem to work fine

#

but i didn't set it up and it's all handled by baking instead of being set at rutnime

#

i'll take a quick look at the shader to see if i spot anything of interest

heavy crystal
#

ah that's not going to be much help, handled by a custom function for raymarching

main lava
#

Hmm.. I've tried to initialize the MaterialMeshInfo with a materialID, retrieving that and setting the texture from there. No avail.

var mmi = EntityManager.GetComponentData<MaterialMeshInfo>(voxelChunkEntity);
var hybridRenderer = World.GetExistingSystemManaged<EntitiesGraphicsSystem>();
var material = hybridRenderer.GetMaterial(mmi.MaterialID);
var meshID = hybridRenderer.RegisterMesh(mesh);
material.SetTexture("_VoxelTexture", texture);
main lava
#

Man, I'm having a hard time finding a single resource that illustrates how to set a texture in a material

heavy crystal
#

reason i was asking about your texture name in your shader before was this would usually be called VoxelTexture

#

weird to have the name and reference so different

#

anyway about to test my own copy

#

for curiosity
well i dont know what i expected from the 3d textures for drawing, but it's definitely rendering something but not really what i expected tbh

main lava
#

So with the same setup you managed to have confirm that the texture is at least being applied to the material?

#

Oh and yes, it's correct. I just didn't bother to change the name of the node.

heavy crystal
#

but i'm just applying this to a cube so the texture doesn't make much sense

main lava
#

Are you applying the texture through hybridRenderer?

heavy crystal
#

oh i just baked it

#

i didn't set anything at runtime

#

i was more just curious if this worked at all