投影纹理与最小细节层级的混合应用
2017-12-09 21:58
447 查看
void Basic::genfloorTex() { m_sourceImage = NvImage::CreateFromDDSFile("textures/flower1024.dds"); GLint w = m_sourceImage->getWidth(); GLint h = m_sourceImage->getHeight(); GLint intFormat = m_sourceImage->getInternalFormat(); GLint format = m_sourceImage->getFormat(); GLint type = m_sourceImage->getType(); // Image must be immutable in order to be used with glBindImageTexture // So we copy the mutable texture to an immutable texture glGenTextures(1, &m_sourceTexture); glBindTexture(GL_TEXTURE_2D, m_sourceTexture); glTexStorage2D(GL_TEXTURE_2D, 1, intFormat, w, h); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, type, m_sourceImage->getLevel(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, 0); } //vertex shader #version 100 attribute highp vec2 aPosition; attribute highp vec2 aTexcoord; uniform mediump mat4 uViewProjMatrix; varying lowp vec4 vColor; varying lowp vec2 vs_fs_texCoord; varying lowp vec4 vs_fs_projtexCoord; void main(void) { gl_Position = uViewProjMatrix * vec4(aPosition.x, aPosition.y, 0.0, 1.0); vs_fs_texCoord = aTexcoord; vs_fs_projtexCoord = mat4(0.5,0.0,0.0,0.0, 0.0,0.5,0.0,0.0, 0.0,0.0,0.5,0.0, 0.5,0.5,0.5,1.0)*uViewProjMatrix * vec4(aPosition.x+0.4, aPosition.y, 0.0, 1.0); } //frag shader #version 430 precision highp float; in lowp vec2 vs_fs_texCoord; in lowp vec4 vs_fs_projtexCoord; layout (binding = 0) uniform sampler2D mipmapTex; layout (binding = 1) uniform sampler2D projTex; layout (location = 0) out vec4 outcolor0; void main(void) { //outcolor0 = texture(mipmapTex, vs_fs_texCoord); //outcolor0 = textureLod(mipmapTex,vs_fs_texCoord,6.0f); outcolor0 = texture(mipmapTex, vs_fs_texCoord); outcolor0+= textureProj(projTex,vs_fs_projtexCoord); }
相关文章推荐
- android应用开发:音乐播放器(2)--技术细节
- 如何投影一个纹理 (转 by 叶蔚 Azure)
- 如何投影一个纹理
- nyoj 2340 最小循环节(KMP之next数组的应用)
- Linux系统下的NAT及防火墙的混合应用
- java.util.TaskQueue的最小堆排序算法的应用
- 梯度方法在非线形最小二乘法问题的应用
- 网易内推编程题:异或运算求混合颜料的最小种类
- POJ 3026 bfs+最小生成树的应用
- (step6.1.8)hdu 3367(Pseudoforest——最小生成树的逆应用)
- 从 iOS Basecamp 3 探索混合应用开发的最佳实践
- 纹理混合和模板
- Web初学-Web应用细节
- Soap技术在Windows应用程序开发中的应用B/S与C/S混合模式开发[草稿]
- OpenGL学习笔记(十三):将纹理贴图应用到四边形上,对VAO/VBO/EBO/纹理/着色器的使用方式进行总结
- 多重纹理的混合
- Shader中贴图知识汇总: 漫反射贴图、凹凸贴图、高光贴图、 AO贴图、环境贴图、 光照纹理及细节贴图
- 原生应用native、Web应用、混合应用hybrid:3者的优缺点解析
- 三维纹理的绑定和应用
- 数据结构学习笔记(20)---图的应用(生成树与最小生成树)