You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just pass multiple variables in shader in .mat file and wanna do the computation in gpu and got the position(finalPosition), is there any way I can do something like gl_Position = projectionMatrix * modelViewMatrix * finalPosition; in vertex in .mat file to set render in glsl part.
There are my .mat file like:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I just pass multiple variables in shader in .mat file and wanna do the computation in gpu and got the position(finalPosition), is there any way I can do something like gl_Position = projectionMatrix * modelViewMatrix * finalPosition; in vertex in .mat file to set render in glsl part.
There are my .mat file like:
material {
name: cube,
requires : [ color , custom0, custom1, custom2],
shadingModel : lit,
culling: none,
parameters : [
{
type: float,
name: lineWidth
},
{
type: float,
name: opacity
},
{
type: float4,
name: color
}
]
}
vertex {
// uniform vec4 interpolatedData;
void materialVertex(inout MaterialVertexInputs material) {
// interpolatedData = vec4(0.0, 0.0, 0.0, 1.0);;
float4 position = material.worldPosition;
float3 previous = getCustom0().xyz;
float3 next = getCustom1().xyz;
float side = getCustom2().x;
vec3 dir;
if(position.xyz == next) {
dir = normalize(position.xyz - previous);
} else if (position.xyz == previous) {
dir = normalize(next - position.xyz);
} else {
dir = normalize(normalize(position.xyz - previous) + normalize(next - previous));
}
vec4 normal = vec4(-dir.y, dir.x, 0.0, 1.0);
normal.xy *= 0.5 * materialParams.lineWidth;
vec4 finalPosition = vec4(position.xyz, 1.0);
finalPosition.xy += normal.xy * side;
position = finalPosition;
// material.vertex.xy = (getClipFromViewMatrix() * getViewFromWorldMatrix() * finalPosition).xy;
}
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
// material.baseColor = float4(materialParams.color, 1.0);// getColor();
material.baseColor = getColor();
float4 curColor = materialParams.color;
// vec4 testColor = interpolatedData;
}
}
Thanks so much!
Beta Was this translation helpful? Give feedback.
All reactions