bump mapping tests
This commit is contained in:
parent
d2244fa274
commit
935b56da2e
@ -64,7 +64,6 @@ Scene* MyGLWidget::buildScene()
|
||||
scene->addEntity(myEntity);
|
||||
|
||||
scene->addDirectionnalLight(glm::vec3(6, 4, -4), glm::vec3(0.7f, 0.6f, 0.4f)); // sun
|
||||
scene->addPointLight(glm::vec3(0, 0, 4), glm::vec3(0.7f, 0.6f, 0.4f));
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
@ -39,12 +39,13 @@ vec3 computeLight(in vec3 kd, in vec3 ks, in float ns, in vec3 color, in vec3 no
|
||||
|
||||
void main(void) {
|
||||
int i;
|
||||
vec3 kd = vec3(texture2D(baseTexture, varTexCoord));
|
||||
vec3 light = 0.1f*kd;
|
||||
vec3 kd = vec3(0.5);
|
||||
vec3 light = 0.1*kd;
|
||||
vec3 myNormal = normalize(varNormal + 0.3 - 0.6*vec3(texture2D(baseTexture, varTexCoord)));
|
||||
for(i=0; i<nbDirLights && i<4; ++i)
|
||||
light += computeLight(kd, materialKs, materialNs, dirLights[i*2+1], varNormal, lightDirInView[i], halfVecInView[i]);
|
||||
light += computeLight(kd, materialKs, materialNs, dirLights[i*2+1], myNormal, lightDirInView[i], halfVecInView[i]);
|
||||
for(i=0; i<nbPointLights && i+nbDirLights<4; ++i)
|
||||
light += computeLight(kd, materialKs, materialNs, pointLights[i*2+1], varNormal, lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
|
||||
light += computeLight(kd, materialKs, materialNs, pointLights[i*2+1], myNormal, lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
|
||||
|
||||
outColor = vec4(light, 1);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ Texture::Texture() : type(GL_TEXTURE_2D)
|
||||
{
|
||||
glAssert(glGenTextures(1, &texId));
|
||||
glAssert(glBindTexture(type, texId));
|
||||
createNoiseTexture(GL_TEXTURE_2D, 512, 512, 10, 1);
|
||||
createNoiseTexture(GL_TEXTURE_2D, 512, 512, 10, 1.5f);
|
||||
setWrap(GL_REPEAT);
|
||||
setFiltering(GL_LINEAR);
|
||||
}
|
||||
@ -42,7 +42,7 @@ Texture::~Texture()
|
||||
glAssert(glDeleteTextures(1, &texId));
|
||||
}
|
||||
|
||||
void Texture::createNoiseTexture(GLenum textureSlot, int width, int height, float frequency, float myScale)
|
||||
void Texture::createNoiseTexture(GLenum textureSlot, int width, int height, float frequency, float amplitude)
|
||||
{
|
||||
GLubyte *data = new GLubyte[ width * height * 4];
|
||||
|
||||
@ -55,7 +55,7 @@ void Texture::createNoiseTexture(GLenum textureSlot, int width, int height, floa
|
||||
float y = yFactor * row;
|
||||
float sum = 0.0f;
|
||||
float freq = frequency;
|
||||
float scale = myScale;
|
||||
float scale = amplitude;
|
||||
|
||||
// Compute the sum for each octave
|
||||
for( int oct = 0; oct < 4 ; oct++ ) {
|
||||
@ -68,7 +68,7 @@ void Texture::createNoiseTexture(GLenum textureSlot, int width, int height, floa
|
||||
data[((row * width + col) * 4) + oct] =
|
||||
(GLubyte) ( result * 255.0f );
|
||||
freq *= 2.0f; // Double the frequency
|
||||
scale *= myScale; // Next power of b
|
||||
scale *= amplitude; // Next power of b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user