Add Texture Size node to particles
This commit is contained in:
@@ -459,7 +459,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
AlternativeTitles = new string[] { "Lightmap TexCoord" },
|
||||
Description = "Lightmap UVs",
|
||||
Flags = NodeFlags.MaterialGraph,
|
||||
Size = new Float2(110, 30),
|
||||
Size = new Float2(110, 20),
|
||||
Elements = new []
|
||||
{
|
||||
NodeElementArchetype.Factory.Output(0, "UVs", typeof(Float2), 0)
|
||||
@@ -493,6 +493,19 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
NodeElementArchetype.Factory.Bool(190, Surface.Constants.LayoutOffsetY * 4, 4),
|
||||
}
|
||||
},
|
||||
new NodeArchetype
|
||||
{
|
||||
TypeID = 24,
|
||||
Title = "Texture Size",
|
||||
Description = "Gets the size of the texture (in pixels). If texture is during streaming, then returns size of the highest resident mip.",
|
||||
Flags = NodeFlags.ParticleEmitterGraph,
|
||||
Size = new Float2(160, 20),
|
||||
Elements = new[]
|
||||
{
|
||||
NodeElementArchetype.Factory.Input(0, "Texture", true, typeof(FlaxEngine.Object), 0),
|
||||
NodeElementArchetype.Factory.Output(0, "Size", typeof(Float3), 1),
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,13 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupTextures(Box* box, Node* node,
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Texture Size
|
||||
case 24:
|
||||
{
|
||||
// TODO: support sampling textures in CPU particles
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ bool ParticleEmitterGPUGenerator::loadTexture(Node* caller, Box* box, const Seri
|
||||
Value location = tryGetValue(locationBox, Value::InitForZero(VariantType::Float2));
|
||||
|
||||
// Convert into a proper type
|
||||
if (isCubemap || isVolume || isArray)
|
||||
location = Value::Cast(location, VariantType::Float3);
|
||||
if (isVolume || isArray)
|
||||
location = Value::Cast(location, VariantType::Float4);
|
||||
else
|
||||
location = Value::Cast(location, VariantType::Float3);
|
||||
|
||||
@@ -332,6 +332,21 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
||||
value = box == gradientBox ? gradient : distance;
|
||||
break;
|
||||
}
|
||||
// Texture Size
|
||||
case 24:
|
||||
{
|
||||
value = Value::Zero;
|
||||
auto textureBox = node->GetBox(0);
|
||||
if (!textureBox->HasConnection())
|
||||
break;
|
||||
const auto texture = eatBox(textureBox->GetParent<Node>(), textureBox->FirstConnection());
|
||||
const auto textureParam = findParam(texture.Value);
|
||||
if (!textureParam)
|
||||
break;
|
||||
value = writeLocal(VariantType::Float2, node);
|
||||
_writer.Write(TEXT("\t{0}.GetDimensions({1}.x, {1}.y);\n"), textureParam->ShaderName, value.Value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user