Лекция 7 (26.11.2012). /archived-tools/gpu-tools- archive/rendermonkey-toolsuite/#download

Презентация:



Advertisements
Похожие презентации
RealTime Галинский В.А. Физико-математический лицей 30 Computer Graphics Support Group 1 Компьютерная графика реального времени. URL:
Advertisements

Effects in Computer Graphics. Modern effects Introduction 80-90s effects My own effects Some info.
War & Peace is the first in the history TV channel and media portal Based on technology of semantic imposition called "info-reactor" Intellectuals only
1. a=? b=? c=? {int a, b, c; a=(b=2+3)/2 - 4+(c=5%2); printf("%d %d %d \n", a, b, c); }
The institutionalization and evolutionary dynamics of interorganizational alliances Perspectives on networks Economic-based views of alliances The corporate.
Which has more packaging than NECESSARY ?
Защита от взлома Лекция 10Защита от взлома Лекция 10.
My Altai Made by Maxim Asmolov, Form 7 Bobrovka, 2013.
The main goal of the project is to develop 3-D Local Positioning System (LPS) which allows locating mobile objects inside multi-floor building. Required.
Crisis and business Help us to choose. An idea for business In metallurgy, some plants form by- products that they dont need at all. There are companies.
Data Types in C. A Data Type A data type is –A set of values AND –A set of operations on those values A data type is used to –Identify the type of a variable.
The main industry is coalmining. Of course, the mines pollute our environment. And our nature is unique. Some lyrics even call our place The second Switzerland.
Unit II Constructor Cont… Destructor Default constructor.
Evgeniy Krivosheev Andrey Stukalenko Vyacheslav Yakovenko Last update: Nov, 2013 Spring Framework Module 1 - Introduction.
OLAP ModelKit is a universal solution in the field of interactive reporting and thorough data analysis which allows programmers to create effective decision-support.
Schooling School is the main social environment for young people. At school we make out best friends.
Russian State University Physical Education Recreation Moscow 2012.
1. a=? b=? c=? {int a, b, c; a=(b=2+3)/2 - 4+(c=5%2); printf("%d %d %d \n", a, b, c); }
Программирование графических процессоров Безгодов Алексей Алексеевич НИИ НКТ, СПбГУ ИТМО.
Транксрипт:

Лекция 7 ( )

/archived-tools/gpu-tools- archive/rendermonkey-toolsuite/#download /archived-tools/gpu-tools- archive/rendermonkey-toolsuite/#download RenderMonkey is a rich shader development environment for both programmers and artists which facilitates the collaborative creation of real-time shader effects.

glActiveTexture(GL_TEXTURE0+iTextureUnit); glBindTexture(GL_TEXTURE_2D, uiTexture); glBindSampler(iTextureUnit, uiSampler); int iSamplerLoc = glGetUniformLocation(spMain.getProgramID(), "gSampler"); glUniform1i(iSamplerLoc, 0);

in vec2 texCoord; out vec4 outputColor; uniform sampler2D gSampler; void main() { outputColor = texture2D(gSampler, texCoord); }

uniform mat4 projectionMatrix; uniform mat4 modelViewMatrix; layout (location = 0) in vec3 inPosition; layout (location = 1) in vec2 inCoord; out vec2 texCoord; void main() { gl_Position = projectionMatrix*modelViewMatrix*vec4(inPosition, 1.0); texCoord = inCoord; }

#ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; #else precision mediump float; #endif uniform sampler2D BaseMap; uniform vec4 lightDir; varying vec2 texCoord; varying vec3 normal; void main(void) { vec4 base = texture2D(BaseMap, texCoord); float diffuse = clamp(dot(normalize(normal), vec3(lightDir)), 0.0, 1.0); gl_FragColor = vec4( * diffuse) * base; }

Где 'I' - интенсивность отражения (reflection), Ld = диффузный цвет источника (gl_LightSource[0].diffuse), и Md - диффузный коэффициент материала (gl_FrontMaterial.diffuse). Эта формула известна как "Lambertian Reflection ("Закон косинуса Ламберта)

void main() { vec3 normal, lightDir; vec4 diffuse; float NdotL; normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); NdotL = max(dot(normal, lightDir), 0.0); diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; gl_FrontColor = NdotL * diffuse; gl_Position = ftransform(); }

Всё, что остаётся на долю пикселного шейдера - установить цвет пикселов, используя varying-переменную gl_Color void main() { gl_FragColor = gl_Color; }

void main() { vec3 normal, lightDir; vec4 diffuse, ambient, globalAmbient; float NdotL; normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); NdotL = max(dot(normal, lightDir), 0.0); diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient; globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient; gl_FrontColor = NdotL * diffuse + globalAmbient + ambient; gl_Position = ftransform(); }