Add Texture Size node to particles
This commit is contained in:
@@ -459,7 +459,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
AlternativeTitles = new string[] { "Lightmap TexCoord" },
|
AlternativeTitles = new string[] { "Lightmap TexCoord" },
|
||||||
Description = "Lightmap UVs",
|
Description = "Lightmap UVs",
|
||||||
Flags = NodeFlags.MaterialGraph,
|
Flags = NodeFlags.MaterialGraph,
|
||||||
Size = new Float2(110, 30),
|
Size = new Float2(110, 20),
|
||||||
Elements = new []
|
Elements = new []
|
||||||
{
|
{
|
||||||
NodeElementArchetype.Factory.Output(0, "UVs", typeof(Float2), 0)
|
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),
|
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;
|
value = Value::Zero;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Texture Size
|
||||||
|
case 24:
|
||||||
|
{
|
||||||
|
// TODO: support sampling textures in CPU particles
|
||||||
|
value = Value::Zero;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ bool ParticleEmitterGPUGenerator::loadTexture(Node* caller, Box* box, const Seri
|
|||||||
Value location = tryGetValue(locationBox, Value::InitForZero(VariantType::Float2));
|
Value location = tryGetValue(locationBox, Value::InitForZero(VariantType::Float2));
|
||||||
|
|
||||||
// Convert into a proper type
|
// Convert into a proper type
|
||||||
if (isCubemap || isVolume || isArray)
|
if (isVolume || isArray)
|
||||||
location = Value::Cast(location, VariantType::Float3);
|
location = Value::Cast(location, VariantType::Float4);
|
||||||
else
|
else
|
||||||
location = Value::Cast(location, VariantType::Float3);
|
location = Value::Cast(location, VariantType::Float3);
|
||||||
|
|
||||||
@@ -332,6 +332,21 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
|||||||
value = box == gradientBox ? gradient : distance;
|
value = box == gradientBox ? gradient : distance;
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user