使用着色器而非几何体通常是性能提升最大的方法之一,对程序化形状效果惊人。纹理被采样到各个点,每个发射器都是一个类似这样的小着色器程序:
float2 cell = floor(uv * ledGrid);
float2 ledUV = frac(uv * ledGrid) - 0.5;
float d = length(ledUV) - ledRadius;
float emitter = 1.0 - smoothstep(0.0, fwidth(d), d);
float3 color = content.Sample(samplerContent, (cell + 0.5) / ledGrid);
return float4(color * emitter * brightness, 1.0);
评论 (0)