need some help with particles!!
hello is anyone willing to help me out for this project I'm working on? I'm pretty lost but I'm basically trying to make an image to particles and I've tried to follow tutorials but for some reason, I think my shader isn't working. I'm also on a Macbook. If you might be able to help please let me know!!
just to be sure, you're probably referring to these tutorials(?):
if so, feel free to post what you have so far, and people can help you from there.
Yeah those are the ones! thats a good idea, I'll post my patch and shader text if someone can check it out, thanks :)
This is what my shader looks like
<jittershader name="ImageToParticlesShader">
<description> </description>
<param name="iPosition" type="vec3" state="POSITION" />
<param name="iVelocity" type="vec3" state="NORMAL" />
<param name="iColor" type="vec4" state="COLOR" />
<param name="iPosOrig" type="vec3" state="VERTEX_ATTR" />
<param name="uMousePos" type="vec3" default="0.00.00.0" />
<param name="uMaxVel" type="float" default="0.04" />
<language name="glsl" version="1.5">
<bind param="iPosition" program="vp" />
<bind param="iVelocity" program="vp" />
<bind param="iColor" program="vp" />
<bind param="iPosOrig" program="vertex">
<bind param="uMousePos" program="vp" />
<bind param="uMaxVel" program="vp" />
<program name="vp" type="vertex">
<![CDATA[
#version 330 core
uniform vec3 uMousePos;
uniform float uMaxVel;
in vec3 iPosition;
in vec3 iVelocity;
in vec4 iColor;
in vec3 iPosOrig;
out vec3 oPosition;
out vec3 oVelocity;
out vec4 oColor;
out vec3 oPosOrig;
void main() {
vec3 dirFromMouse = iPosition - uMousePos;
vec3 normDirFromMouse = normalize(dirFromMouse);
float distFromMouse = length(dirFromMouse);
vec3 acc = normDirFromMouse * 0.0007;
float distFromMouseSqrd = (distFromMouse *2.0) * (distFromMouse*2.0) * 2000.0;
acc /= distFromMouseSqrd + 0.0001;
oVelocity = acc + iVelocity;
oVelocity - clamp(oVelocity, vec3(-uMaxVel), vec3(uMaxVel));
oPosition = iPosition + oVelocity;
oColor = iColor;
oPosOrig = iPosOrig;
}
]]>
</program>
<program name="fp" type="fragment">
<![CDATA[
#version 330 core
void main() {
}
]]>
</program>
</language>
</jittershader>
right away, i see a couple small typos and mistakes:
your [route mouseidle] object is connected by its right-inlet when it should be connected by it's left-inlet

and also, in your shader, couple small typos which don't seem matched to Federico's video:
<bind param="iPosOrig" program="vertex">
can be changed to:
<bind param="iPosOrig" program="vp">
and:
oVelocity - clamp(oVelocity, vec3(-uMaxVel), vec3(uMaxVel));
should be changed(from 'minus' sign to 'equals' sign) to:
oVelocity = clamp(oVelocity, vec3(-uMaxVel), vec3(uMaxVel));
but... i still get a weird error i've never seen before in my Max window given tags all seem matched..(..but probably missing some hidden text/formatting while copy/pasting your code from forums):
jit_xml_document: error reading file at byte offset 1522 / mismatched tag
line (54): language>
jit.gl.shader: error reading shader xml file 'C:/Users/v/Downloads/myShader.jxs'
so i'm still going through it... but you could try making the above changes and see if that works yet for you, and i'll keep looking... (perhaps others will chime in, in the meantime, too)...
also, feel free to post the max window error you get and that can help narrow it down further...
Hey, yes I will fix those errors and see how it looks. I get the same error about reading the shader xml file and then for some reason it goes away after a while so I'm not sure what that means. Thanks so much for your help btw, I really appreciate it!!
This is the error message that I get

ah cool, that error is probably the same/related error:
as [jit.gl.tf @shader myShader] has an attribute "@shader myShader" to link it to the
[jit.gl.shader portal @name myShader @file myShader.jxs] object, it will become disabled since it can't find a working shader to link to(so basically, just have to fix the shader file for that error too).
i found one more typo, there should be spaces between the "0.0"s here:
<param name="uMousePos" type="vec3" default="0.00.00.0" />
so it would be:
<param name="uMousePos" type="vec3" default="0.0 0.0 0.0" />
and now it seems to be working for me... but just to be sure you can start or compare from the same files, here i've uploaded a .zip of the two files together:
i think that's everything up to around the 18minute mark of Federico's 2nd jit.gl.tf related vid, so you can go from there. but if you still have probs, feel free to ask here again... i(or others) will be happy to help 🍻
Yes it works, and it looks amazing, thank you so much for your help!!!