shader

How to get a flat, non-interpolated color when using vertex shaders

那年仲夏 提交于 2019-12-11 08:33:34
问题 Is there a way to achieve this (OpenGL 2.1)? If I draw lines like this glShadeModel(GL_FLAT); glBegin(GL_LINES); glColor3f(1.0, 1.0, 0.0); glVertex3fv(bottomLeft); glVertex3fv(topRight); glColor3f(1.0, 0.0, 0.0); glVertex3fv(topRight); glVertex3fv(topLeft); . . (draw a square) . . glEnd(); I get the desired result (a different colour for each edge) but I want to be able to calculate the fragment values in a shader. If I do the same after setting up my shader program I always get interpolated

How to create a shader that can display a texture made out of many small images in Unity

萝らか妹 提交于 2019-12-11 08:09:42
问题 So what I'm trying to do is load satellite images from an SQL table and wrap them around a sphere to create a globe. I know I've got loading the images covered, I'm just not sure how to make my shader display the images in the correct orientation. I've gone to the Unity Forums as well as checked out this code from the Unity Docs. Using the linked shader code and the help I received on the forums, here's the code I've ended up with: Properties { _MainTexArray("Tex", 2DArray) = "" {}

Combining Two Shaders into One Shader

僤鯓⒐⒋嵵緔 提交于 2019-12-11 08:03:22
问题 Unity Project, Want to combine these two shaders into one shader to get both of their functionality. One shader is for lighting, the other shader is for rendering better. How do I combine? Shader "Transparent/Cutout/Lit3dSprite" { Properties{ _MainCol("Main Tint", Color) = (1,1,1,1) _MainTex("Main Texture", 2D) = "white" {} _Cutoff("Alpha cutoff", Range(0,1)) = 0.5 } SubShader{ Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" "PreviewType" = "Plane"}

Conflict drawing on OpenGLES on iOS

三世轮回 提交于 2019-12-11 07:54:05
问题 I'm writing an app allows drawing free style (using finger) and drawing image. I posted one of my problems at OpenGL ES glFragColor depend on if condition on Fragment shader in iOS. Thanks for many suggestions, I solved that. Now I still have another new issue. I have 2 programs which have id PROGRAM_POINT (drawing free style) and PROGRAM_POINT_0 (draw image). Those are initialized. Each program has a pair of shader files. PROGRAM_POINT has shader files named point.vsh and point.fsh. For

Convert OpenGL shader to Metal (Swift) to be used in CIFilter

偶尔善良 提交于 2019-12-11 07:46:11
问题 I'm quite new to OpenGL / Metal and I'm trying to understand some fundamental concepts. Within our app, we are using CIFilter to filter videos. I saw a WWDC video from 2017 explaining that you can wrap CIFilter with Metal and use it as a regular filter. I'm trying to understand how to convert this OpenGL video effect to Metal so I can use it as a reference point for future effects. void mainImage(out vec4 fragColor, in vec2 fragCoord) { float amount = sin(iTime) * 0.1; // uv coords vec2 uv =

How to pass non-texture data to SCNTechnique Metal shaders

社会主义新天地 提交于 2019-12-11 07:32:56
问题 I can a pass custom parameter of type sampler2D to the Metal fragment function of an SCNTechnique and I have a working 2nd pass: PList: <key>inputs</key> <dict> <key>imageFromPass1</key> <string>COLOR</string> <key>myCustomImage</key> <string>myCustomImage_sym</string> </dict> ... <key>symbols</key> <dict> <key>myCustomImage_sym</key> <dict> <key>type</key> <string>sampler2D</string> </dict> </dict> Relevant Obj-C code: [technique setValue: UIImagePNGRepresentation(myCustomTexture) forKey:@

GGX shader creation

旧街凉风 提交于 2019-12-11 07:19:29
问题 I'm trying to create a ggx shader but when I run it at BRDF Explorer the main page remains white. I'm trying to find my error but I can't. Can anybody help me? below is my file analytic ::begin parameters float baseColor 0.001 .2 .1 float m 0.001 0.1 1.0 ::end parameters ::begin shader const float PI = 3.14; vec3 BRDF( vec3 N, vec3 V, vec3 L, float m, float baseColor) { vec3 H = normalize(V+L); float dotNL = clamp(dot(N,L), 0.0, 1.0); float dotLH = clamp(dot(L,H), 0.0, 1.0); float dotNH =

Giving colour to primitives in OpenGL using Vertex Buffer Objects

浪尽此生 提交于 2019-12-11 06:29:17
问题 I am writing a program in C, using OpenGL, to draw some primitives (lines, circles, etc.). I have succeeded in using the buffer objects to store the vertices of the primitives, and hence, in drawing them. But I seem to be stuck now since I don't know how to set their colour. Part of the program was given to me by my teacher, so I know that the colour attributes must be specified using this structure: typedef struct { float r; float g; float b; float a; } vec4; I know I am supposed to use a

Opengl ES 3.0 shader functions unimplemented on Nexus 5/KitKat 4.4

送分小仙女□ 提交于 2019-12-11 06:26:13
问题 I'm having no luck using any of the OpenGL 3.0 shader functions on my Nexus 5 w/ KitKat 4.4, I get "called unimplemented opengl es api" for functions such as glCreateProgram() glShaderSource() glCompileShader() e.t.c. I am performing all calls whilst the OpenGL context is active. I can't imagine that these functions would not be implemented, so believe I must be doing something wrong! I have included the following <GLES3/gl3.h> <GLES2/gl2ext.h> <GLES3/gl3platform.h> and am using -lGLESv3 in

Where do shaders fit in with the older methods of rendering in OpenGL?

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:23:23
问题 I have written a level renderer in OpenGL following many online tutorials. I actually render with vertex arrays and the range draw command. Now because I want to have the level lit with per pixel lighting, I realize shaders are a huge part if not the main part of OpenGL at this point. So here I am with my "traditional" method of rendering without shaders and I want to know how shaders fit into the grand sceme of things. Will my main rendering function actually be done with shaders if I rework