mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 12:15:25 +02:00
Better names for the shaders.
This commit is contained in:
parent
0a6b4702c6
commit
86ddcea87f
4 changed files with 22 additions and 16 deletions
interface
|
@ -1,16 +1,22 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// grainy_voxels.frag
|
||||
// perlin_modulate.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 5/15/13.
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#version 120
|
||||
|
||||
// the texture containing our permutations and normals
|
||||
uniform sampler2D permutationNormalTexture;
|
||||
|
||||
// the noise frequency
|
||||
const float frequency = 1024.0;
|
||||
|
||||
// the noise amplitude
|
||||
const float amplitude = 0.1;
|
||||
|
||||
// the position in model space
|
||||
varying vec3 position;
|
||||
|
||||
|
@ -53,5 +59,5 @@ float perlin(vec3 location) {
|
|||
}
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = vec4(gl_Color.rgb * (0.85 + perlin(position * 1024.0) * 0.15), 1.0);
|
||||
gl_FragColor = vec4(gl_Color.rgb * (1.0 + amplitude*(perlin(position * frequency) - 1.0)), 1.0);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// grainy_voxels.vert
|
||||
// perlin_modulate.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 5/15/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#version 120
|
||||
|
||||
// the position in model space
|
||||
varying vec3 position;
|
||||
|
|
@ -503,12 +503,12 @@ void VoxelSystem::init() {
|
|||
|
||||
// create our simple fragment shader
|
||||
switchToResourcesParentIfRequired();
|
||||
_grainProgram = new ProgramObject();
|
||||
_grainProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/grainy_voxels.vert");
|
||||
_grainProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/grainy_voxels.frag");
|
||||
_grainProgram->link();
|
||||
_perlinModulateProgram = new ProgramObject();
|
||||
_perlinModulateProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/perlin_modulate.vert");
|
||||
_perlinModulateProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/perlin_modulate.frag");
|
||||
_perlinModulateProgram->link();
|
||||
|
||||
_grainProgram->setUniformValue("permutationNormalTexture", 0);
|
||||
_perlinModulateProgram->setUniformValue("permutationNormalTexture", 0);
|
||||
|
||||
// create the permutation/normal texture
|
||||
glGenTextures(1, &_permutationNormalTextureID);
|
||||
|
@ -640,7 +640,7 @@ void VoxelSystem::render() {
|
|||
glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID);
|
||||
glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
|
||||
|
||||
_grainProgram->bind();
|
||||
_perlinModulateProgram->bind();
|
||||
glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID);
|
||||
|
||||
// draw the number of voxels we have
|
||||
|
@ -648,7 +648,7 @@ void VoxelSystem::render() {
|
|||
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||
glDrawElements(GL_TRIANGLES, 36 * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
|
||||
|
||||
_grainProgram->release();
|
||||
_perlinModulateProgram->release();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// deactivate vertex and color arrays after drawing
|
||||
|
|
|
@ -135,7 +135,7 @@ private:
|
|||
pthread_mutex_t _bufferWriteLock;
|
||||
pthread_mutex_t _treeLock;
|
||||
|
||||
ProgramObject* _grainProgram;
|
||||
ProgramObject* _perlinModulateProgram;
|
||||
GLuint _permutationNormalTextureID;
|
||||
|
||||
ViewFrustum* _viewFrustum;
|
||||
|
|
Loading…
Reference in a new issue