Herramientas de usuario

Herramientas del sitio


fw:ogl:graphics

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
fw:ogl:graphics [2013/02/10 18:19]
alfred [Shaders]
fw:ogl:graphics [2020/05/09 09:25] (actual)
Línea 15: Línea 15:
 ==== Shaders ==== ==== Shaders ====
 Los shaders son programas que se ejecutan sobre el procesador gráfico y son utilizados para modificar los efectos de luz, sombras y producir efectos de postprocesado especiales. Proporcionan gran flexibilidad a la hora de programar la GPU.  Los shaders son programas que se ejecutan sobre el procesador gráfico y son utilizados para modificar los efectos de luz, sombras y producir efectos de postprocesado especiales. Proporcionan gran flexibilidad a la hora de programar la GPU. 
 +
 === Tipos de shaders === === Tipos de shaders ===
-  * Vertex shaders +  ​* **Vertex shaders**: Se ejecutan por cada vérticeSu propósito es transformar cada vértice 3d en una coordenada 2d. Dan muchas facilidades para manipular sus propiedades ​(posición, color y texturaaunque no crear nuevos vértices 
-Vertex shaders are run once for each vertex given to the graphics processorThe purpose is to transform each vertex'​s 3D position in virtual space to the 2D coordinate at which it appears on the screen ​(as well as a depth value for the Z-buffer). Vertex ​shaders ​can manipulate properties such as positioncolorand texture coordinate, but cannot create new verticesThe output of the vertex ​shader goes to the next stage in the pipelinewhich is either a geometry shader if presentor the pixel shader and rasterizer otherwiseVertex shaders can enable powerful ​control ​over the details of position, movement, lighting, and color in any scene involving 3D models+  * **Geomtry ​shaders**: Pueden generar nuevas primitivas gráficas (puntoslíneastriangulos...). Se ejecutan después de los vertex ​sahders. Toman como input una primitiva. Entre sus usos está el de la generación de puntos de spritetessellationvolumen y extrusión de sombras... Un ejemplo sería el de la modificación de una malla compleja, se pueden generar puntos de control ​para una curva y generar líneas extra para aproximarla
-  * Geometry ​shaders +  * **Pixel ​shaders** (también conocidos como **fragment ​shaders**): Tratan atributos como el color de cada fragmentoPara simplificar el valor de luzhacer bump mappingsombrasobjetos translucidos... Pueden alterar la profundidad de los fragmentos o sacar más de un color si han sido activados múltiples targets de renderAunque no pueden aplicar grandes alteraciones, a su nivel se conoce las coordenadas de la pantalla donde donde serán dibujados y los pixels vecinoscosa que permite ejecutar gran variedad de efectos de postprocesado 2d (como blurdetección y acentuación de bordes...).  
-Geometry ​shaders ​are a relatively new type of shader, introduced in Direct3D 10 and OpenGL 3.2; formerly available in OpenGL 2.0+ with the use of extensions.[2] This type of shader can generate new graphics primitivessuch as pointslinesand triangles, from those primitives that were sent to the beginning of the graphics pipeline.[3] + 
-Geometry shader programs are executed after vertex shadersThey take as input a whole primitive, possibly with adjacency informationFor example, when operating on triangles, the three vertices are the geometry shader'​s inputThe shader can then emit zero or more primitiveswhich are rasterized and their fragments ultimately passed to pixel shader. +=== Algoritmos de shading === 
-Typical uses of a geometry shader include point sprite generationgeometry tessellation,​ shadow volume extrusionand single pass rendering to a cube mapA typical real world example of the benefits of geometry shaders would be automatic mesh complexity modificationA series of line strips representing control points for a curve are passed to the geometry shader and depending on the complexity required the shader can automatically generate extra lines each of which provides a better approximation of a curve.+  * [[http://​en.wikipedia.org/​wiki/​Illumination_model]] 
 +Técnicas de interpolación:​ 
 +  * Flat shading 
 +  * Gouraud shading 
 +  * Phong shading 
 +Modelos de iluminación (pueden ser combinados con técnicas de interpolación):​ 
 +  * Blinn–Phong 
 +  * Cook–Torrance (microfacets) 
 +  * Lambert 
 +  * Minnaert 
 +  * Oren–Nayar (Rough opaque diffuse surfaces) 
 +  * Phong 
 +  * Ward anisotropic 
 +  * Cel shading
  
-Pixel shaders 
-Pixel shaders, also known as fragment shaders, compute color and other attributes of each fragment. Pixel shaders range from always outputting the same color, to applying a lighting value, to doing bump mapping, shadows, specular highlights, translucency and other phenomena. They can alter the depth of the fragment (for Z-buffering),​ or output more than one color if multiple render targets are active. In 3D graphics, a pixel shader alone cannot produce very complex effects, because it operates only on a single fragment, without knowledge of a scene'​s geometry. However, pixel shaders do have knowledge of the screen coordinate being drawn, and can sample the screen and nearby pixels if the contents of the entire screen are passed as a texture to the shader. This technique can enable a wide variety of two-dimensional postprocessing effects, such as blur, or edge detection/​enhancement for cartoon/cel shaders. Pixel shaders may also be applied in intermediate stages to any two-dimensional images in the pipeline, whereas vertex shaders always require a 3D model. For instance, a pixel shader is the only kind of shader that can act as a postprocessor or filter for a video stream after it has been rasterized. 
 === Lenguajes para programar shaders === === Lenguajes para programar shaders ===
-  * **GLSL** +  * **GLSL**: Oficial de OpenGL (OpenGL Shading Language). 
-  * **HLSL** +  * **HLSL**: Oficial de Direct3d (High Level Shading Language). 
-  * **Cg** +  * **Cg**: Propio de nVidia.
-===== GLSL =====+
  
  
 +===== Notas =====
 +  * [[http://​es.wikipedia.org/​wiki/​Coordenadas_homog%C3%A9neas]]
fw/ogl/graphics.1360520397.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)