Skip to content

Commit

Permalink
switch shaders to 330
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Apr 24, 2024
1 parent e5fb416 commit 6afe3ec
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion modules/ar/src/panda3d-simulator/vpPanda3DBaseRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void vpPanda3DBaseRenderer::initFromParent(std::shared_ptr<PandaFramework> frame
void vpPanda3DBaseRenderer::setupScene()
{
m_renderRoot = m_window->get_render().attach_new_node(m_name);
m_renderRoot.set_antialias(AntialiasAttrib::M_none);
//m_renderRoot.set_antialias(AntialiasAttrib::M_none);
}

void vpPanda3DBaseRenderer::setupCamera()
Expand Down
47 changes: 29 additions & 18 deletions modules/ar/src/panda3d-simulator/vpPanda3DGeometryRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,74 @@
#include <visp3/ar/vpPanda3DGeometryRenderer.h>

const char *vpPanda3DGeometryRenderer::SHADER_VERT_NORMAL_AND_DEPTH_CAMERA = R"shader(
#version 120
#version 330
attribute vec3 p3d_Normal;
attribute vec3 p3d_Vertex;
in vec3 p3d_Normal;
in vec4 p3d_Vertex;
varying vec3 oNormal;
out vec3 oNormal;
uniform mat3 p3d_NormalMatrix;
uniform mat4 p3d_ModelViewMatrix;
uniform mat4 p3d_ModelViewProjectionMatrix;
varying float distToCamera;
out float distToCamera;
void main()
{
gl_Position = ftransform();
//gl_Position = ftransform();
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
// View space is Z-up right handed, flip z and y
oNormal = p3d_NormalMatrix * normalize(p3d_Normal);
oNormal.yz = oNormal.zy;
oNormal.y = -oNormal.y;
vec4 cs_position = p3d_ModelViewMatrix * vec4(p3d_Vertex, 1.0);
vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex;
distToCamera = -cs_position.z;
}
)shader";

const char *vpPanda3DGeometryRenderer::SHADER_VERT_NORMAL_AND_DEPTH_WORLD = R"shader(
#version 120
attribute vec3 p3d_Normal;
attribute vec3 p3d_Vertex;
#version 330
in vec3 p3d_Normal;
in vec4 p3d_Vertex;
uniform mat4 p3d_ModelViewMatrix;
varying vec3 oNormal;
varying float distToCamera;
uniform mat4 p3d_ModelViewProjectionMatrix;
out vec3 oNormal;
out float distToCamera;
void main()
{
gl_Position = ftransform();
//gl_Position = ftransform();
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
oNormal = normalize(p3d_Normal);
oNormal.yz = oNormal.zy;
oNormal.y = -oNormal.y;
vec4 cs_position = p3d_ModelViewMatrix * vec4(p3d_Vertex, 1.0);
vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex;
distToCamera = -cs_position.z;
}
)shader";

const char *vpPanda3DGeometryRenderer::SHADER_FRAG_NORMAL_AND_DEPTH = R"shader(
#version 120
#version 330
in vec3 oNormal;
in float distToCamera;
out vec4 p3d_FragColor;
out vec4 fragColor;
out vec4 p3d_FragData;
varying vec3 oNormal;
varying float distToCamera;
void main()
{
vec3 n = normalize(oNormal);
//if (!gl_FrontFacing)
//n = -n;
gl_FragColor = vec4(n, distToCamera);
p3d_FragData = vec4(n, distToCamera);
}
)shader";

Expand Down
2 changes: 1 addition & 1 deletion modules/ar/src/panda3d-simulator/vpPanda3DRendererSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void vpPanda3DRendererSet::initFramework(bool showWindow)

// load_prc_file_data("", "load-display p3tinydisplay");
// load_prc_file_data("", "color-bits 32 32 32");
// load_prc_file_data("", "depth-bits 16");
load_prc_file_data("", "gl-version 3 2");


if (m_framework.use_count() > 0) {
Expand Down

0 comments on commit 6afe3ec

Please sign in to comment.