shader

Shader can't be compiled

隐身守侯 提交于 2019-11-27 15:04:16
问题 I'm following book "OpenGL Programming Guide 8th Edition". I just want to run the first program introduced in the book on my Mac. It's Mavericks + Xcode 4.6.1 + Intel HD graphics 4000. So the problem is, the shader can't be compiled. Shader codes: #version 410 core layout(location = 0) in vec4 vPosition; void main() { gl_Position = vPosition; } And the error message is: Shader compilation failed: ERROR: 0:1: '' : version '410' is not supported ERROR: 0:1: '' : syntax error #version ERROR: 0:3

Simulating palette swaps with OpenGL Shaders (in LibGDX)

 ̄綄美尐妖づ 提交于 2019-11-27 14:58:36
问题 I'm trying to use LibGDX to make a retro-style little game, and I'd like to let the players to choose the colors of several characters, so I thought about loading png indexed images and then updating palettes programatically... How wrong I was ^^U It seems that color pallettes are something of the past, and also seems that the best option to achieve a similar result is by using Shaders. Here is an image explaining what I'm trying right now: My intention is to use 2 images. One of them, pixel

Libgdx how to use shader in 3D

瘦欲@ 提交于 2019-11-27 14:12:09
问题 I reached a point in my wip game, where I want to make it more eye-appealing. Currently I add some Ambientlight and a Directionla-light to an Environment and render my scene with it. But now I want to add a custom Shader to it. So I have been looking for some tutorials and for some reason in almost every tutorial they have used another "version" of using Shader in their game: Giving the ModelBatch a String or FileHandle vertex/fragment -shader Creating a ShaderProgram with vertex and fragment

How to render clipped surfaces as solid objects

怎甘沉沦 提交于 2019-11-27 14:11:39
In Three.js, I have a 3d object where I am using local clipping planes to only render a part of the object. However, since 3d objects are "hollow" (meaning only the outer surface is rendered), when we clip anything off that surface we can "see into" the object. Here's an example of what I mean, clipping a corner off a cube . Notice how we can see the backside of the opposite corner. I would like to give the appearance of the object being solid. Based on this issue , it seems that the best way to accomplish this is to create a surface over the clipped region, thus capping the hole and making

Shader position vec4 or vec3

旧巷老猫 提交于 2019-11-27 13:53:51
问题 I have read some tutorials about GLSL. In certain position attribute is a vec4 in some vec3. I know that the matrix operations need a vec4, but is it worth to send an additional element? Isn't it better to send vec3 and later cast in the shader vec4(position, 1.0)? Less data in memory - it will be faster? Or we should pack an extra element to avoid casting? Any tips what should be better? layout(location = 0) in vec4 position; MVP*position; or layout(location = 0) in vec3 position; MVP*vec4

探究光线追踪技术及UE4的实现

爷,独闯天下 提交于 2019-11-27 13:46:26
目录 一、光线追踪概述 1.1 光线追踪是什么 1.2 光线追踪的特点 1.3 光线追踪的历史 1.4 光线追踪的应用 二、光线追踪的原理 2.1 光线追踪的物理原理 2.2 光线追踪算法 2.3 RTX和DXR 2.3.1 RTX(NV) 2.3.2 DXR(Microsoft) 三、UE4的光线追踪 3.1 UE4光线追踪的开启 3.2 UE4光线追踪的特性 3.2.1 光线追踪的阴影 3.2.2 光线追踪的反射 3.2.3 光线追踪的透明 3.2.4 光线追踪的环境光遮蔽 3.2.5 光线追踪的全局光照 3.2.6 光线追踪的其它特性 3.3 UE4光线追踪的调试 3.4 UE4光线追踪的不足 四、UE的底层实现 五、总结 特别说明 参考文献 一、光线追踪概述 1.1 光线追踪是什么 与传统的扫描线或光栅化渲染方式不同, 光线追踪(Ray tracing) 是三维计算机图形学中的特殊渲染算法,跟踪从摄像机发出的光线而不是光源发出的光线,通过这样一项技术生成编排好的场景的数学模型显现出来。 利用光线追踪技术渲染出的照片级画面。 与传统方法的扫描线技术相比,这种方法有更好的光学效果,例如对于反射与折射有更准确的模拟效果,并且效率非常高,所以当追求高质量的效果时经常使用这种方法。 在物理学中,光线追迹可以用来计算光束在介质中传播的情况。在介质中传播时,光束可能会被介质吸收

Three.js Retrieve data from WebGLRenderTarget (water sim)

…衆ロ難τιáo~ 提交于 2019-11-27 13:29:34
问题 I am trying to port this (http://madebyevan.com/webgl-water/‎) over to THREE. I think I'm getting close (just want the simulation for now, don't care about caustics/refraction yet). I'd like to get it working with shaders for the GPU boost. Here's my current THREE setup using shaders: http://jsfiddle.net/EqLL9/2/ (the second smaller plane is for debugging what's currently in the WebGLRenderTarget) What I'm struggling with is reading data back from the WebGLRenderTarget (rtTexture in my

Gaussian filter with OpenGL Shaders

匆匆过客 提交于 2019-11-27 12:30:57
I am trying to learn Shaders to implement something in my iPhone app. So far I have understood easy examples like making a color image to gray scale, thresholding, etc. Most of the examples involve simple operations in where processing input image pixel I(x,y) results in a simple modification of the colors of the same pixel But, how about Convolutions?. For example, the easiest example would the Gaussian filter, in where output image pixel O(x,y) depends not only on I(x,y) but also on surrounding 8 pixels. O(x,y) = (I(x,y)+ surrounding 8 pixels values)/9; Normally, this cannot be done with one

Get results of GPU calculations back to the CPU program in OpenGL

这一生的挚爱 提交于 2019-11-27 11:41:53
问题 Is there a way to get results from a shader running on a GPU back to the program running on the CPU? I want to generate a polygon mesh from simple voxel data based on a computational costly algorithm on the GPU but I need the result on the CPU for physics calculations. 回答1: Define "the results"? In general, if you're doing GPGPU-style computations with OpenGL, you are going to need to structure your shaders around the needs of a rendering system. Rendering systems are designed to be one-way:

What can cause glDrawArrays to generate a GL_INVALID_OPERATION error?

喜欢而已 提交于 2019-11-27 11:04:31
问题 I've been attempting to write a two-pass GPU implementation of the Marching Cubes algorithm, similar to the one detailed in the first chapter of GPU Gems 3, using OpenGL and GLSL. However, the call to glDrawArrays in my first pass consistently fails with a GL_INVALID_OPERATION . I've looked up all the documentation I can find, and found these conditions under which glDrawArrays can throw that error: GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled