In Blender 2.8 I set the material “Base Color” to a texture then export the model to .gltf.
Loading the model in Panda the texture on the model is very dark.
I wrote a shader and if I use Panda’s texture index the model is still dark:
vec4 diffuse = texture(p3d_Texture0, texcoord);
If I load the texture and pass to the shader the texture then looks normal:
vec4 diffuse = texture(image, texcoord);
Is there a setting in Blender or Panda that needs to be set to prevent the model’s texture from being dark?
Panda Code:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Shader
class Game(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.trackball.node().set_pos(0, 30, -5)
base.trackball.node().set_hpr(0, 40, 0)
image = self.loader.load_texture("image/Avatar.png")
cube = self.loader.load_model("models/cube2.gltf")
cube.reparent_to(self.render)
texture_shader = Shader.load(Shader.SL_GLSL, vertex="shaders/texture.vert", fragment="shaders/texture.frag")
cube.set_shader(texture_shader)
cube.set_shader_input('image',image)
game = Game()
game.run()
Shaders:
#version 330
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec4 p3d_Vertex;
in vec2 p3d_MultiTexCoord0;
out vec2 texcoord;
void main(void){
texcoord = p3d_MultiTexCoord0;
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
}
#version 330
uniform sampler2D image;
uniform sampler2D p3d_Texture0;
in vec2 texcoord;
out vec4 color;
void main (void){
//vec4 diffuse = texture(image, texcoord); //Texture looks normal.
vec4 diffuse = texture(p3d_Texture0, texcoord); //Texture looks dark.
color = diffuse;
}
I’m using panda 1.10.4.1