Simple 4x4 Matrix Constructor + Multiply
float3x3 m = float3x3(-2,-1,2,3,-2,1,1,2,2); float3 output = mul(input,m); return output; float4x4 m = float4x4(x,y,z,w); float4 output = mul(input,m); return output;
Line graph from float2's
uint count = 5; float2 points[6] = { float2(Data1.x,Data1.y), float2(Data1.z,Data1.w), float2(Data2.x,Data2.y), float2(Data2.z,Data2.w), float2(Data3.x,Data3.y), float2(Data3.z,Data3.w) }; float2 v0 = float2(Data1.x,Data1.y); float2 v1 = float2(Data1.z,Data1.w); float4 graphline = float4(0.0,0.0,0.0,0.0); for(int i=0; i<count; i++) { v0 = float2(points[i].x,1-points[i].y) ; v1 = float2(points[i+1].x,1-points[i+1].y); float2 dir = normalize(v0-v1); // Line Mask float j = distance(v0,v1); float k = (distance(pos,v0) + distance(pos,v1)); float mask = 1 - saturate((k - j) * 128); // unit length normal of the line float2 n = float2(-dir.y,dir.x); // signed distance from p to the line float dist = dot(pos-v0, n); // thickness of the line float thickness = 0.001; float col = 1.0-smoothstep(abs(dist), 0.0, thickness); // Output to screen graphline = saturate(graphline + (float4(col,col,col,1.0) * mask)); } return graphline;
Graph line material graph
Related Posts
2 May 2023
3D Coat Learning
Every selector has the potential to have unintended side effects by targeting…