shader

rotate Z axis on 2d image's matrix in shader

ぐ巨炮叔叔 提交于 2021-02-19 04:41:28
问题 I'm trying to rotate a 2d image's matrix inside the vertex shader. I want the 2d image to rotate around what I think would be the z axis. However The closes I've ever gotten is: Here is my matrix inside my shader that I apply translation and scaling on: mat4 worldPosTrans = mat4(vec4(scale.x * cos(rotateZ), 0, 0, 0), vec4(0, scale.y, 0, 0), vec4(0, 0, scale.z, 0), vec4(translation, 1)); This is a slightly changed version from something that was supposed to rotate everything: mat4

Shader that transforms a mercator projection to equirectangular?

早过忘川 提交于 2021-02-18 16:55:14
问题 I am trying to make a shader in Unity taking a mercator projection texture as a source and converting it to an equirectangular projection texture . Input example: Output example: This example does the opposite with an equirectangular as source. If you look at the source of the above example: // mercator float latClamped = clamp(lat, -1.4835298641951802, 1.4835298641951802); float yMerc = log(tan(PI / 4.0 + latClamped / 2.0)) / PI2; float xMerc = xEqui / 2.0; vec4 mercatorPos = vec4(xMerc,

webgl border color shader

心不动则不痛 提交于 2021-02-18 08:44:17
问题 How do I write a shader to draw a polygon in solid color and it's border in a different color. Basically I have a hexagons map in 3d and I need to be able to outline each hexagon with a black border, if user requests so. Would also be nice if I could control border width. Thanks. 回答1: Off the top of my head, one way would be to create a your hex with a 7th vertex in the center 1---2 /\ /\ / \ / \ 6----0----3 \ / \ / \/ \/ 5---4 Add texture coordinates where point 0 has UV = { 0, 0 } and

Draw edges of a polygon with OpenGL shaders

痞子三分冷 提交于 2021-02-17 22:27:45
问题 I was wondering if it was possible to draw the edges of a rendered polygon with a specific color using a fragment shader, as in this example picture: Or should I just render those separately? 回答1: See work related on this page: http://web.archive.org/web/20120527185124/http://cgg-journal.com/2008-2/06/index.html A vertex shader should render polygons where the distance to each edge is colored. The difference between coloring each "cell" is explained in much detail. 来源: https://stackoverflow

Increase precision in DirectX with high range positions?

依然范特西╮ 提交于 2021-02-16 13:12:34
问题 I am creating an little game in c++ with directx 9 with a randomly created world and have an issue when the player goes far from the 3d origins (0,0,0) 3d rendering become very imprecise causing visual issues. I think it's because the values sent to the shader are floats and floats become less precise when increasing. I though about a solution to move all the models instead of moving the camera but it makes more calculating, I 'm afraid about the possible performances decrease. Is there a

Increase precision in DirectX with high range positions?

假装没事ソ 提交于 2021-02-16 13:10:12
问题 I am creating an little game in c++ with directx 9 with a randomly created world and have an issue when the player goes far from the 3d origins (0,0,0) 3d rendering become very imprecise causing visual issues. I think it's because the values sent to the shader are floats and floats become less precise when increasing. I though about a solution to move all the models instead of moving the camera but it makes more calculating, I 'm afraid about the possible performances decrease. Is there a

Is there a way to draw a circle with the fragment shader at the position of a point from the vertex shader?

╄→尐↘猪︶ㄣ 提交于 2021-02-16 05:25:44
问题 So i am drawing a Point at a certain ... well ... point of the screen that is then moving around. My Vertex Shader looks like this. private final String vertexShaderCode = "attribute vec4 vPosition;" + "uniform mat4 Projection; \n" + "uniform mat4 ModelView; \n" + "void main() {" + " gl_Position = Projection * ModelView * vPosition;" + " gl_PointSize = 900.0; " + "}"; What i am trying to achive is to then render a circle around the position of this one vertice. For that i am using the

Is there a way to draw a circle with the fragment shader at the position of a point from the vertex shader?

帅比萌擦擦* 提交于 2021-02-16 05:24:40
问题 So i am drawing a Point at a certain ... well ... point of the screen that is then moving around. My Vertex Shader looks like this. private final String vertexShaderCode = "attribute vec4 vPosition;" + "uniform mat4 Projection; \n" + "uniform mat4 ModelView; \n" + "void main() {" + " gl_Position = Projection * ModelView * vPosition;" + " gl_PointSize = 900.0; " + "}"; What i am trying to achive is to then render a circle around the position of this one vertice. For that i am using the

Is it possible to access pre-set textureunits within a shader?

旧巷老猫 提交于 2021-02-11 15:31:16
问题 TL;DR: I've activated and bound textures to textureunits 1-4 and now I wish to use them within shaders without using a program specific uniform position. Is it possible to read data from textures using the "global" texture units? I'm having a bit of a hard time understanding how to access textures in webgl. Here in this tutorial on textures it says " Texture units are a global array of references to textures. ", and this sounds great. I've bound my textures using gl.activeTexture(gl.TEXTURE1

Is it possible to access pre-set textureunits within a shader?

﹥>﹥吖頭↗ 提交于 2021-02-11 15:31:10
问题 TL;DR: I've activated and bound textures to textureunits 1-4 and now I wish to use them within shaders without using a program specific uniform position. Is it possible to read data from textures using the "global" texture units? I'm having a bit of a hard time understanding how to access textures in webgl. Here in this tutorial on textures it says " Texture units are a global array of references to textures. ", and this sounds great. I've bound my textures using gl.activeTexture(gl.TEXTURE1