Re: How to move around camera in JOGL 2.0?
Posted by
elect on
Feb 01, 2016; 3:38pm
URL: https://forum.jogamp.org/How-to-move-around-camera-in-JOGL-2-0-tp4036081p4036097.html
Yep, if you want it run, you have to include jglm and jgli, otherwise just look at the most important parts for you, that are:
- the
sampler init (if you don't plan to use a sampler, you need to set all those parameters on the textures itself)
- the texture
allocation and loading- the
fragment shader, here you have to pass a vec4 representing the direction you are looking at.
To calculate the direction you are looking at, you have to do something similar in the
vertex shader. After calculating the well known and mandatory gl_Position, you should
vec3 p = mv3x3 * vec3(position, 0.0);
here you do the almost the same, you need the position in world space, so your mv3x3 is
mat3 mv3x3 = mat3(transform.mv);
and you need just the orientation, so a mat3 is sufficient. Then he plays with the reflection, but this has no interest for your case. Just calculate the vector you are looking at in the i-th vertex as
normalize(p - transform.camera);
and pass it directly to the fragment shader
and you are done ;)