noob needs help with shaders

    Jan 14 2020 | 10:49 am
    Hello Forum,
    i am a bloody shader noob who wanted to follow a simple tutorial. but it is much harder than i thought to replicate this example you see on the picture. i would love to have more insight in the following questions 1. i am not sure if this is example is possible in a slab or if it has to be a shader (slabs cannot run vertex programs??) 2. i am not sure if this can be done in version 1.2 gl2 or 1.5 gl3 ? 3. what do i have to write instead of "varying vec3 v_position" ?? 4.does the varying vec3 position has to be declared and bind at the beginning of the shader... 5. is this line necessary?? gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 6. is there a log which describes the use of terms in the different shader environments so that is easier to follow and port any tutorial. for example what is uv in jitter? 7. what are the idiosyncrasies of jitter to other shader environments? thank you so much for your help

    • Jan 14 2020 | 3:08 pm
      Hi, disclaimer first, I'm not a shader specialist. I'm going to talk about gl2. I found to be useful, as a complement to the Max resources. In the Max reference, this page has useful information: Appendix C: The JXS File Format. Now, here is some information that might be useful to you: When you write a shader, it has to include both vertex and fragment programs. In many Max examples, the vertex program is given as a separate file. For instance in the shader co.average.jxs, you see the line <program name="vp" type="vertex" source="sh.passthru.xform.vp.glsl" /> This sh.passthru.xform.vp.glsl file lies in the Max application folder, in Contents/Resources/C74/media/jitter/shaders/shared/glsl Studying it, you'll see what's part of the Max/shader interface (gl_MultiTexCoord0 for instance) and what variables are created in this program, not part of the interface (texcoord0). In other shaders coming with Max, the vertex program is included in the shader. For instance, look at td.lumadisplace.jxs: you'll see two main() programs. I hope that helps, J-F
    • Jan 14 2020 | 5:42 pm
      Found a little time to make a patch. Try this with the attached shader.
      In the shader, the following line is especially interesting, and shows how texdim is a variable you create, but receives the texture dimension as a state. <param name="texdim" type="vec2" state="TEXDIM0" />
    • Jan 15 2020 | 8:50 am
      how can i get this values in a jitter shader??
      how can i get this values in a jitter shader??
      Thank you Jean-Francois for your help. will have a look in the files you pointed out. your example posted above is similar to one i found in the wonderful bookofshaders (somehow the axes are shifted). however my problem is exactly how i get from that example you posted to the example i posted in the picture.... how can i get a model position of a point? basically the example shifts the coordinates so that the middle has the coordinate 0.0 (instead of bottom left = 0.0). that why the color gradient is different. it does it by simply declarying a vec3 position. but i have no clue how i can do that inside the jxs file and i would love to understand what is going on there.
    • Jan 15 2020 | 2:00 pm
      In your code, vec3 stands for a "3-plane" cell, RGB. On line 17, with gl_FragColor = vec4(color, 1.0), the full RGBA is reconstituted: the whole alpha plane is set to 1. In my example, I just didn't use an intermediary vec3, but that really has no consequence on the rendering. With my patch, the gradient progression doesn't look like your picture, but looks quite close to the picture on thebookofshaders page 03. Then, when it comes to which cell has the coordinate (0, 0): in GLSL world, the cell (0,0) is the one in the bottom left corner. In Jitter matrices, it's the one on the top left corner. I can only "guess" that the interface between Jitter & the shaders was designed to keep the Jitter logic of cell numbering. Just use the coordinate "1.-y" instead of "y", like this:
    • Jan 15 2020 | 3:00 pm
      thank you very much for clarifying. i am just wondering if there is a more elegant way to achieve this other than scaling the coordinates... something like snorm for shaders?? i achieved to get the result i wished by this shader:
    • Jan 15 2020 | 9:43 pm
      ...did not read all of the thread but maybe this here helps a little bit
      You can see the shader code of a if you export the code with this message.
      You can see the shader code of a if you export the code with this message.
      Tutorial (gl2) by Federico Foderaro on translation of shader toy code to Jitter.
      ...but with gl3 this became even simpler.