I’m trying to generate a sort of a landscape by an addon I’m currently developing.
Now the addon is correctly working with some parameters and it correctly draw on the viewport.
during the test with a custom shader I’ve noticed that the fragment color is “fixed” with the viewport, it seems that the color is not correctly projected on the model.
I now that I’m lack of knowledge about OpenGL and if someone can help me with this maybe we can help others that have the same problem finding documentation about that.
the addon is hosted on github is a public repository, so you can install it into blender and you can send me pull requests
vlander repo on github
I tried to run the addon but I see only green dots, I can’t generate the geomery to test. Perhaps I don’t know how to use it now.
However by looking at the code I see that you have the
ModelViewProjectionMatrix defined in the shader. This needs to be updated before each draw call, so the vertex shader can transform the vertices correctly.
Now Blender behind the scenes uses a standard 2D viewport matrix, thus is like you are looking at the texture in 2D mode. In custom C++ opengl you would get no screen at all since there would be no default matrix, it should be set explicitly.
To set the uniform matrix camera can be done like this:
Really thanks for your time to investigate on it, the addon is in early stage, i’ve updated the codebase, if you downloaded recently you should see a checkbox here :
if you check those boxes you can see the complete geometry.
The type that works ATM is Quad (you can leave others options there as they are)
I’ve removed the custom shader from the rendering phase since it doesn’t worked. but you can pull again since I’ve pushed now, if you want you can create a PR.
even if i set viewProjectionMatrix as it written in the docs, the shader follows the screen coordinates, maybe i’ve to study better for understand how it works.
Anyway TY again for your help.
I did some testing, unfortunately I could not solve it, but I understand the meaning.
The fragment shader is generated in 2D viewport coordinates. Instead it would use the uv coordinates of the vertices instead.
vec3 pos you would add a
vec2 uv as well. Also have the generator function include uv coordinates for each vertex.
Then there is another part, how to take the 2D procedural texture and glue it on top of the 3D surface. If you had and image it would be easy because you would use the
texture glsl command. I have not figured out this part yet, though there are some resources on this.
I’ve passed the uv coords based on the vertices coordinates and passed the uv inside the cellular function in the fragment shader. now it works thank you again @const, PS the repo is now updated with those edits…
I’m curious about the issues you encountered with the use of the addon… there are some errors in the console? which version of blender are you using?
Nice job, you did it really fast.
I currently use the 3.0.0 version, though I will go now and download the 3.0.1 since I forgot to upgrade.
Once I do some more testing and I found anything else that comes into my mind I will keep you updated.