Changeset 8744:0e4e4f78fc13 in orange


Ignore:
Timestamp:
08/23/11 17:34:28 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
4f276762ba4b1806f8d90800488b2836b19d3eb4
Message:

Noise texture applied when using 2d symbols

Location:
orange/OrangeWidgets/plot
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/plot/owplot3d.py

    r8743 r8744  
    565565            self.use_fbos = False 
    566566 
     567        img = QImage(os.path.join(os.path.dirname(__file__), 'noise.jpg')) 
     568        self.fractal_texture = self.bindTexture(img) 
     569        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) 
     570        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) 
     571        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT) 
     572        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT) 
     573 
    567574    def resizeGL(self, width, height): 
    568575        pass 
     
    629636            self.symbol_program.setUniformValue(self.symbol_program_translation,    *self.plot_translation) 
    630637            self.symbol_program.setUniformValue(self.symbol_program_force_color,    0., 0., 0., 0.) 
     638            if self.use_2d_symbols: 
     639                self.symbol_program.setUniformValue('texture', 0) 
     640                self.symbol_program.setUniformValue('apply_texture', True) 
     641                self.symbol_program.setUniformValue('screen_size', self.width(), self.height()) 
     642                glActiveTexture(GL_TEXTURE0) 
     643                glBindTexture(GL_TEXTURE_2D, self.fractal_texture) 
     644            else: 
     645                self.symbol_program.setUniformValue('apply_texture', False) 
    631646 
    632647            glEnable(GL_DEPTH_TEST) 
  • orange/OrangeWidgets/plot/symbol.fs

    r8721 r8744  
    22 
    33in vec4 var_color; 
     4uniform bool apply_texture; 
     5uniform sampler2D texture; 
     6uniform vec2 screen_size; 
    47 
    58void main(void) 
    69{ 
    7       gl_FragColor = var_color; 
     10    if (apply_texture) 
     11    { 
     12        gl_FragColor = mix(var_color, texture2D(texture, vec2(10., 10.)*gl_FragCoord.xy/screen_size), 0.3); 
     13    } 
     14    else 
     15    { 
     16        gl_FragColor = var_color; 
     17    } 
    818} 
Note: See TracChangeset for help on using the changeset viewer.