Closed LeeMcQueen closed 3 years ago
add emission
in vec2 tex_cord; in vec3 v_normal; in vec3 v_pos; in vec4 bw; out vec4 color; uniform float time; uniform sampler2D diff_texture; uniform sampler2D emission; vec3 lightPos = vec3(20.0, 55.0, 13.0); void main() { vec3 lightDir = normalize(lightPos - v_pos); float diff = max(dot(v_normal, lightDir), 0.2); vec3 dCol = diff * texture(diff_texture, tex_cord).rgb; vec3 emission = vec3(0.0); if(texture(diff_texture, tex_cord).r == 0.0){ emission = texture(emission, tex_cord).rgb; emission = texture(emission, tex_cord + vec2(0.0, time)).rgb; emission = emission * (sin(time) * 0.5 + 0.5) * 2.0; } color = vec4(dCol + emission, 1.0f); }
纹理无法加载的问题,适应本身的createTexture方法只对应了一个图片 直接使用loader.loadTexture函数
uniform time
rass_computeshader.setFloat("current_time",static_cast(glfwGetTime()));
add emission
version 330 core