CParticleEvolver_Script $LOCAL$/CParticleEvolver_Script_B000B1E5
{
Expression = $LOCAL$/CCompilerSyntaxNodeExpression_FFFB00B5;
}
CCompilerSyntaxNodeExpression $LOCAL$/CCompilerSyntaxNodeExpression_FFFB00B5
{
EditorInfosPosition = int2(-549, 430);
Expression = "function void Eval()
{
float2 uv = Position.xz * 0.25; // -1,1
float3 viewVec = normalize(uv.xy1);
float3 viewOrigin = float3(0,0,0);
float3 sphereCenter(0,0,5);
float sphereRadius(3.0);
float3 offset = sphereCenter - viewOrigin;
float dist = dot(viewVec, offset);
float c0 = step(dist, 0.0f);
//if (dist > 0)
{
float off2 = dot(offset, offset);
float r2 = sphereRadius * sphereRadius;
float c1 = step(off2, r2);
//if (off2 > r2)
{
float t = r2 - (off2 - dist * dist);
float c2 = step(t, 0.0f);
//if (t >= 0.0f)
{
float intersects = c0 * c1 * c2;
t = dist - sqrt(t * c2);
float3 normal = normalize(viewVec * t - offset);
float3 lighting = float3(0.1,0.11,0.15) + min(1, max(0, dot(normal, normalize(float3(-1,-1,-0.5)))));
float3 background = float3(0.15,0.08,0.05);
Color = (background + (lighting - background) * intersects).xyz1;
}
}
}
// Color = float4(1);
}";
}