Add Texture Size node to particles

This commit is contained in:
Wojtek Figat
2025-06-23 09:31:15 +02:00
parent 6479a3d3c6
commit 867ae2ceaa
3 changed files with 38 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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;
}