HomeiOS Developmentios - Apple Metallic lineStrip how to attract thicker strains

ios – Apple Metallic lineStrip how to attract thicker strains


I’m creating an iOS utility utilizing XCode 14.2, and my deployment goal is iOS 16.2. I’ve an inventory of X,Y, and Z values that I need to draw with Metallic utilizing lineSrip. This works, nevertheless the road that’s drawn is simply too skinny for my functions. I’ve examine varied methods on learn how to thicken the road and I’ve determined to try to attract the identical line many iterations with a small quantity of noise every time to present the looks of a thicker line.

I generate 3 random floats every time by the render loop and ship them to my vertex shader with a uniform. The problem is that the ensuing line appears to be extra periodic than random and extra iterations doesn’t appear to present the looks of a thicker line.

How can I draw thicker strains utilizing this technique? Thanks.

enter image description here
enter image description here

Draw many iterations:

// Draw many iterations
for iteration in 1...1024 {
    scene.observe?.draw(encoder: commandEncoder,
                      modelMatrix: accumulatedRotationMatrix,
                      projectionMatrix: projectionMatrix * viewMatrix,
                      secondsInEpoch: Float(self.epochTime))
}

Random floats:

var jitter = 1.0 / Float(self.screenSizeX) - 1 / Float(self.screenSizeY)
var jitterX = Float.random(in: -jitter...jitter)
var jitterY = Float.random(in: -jitter...jitter)
var jitterZ = Float.random(in: -jitter...jitter)

Vertex Uniform:

struct VertexUniforms {
    
    var viewProjectionMatrix: float4x4
    var modelMatrix: float4x4
    var normalMatrix: float3x3
    var jitterX: Float
    var jitterY: Float
    var jitterZ: Float
    var iteration: Float
}

Draw primitives name:

encoder.drawPrimitives(sort: .lineStrip , vertexStart: 0, vertexCount: vertices.depend / 3)

Vertex shader:

// Calculate the jitter for X/Y/Z
//float subFactor = 0.0099;
float subFactor = 0.0105;
float smallFactorX = (subFactor * uniforms.jitterX);
float smallFactorY = (subFactor * uniforms.jitterY);
float smallFactorZ = (subFactor * uniforms.jitterZ);
if (vertexId % 2 == 0) {
    vertexOut.place.x += (vertexOut.place.x * smallFactorX);
    vertexOut.place.y += (vertexOut.place.y * smallFactorY);
    vertexOut.place.z += (vertexOut.place.z * smallFactorZ);
} else {
    vertexOut.place.x -= (vertexOut.place.x * smallFactorX);
    vertexOut.place.y -= (vertexOut.place.y * smallFactorY);
    vertexOut.place.z -= (vertexOut.place.z * smallFactorZ);
}

return vertexOut;

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments