shader

OpenGL - Texture mapping in vertex or fragment shader?

倖福魔咒の 提交于 2019-12-10 10:24:40
问题 Is there texture of an object/triangles mapped in the fragment shader or the vertex shader? Whether if it is on the vertex or fragment shader, if you are programming shaders it's something that you have to code yourself right? Without shader you just assinged the tex coords and opengl mapps it without you knowing, but with shaders you have to do it yourself, right? 回答1: Usually the texturing happens in the fragment shader. This is the place where triangle's fragments gain a color. Usually in

How to define an array of floats in Shader properties?

送分小仙女□ 提交于 2019-12-10 09:36:59
问题 I'd like to define an array of floats in my shader, something like this: Properties { _TilesX ("Tiles X", Int) = 10 _TilesY ("Tiles Y", Int) = 10 _TileData1 ("Tile data", Float[]) = {} // THIS!!! _Texture1 ("Texture odd", 2D) = "white" {} _Texture2 ("Texture even", 2D) = "white" {} } I'm trying to create a single plane that I'll use as a grid and I want to modify the _TileData1 at run-time to change the Y offset of a tile. I'm using _TilesX and _TilesY to get a 2d position of the tile from a

基于three.js的shader入门教程 四

好久不见. 提交于 2019-12-10 07:50:47
片源着色器 uniform 这种uniform变量啊 传入之后 可以在顶点着色器用 也可以在片源着色器用 uniform float a;这样 就是声明变量之前加一个uniform 这样在顶点或者片源着色器里面声明一下 外面再传入一个值 就可以使用了 这东西有啥用? 较为简单的 这个栗子 我传入了uniform vec3 a是一个1 0 0 运行是一个红色的球 你试试setTimeout几秒后 修改uniform.a.value=new THREE.Vector3(1,0,1)看看 var uniform={ a:{value:new THREE.Vector3(1,0,0)} } var geometry = new THREE.SphereBufferGeometry(10); var material=new THREE.ShaderMaterial({ uniforms:uniform, vertexShader:` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`, fragmentShader:` uniform vec3 a; void main() { gl_FragColor=vec4(a.r,a.g,a.b,1.0); } `, })

GLSL Shader to convert six textures to Equirectangular projection

有些话、适合烂在心里 提交于 2019-12-10 00:31:00
问题 I want to create an equirectangular projection from six quadratic textures, similar to converting a cubic projection image to an equirectangular image, but with the separate faces as textures instead of one texture in cubic projection. I'd like to do this on the graphics card for performance reasons, and therefore want to use a GLSL Shader. I've found a Shader that converts a cubic texture to an equirectangular one: link 回答1: Step 1: Copy your six textures into a cube map texture. You can do

Can't link shaders to program object in OpenGL, can't debug

て烟熏妆下的殇ゞ 提交于 2019-12-10 00:05:22
问题 I attach a vertex and fragment shader to a program object, then attempt to link the said program. GL_LINK_STATUS returns false. I check the info log, it's a bunch of gibberish characters. I check GL_INFO_LOG_LENGTH, it's 0. How do I debug this situation? //this is the end of my LoadBasicShaders function glAttachShader(program, vertShader); glAttachShader(program, fragShader); glLinkProgram(program); GLint status; glGetProgramiv(program, GL_LINK_STATUS, &status); if (status == GL_FALSE) {

Rotate Normals in Shader

社会主义新天地 提交于 2019-12-09 18:24:00
问题 I have a scene with several models with individual positions and rotations. Given normals, the shaders apply simple bidirectional lighting to each pixel. That is my vertex shader. #version 150 in vec3 position; in vec3 normal; in vec2 texcoord; out vec3 f_normal; out vec2 f_texcoord; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { mat4 mvp = proj * view * model; f_normal = normal; f_texcoord = texcoord; gl_Position = mvp * vec4(position, 1.0); } And here is the

Render an SCNGeometry as a wireframe

大憨熊 提交于 2019-12-09 16:30:58
问题 I'm using SceneKit on iOS and I have a geometry I want to render as a wireframe. So basically I want to draw only the lines, so no textures. I figured out that I could use the shaderModifiers property of the used SCNMaterial to accomplish this. Example of a shader modifier: material.shaderModifiers = [ SCNShaderModifierEntryPointFragment: "_output.color.rgb = vec3(1.0) - _output.color.rgb;" ] This example apparently simply inverts the output colors. I know nothing about this 'GLSL' language I

General purpose compute with Vertex/Pixel shaders (Open GL / DirectX)

随声附和 提交于 2019-12-09 12:54:59
问题 I have a question regarding compute shaders. are compute shaders available in DX 9? would it be still possible to use a compute shader with a DX9 driver if there is no compute shader fragment on the GPU? ( SGX 545 does not have it, but SGX 6X generation is going to have it), as far as what IMG says. I would like to know If i can do some simple general purpose programming on SGXs GPUs with DirectX9 or OpenGL drivers. Also, is there anyway I can use OpenGL vertex shaders for GPGPU programming?

LibGDX mesh heightmap normals and lights

心不动则不痛 提交于 2019-12-09 11:49:57
问题 I am trying to get mesh normals and lights working in LibGDX project. I already have textured mesh generated from heightmap texture pixels. The problem is I cannot get normals lighted up correctly. Also Im not 100% sure I have normal vertices correctly set up in TerrainChunk class. Heres the main class code: package com.me.terrain; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic

OpenGL glLinkProgram returns false but info log is empty; checked everything

不想你离开。 提交于 2019-12-09 10:24:46
问题 I must admit this is my first time implementing shaders, previously I have only worked with fixed function pipeline; however, though I am certain that everything I did is correct - there must be an error. glLinkProgram(program) - returns GL_FALSE when queried for GL_LINK_STATUS . In addition, the info log is empty (when I query the log length - it is 1, which is the null terminator per the docs, it checks out). So linker errors, and no logs. In addition, I had just discovered that the linker