Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
render: Bypass texture rendering when a model uses the null texture.
Browse files Browse the repository at this point in the history
* data/shaders/default-fragment.glsl (use_texture): New uniform.
  (main): Skip texture rendering when 'use_texture' is false.
* sly/render/model.scm (draw-model): Set 'use_texture' uniform before
  rendering.
* sly/render/shader.scm (load-default-shader): Register 'use_texture'
  uniform.
  • Loading branch information
David Thompson committed Jun 6, 2015
1 parent bef0b89 commit de2abeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions data/shaders/default-fragment.glsl
Expand Up @@ -3,7 +3,12 @@
in vec2 frag_tex;
uniform vec4 color;
uniform sampler2D color_texture;
uniform bool use_texture;

void main (void) {
if(use_texture) {
gl_FragColor = texture2D(color_texture, frag_tex) * color;
} else {
gl_FragColor = color;
}
}
1 change: 1 addition & 0 deletions sly/render/model.scm
Expand Up @@ -155,6 +155,7 @@ CONTEXT."
;; TODO: Support user-defined uniforms.
(uniform-set! shader "mvp" (render-context-transform context))
(uniform-set! shader "color" color)
(uniform-set! shader "use_texture" (not (texture-null? texture)))
(glDrawElements (begin-mode triangles)
(mesh-length mesh)
(data-type unsigned-int)
Expand Down
2 changes: 1 addition & 1 deletion sly/render/shader.scm
Expand Up @@ -305,7 +305,7 @@ VERTEX-SHADER and FRAGMENT-SHADER."
"/shaders/default-vertex.glsl")
(string-append %pkgdatadir
"/shaders/default-fragment.glsl")
'("mvp" "color")
'("mvp" "color" "use_texture")
'("position" "tex")))))

;;;
Expand Down

0 comments on commit de2abeb

Please sign in to comment.