• Non ci sono risultati.

Impostare variabili “uniform” • Passare un valore uniform: uniform: uniform: uniform:

N/A
N/A
Protected

Academic year: 2021

Condividi "Impostare variabili “uniform” • Passare un valore uniform: uniform: uniform: uniform:"

Copied!
1
0
0

Testo completo

(1)

Impostare variabili “uniform”

• Passare un valore uniform: uniform: uniform: uniform:

glUniform{1,2,3,4}{f,i}{v}(location, valore/i)

• Location: Location: Location: Location:

– l' "indirizzo" della variabile uniform che vogliamo impostare.

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

impostare.

– Come si trova?

GLint glGetUniformLocation(

GLuint program, const GLchar *name )

dove name è il nome della variabile

Impostare variabili “attribute”

• Simile

• Trovare l’indice:

int glGetAttribLocation(

GLuint program, const GLchar *name

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

GLuint program, const GLchar *name )

• Impostare il valore di un attributo:

glVertexAttrib{1,2,3,4}{f,i}{v}

(location, valore/i) e tutti i vertici che mando avranno quell’attributo

Accesso alle texture

• Funzioni di GLSL:

vec4 texture[123]D ( sampler[123]D sampler, vec[1234] coord

[, float mipmapbias]

)

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

)

• il primo parametro specifica

da quale texture unit texture unit texture unit texture unit vada letto il valore

• Cos’è una texture unit ?

Multitexturing

• Ogni texture unit è una tessitura attiva

(da cui il fragment shder può fare texture lookup)

• ha il proprio “stato” (parametri di sampling, environment, texture matrix)

• con la funzione:

glActiveTexture(GL_TEXTUREi) con i =0,1,2,..

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

glActiveTexture(GL_TEXTUREi) con i =0,1,2,..

si dichiara che tutti comandi seguenti si riferiranno alla texture unit i

(default alla texture 0).

Multitexturing

• Nel fragment (o vertex*) shader la texture unit e' una variabile uniforme (di tipo: “sampler”)

• Dall'applicazione, va assegnata ad un numero intero che corrisponde al numero della tessitura attiva

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

attiva

* dallo shader model 2.0 le textures sono accedibili anche dal vertex shader!

– (quali applicazioni?)

Esempio

• Se un fragment shader accede:

– ad una rgbmap per il colore

– ad una shininess map per il coeff. di glossiness – ad una normal map per la normale

utilizza 3 texture units

M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a

utilizza 3 texture units

Riferimenti

Documenti correlati

To yield more and more observable constraints to theoretical models of giant planet migration and star-planet tidal interactions, it is important to i) determine accurate orbital

The paper describes every step of the repair process: from 3D scanning of the damaged component to the finishing operation.. This repair method can be applied to extend the life of

Note that, with the proposed approach it is possible to sample in a 4-dimensional space for the locomotion primitive and in a 3-dimensional space for the manipulation one in- stead

Importance of sexual function assessment in multidimensional evalua- tion of AGHD patients: Baseline results from the management of adult growth hormone deficiency (MAGHD) study.

The aim of this study was to evaluate whether modulation of endogenous heme may affect cyclooxygenase-2 expression and activity, taking advantage of two different approaches able

We have analysed the Planck maps of the Stokes parameters at high Galactic latitudes over the sky area b < −60 ◦ , which is well suited for describing the Galactic magnetic

Comparison of the mean chemical composition values (g/kg), in vitro apparent digestibility (DMD, g/kg) and gross energy (GE, MJ/kg) of the leaves and of the green pruning residues

Alcuni tra i casi studio sono proget- ti di grande successo, come ad esempio la serra fotovoltaica dell’Ospedale pediatrico Meyer a Firenze (primo classificato nel programma