glsl

Issues with Z-axis rotation matrix in glsl shader

怎甘沉沦 提交于 2020-02-04 08:40:07
问题 I've recently began putting together an OpenGL ES 1.1/2.0 2D pipeline from the ground up (iPhone only). This pipeline is intended to be used by engineers with no 3D math experience. Commented out are the X and Y axis rotation matrices that produce the exact results they should . The Z rotation matrix seems to do nothing. VERTEX SHADER //THESE WORK /* highp mat4 rotationMatrix = mat4(1.0, 0.0, 0.0, 0.0, 0.0, cos(angle), -sin(angle), 0.0, 0.0, sin(angle), cos(angle), 0.0, 0.0, 0.0, 0.0, 1.0);

Issues with Z-axis rotation matrix in glsl shader

霸气de小男生 提交于 2020-02-04 08:40:06
问题 I've recently began putting together an OpenGL ES 1.1/2.0 2D pipeline from the ground up (iPhone only). This pipeline is intended to be used by engineers with no 3D math experience. Commented out are the X and Y axis rotation matrices that produce the exact results they should . The Z rotation matrix seems to do nothing. VERTEX SHADER //THESE WORK /* highp mat4 rotationMatrix = mat4(1.0, 0.0, 0.0, 0.0, 0.0, cos(angle), -sin(angle), 0.0, 0.0, sin(angle), cos(angle), 0.0, 0.0, 0.0, 0.0, 1.0);

OpenGL ES fragment shader apparently impossibly returning white

回眸只為那壹抹淺笑 提交于 2020-02-02 06:24:58
问题 This is a weird one. I have a fragment shader that as far as I can tell can only return black or red, but it's rendering the pixels in white. And if I remove one specific line, it returns the colour I'd expect. It works in WebGL, but not in OpenGL ES on the Raspberry Pi. Here's the shader code. It returns black if the pixel represents a point inside the Mandelbrot set, red otherwise. precision mediump float; varying vec2 vPosition; void main(void) { float cx = vPosition.x; float cy =

Vertex Shader error while Passing mesh face index using glvertex4i

久未见 提交于 2020-01-30 13:18:07
问题 Initializing GL_List for processing. glBegin(GL_POINTS); for (i = 0; i < faceNum; i++) { mesh->GetFaceNodes(i + 1, ver[0], ver[1], ver[2], ver[3]); **glVertex4i(ver[0] - 1, ver[1] - 1, ver[2] - 1, i+1);** } glEnd(); glEndList(); Vertex Shader gives me a compilation error and doesn't know why. Vertex Shader: varying out float final; void main( void ) { final = float(gl_Vertex.w); // want to pass this face index on to } Geometry Shader: varying in float final[]; varying out float final_tofrag;

(How) can a shader view the current render-buffer?

拈花ヽ惹草 提交于 2020-01-30 09:12:06
问题 Is it possible for a pixel shader to see the current state of the depth/color/stencil buffer? 回答1: A fragment shader is not given the current buffer values for the fragment it is working on. Attempts to read these values, by using those buffers as textures, will not in the general case produce reasonable results. It's "undefined behavior." There are certain specific cases where it can work. First, you can use texture barriers. That is technically an NVIDIA extension, but ATI supports it

从0开发3D引擎(九):实现最小的3D程序-“绘制三角形”

冷暖自知 提交于 2020-01-26 20:01:03
目录 上一篇博文 运行测试截图 需求分析 目标 特性 头脑风暴 确定需求 总体设计 具体实现 新建Engine3D项目 实现上下文 实现_init 实现“获得WebGL上下文” 实现“初始化所有Shader” 实现“初始化场景” 实现“设置清空颜色缓冲时的颜色值” 返回用于主循环的数据 实现_loop 实现“主循环” 实现“clearCanvas” 实现“_render” 最终的分层和领域模型 总结 本文完整代码地址 大家好,本文开始编程,实现最小的3D程序。 我们首先进行需求分析,确定功能点; 然后进行总体设计,划分模块,并且对模块进行顶层设计,给出类型签名和实现的伪代码; 最后进行具体实现,实现各个模块。 注:在Reason中,一个Reason文件(如Main.re)就是一个模块(Module)。 上一篇博文 从0开发3D引擎(八):准备“搭建引擎雏形” 运行测试截图 测试场景包括三个三角形: 需求分析 首先,我们分析最小3D程序的目标和特性; 接着,根据特性,我们进行头脑风暴,识别出功能关键点和扩展点; 最后,根据功能关键点和扩展点,我们确定最小3D程序的功能点。 目标 可从最小3D程序中提炼出通用的、最简化的引擎雏形 特性 为了达成目标,最小3D程序应该具备以下的特性: 简单 最小3D程序应该很简单,便于我们分析和提炼。 具有3D程序的通用特性

Shadow Volumes in WebGL/GLSL

泪湿孤枕 提交于 2020-01-25 08:14:26
问题 I am trying to implement shadow volumes using webgl and glsl for shaders. Currently I have a cube floating above a green ground with light coming from above but I am completely unaware of how to begin the implementation of shadow volumes. If anyone has any helpful tutorials or advice that would be greatly appreciated. I am fascinated by Shadow Volumes (not Shadow Maps) and really want to learn how to create them. I understand the general procedure to be: Perform ambient rendering pass Choose

GLSL gl_LightSource point/directional/spot differentiation

半世苍凉 提交于 2020-01-24 20:17:06
问题 I am writing a GLSL program as part of a plugin that runs inside of Maya, a closed-source 3D application. My plugin renders custom geometry into the same image buffer that the application renders it's default polygonal geometry. The application uses the OpenGL fixed pipeline for it's lighting and shading but I am using GLSL to render custom geometry and materials. My problem is, I want to mimic the behavior of the fixed pipeline lights in my shader. The application defines the lights in the

How to bind texture just to one object in OpenGLES?

白昼怎懂夜的黑 提交于 2020-01-24 19:49:29
问题 I am activating the texture just before the object to draw. But the texture is showing on both objects. Why is that so? Should I unbind the texture before the first object to draw? - I tried with glDisable and glBindTexture but it did not help. Here my code: @Override public void onDrawFrame(GL10 gl) { GLES20.glClear(GL10.GL_COLOR_BUFFER_BIT); synchronized (camerObject) { surfaceTextureCamera.updateTexImage(); cameraUpdate = false; } vertexBuffer.position(0); GLES20.glVertexAttribPointer

I wonder where am going wrong with the zooming and orbiting

巧了我就是萌 提交于 2020-01-24 12:17:47
问题 I want to be able to pan, zoom, and orbit the cube. I would like to know why the cube appears fully zoomed on the screen such that I have to move backwards to view the whole cube. I would also like to change the zooming controls to alt and right mouse button for both zooming and orbiting but I cant get it to work. Any assistance would be appreciated. /*/header inclusions*/ #include <iostream> // Includes C++ i/o stream #include <GL/glew.h> // Includes glew header #include <GL/freeglut.h> //