Open Chaosus opened 6 years ago
A week passed and still no comments ? This is serious issue cuz its vastly limit developers to create own custom shaders. Here is the error log for first code sample
shader TextureColor<Texture2D myTexture>
I don't think you can pass textures this way since that means a compile constant. use a simple uniform declaration as a member of the shader like a field in a class rather.
okay - the last sample with cbuffer used texture as member and I simply got a black surface even if I pass correct texture.
I would suggest firing up renderdoc to see if the texture is bound, or has really something else than black. maybe it's the texcoords. first thing first, try outputting a hard white color as a return value instead of a mytexture.sample
@siliconvoodoo Have you tried pass texture yourself ? It simply doesnt work. texcoords is okay(for sample sphere)
- why its empty when I set it in script ? - material.Passes[0].Parameters.Set(TextureColorKeys.MyTexture, MyTexture);
I don't think you can pass textures this way since that means a compile constant. - this is generic, and its the only visible way to pass parameter from Game Studio(not through script). Why Unity does not have such problem and you could simply pass textures from editor ?
https://forums.xenko.com/t/sampling-a-texture-in-a-custom-shader/1225/4
Well that seems to work ^ However, it requires an extra script, which isn't optimal.
If you wish to create a shader where you can set a texture in the game studio, the following code should work:
shader TextureShader: ComputeColor
{
//Not necessarily a texture, it can also be a different shader, a color, etc.
compose ComputeColor MatrixTexture;
override float4 Compute()
{
return MatrixTexture.Compute();
}
};
Hi Xenko team. I tried several ways and it seems to be impossible.
The following code compiles, but fails at runtime -
or
following by this code in scripts
doesnt work either. Please help !