Closed ofTheo closed 1 year ago
Hi! Thanks for give it a go!
I run it without issues in a Ubuntu 20.04 (intel) with the integrated intel's GPU card. It makes sense that running it against 3.2 or 4.1 will break because the billboard.vert
uses attributes
.
I'm adding #version 120
to the top of all shaders https://github.com/patriciogonzalezvivo/lygia_of_examples/commit/cd2a963dfa041cd87d195f1a5f72a4e113785da2. Lygia shouldn't be bounded to versions with the caveat that I should add a version check to all functions that do sampling to change the use of texture2D(..)
for texture(...)
. Ex: https://github.com/patriciogonzalezvivo/lygia/blob/main/sample/derivative.glsl#L10-L12
Ahh, good to know. If it’s running on Ubuntu as is, it should work on macOS.
I didn’t see any shader errors with the example out of the box so it might be something fairly straightforward.
Will give it a try and report back! :)
Thanks you for giving it a try. Maybe with the #version 120
at the top... now it works?
Wohoo - got it working!
So for macOS the change needed was to make the billboard.vert
#version 120
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
varying vec4 v_position;
void main() {
// get the texture coordinates
v_texcoord = gl_MultiTexCoord0.xy;
// get the position of the vertex relative to the modelViewProjectionMatrix
v_position = ftransform();
// this is the resulting vertex position
gl_Position = v_position;
}
and then adding
ofScale(width*0.5, height*0.5, 1);
Before the billboard drawing ( as the mesh is otherwise just drawn at -1 to 1 pixel in size )
shader.begin();
shader.setUniformTexture("u_tex0", tex_danny, 0);
shader.setUniformTexture("u_lut", tex_lut, 1);
shader.setUniformTexture("u_moss", tex_moss, 2);
shader.setUniformTexture("u_noise", tex_noise, 3);
shader.setUniformTexture("u_sprite", tex_sprite, 4);
shader.setUniform2f("u_spriteResolution", tex_sprite.getWidth(), tex_sprite.getHeight());
shader.setUniform2f("u_resolution", width, height);
shader.setUniform2f("u_mouse", (float)ofGetMouseX(), (float)ofGetMouseY());
shader.setUniform1f("u_time", ofGetElapsedTimef());
ofScale(width*0.5, height*0.5, 1); //<-- needed so we don't draw a tiny 2pixel x 2pixel square in the screen center
billboard.draw();
shader.end();
YAY! That's awesome! do you mind submitting those as a PR? curious how they will run on my end
Hey @patriciogonzalezvivo I gave the instructions a try with the nightly build of OF on macOS
Nothing seemed to render as is, but I also didn't get any error messages.
Changing the GL version to 3.2 or 4.1 gave me useful error messages, but didn't change the visual output.
This is what I changed the main.cpp to ( otherwise it is using the non-programmable renderer )
then the errors I get:
Is there a specific version of OpenGL I should be setting and if so do we need to inject
#version 150
or#version 410
etc into the lygia shadersWhen I get the shader error I do see a tiny white dot at the screen center - I think it is because the billboard mesh is in normalized coords where as OF would need screen res coords:
ie: instead of this being -1 to 1 it should be -ofGetWidth()/2 to ofGetWidth()/2 https://github.com/patriciogonzalezvivo/lygia_of_examples/blob/main/src/ofApp.cpp#L19-L31
Maybe I am missing something basic though. What was the setup you used?