shader

How do I draw vertices that are stored in a SSBO?

旧巷老猫 提交于 2020-01-15 06:27:18
问题 This is a question following OpenGL and loading/reading data in AoSoA (hybrid SoA) format. I am trying to use a shader storage buffer object (SSBO) to store vertex data which is represented in AoSoA format. I am having trouble drawing the vertices, which obviously means that I am doing something wrong somewhere. The problem is that I can't seem to figure out what or where. The answer to the initial question above seems to indicate that I should not be using vertex attribute arrays, so the

JavaFX on Raspberry PI: Error loading stock shader

孤街醉人 提交于 2020-01-15 03:35:28
问题 Am currently trying to deploy my JavaFX application which runs smoothly on windows, on my Raspberry Model B+ v1.2. Since JavaFX is not directly available on the Raspi I've performed the adaptions with Gluon as described here (however with the newest version 144): Running Javafx GUI on the Raspberry Pi Now when I run my JFX application which is just going to show a simple window, I get the following error stack about problem with shaders (Error loading stock shader AlphaTexture_Color): Program

unity shader 着色器实例 代码+详解注释 【显示模型法线方向的shader】

放肆的年华 提交于 2020-01-15 02:57:21
用于显示模型法线方向的shader 原理很简单,就是获取顶点坐标信息作为起点,沿着法线方向在指定长度的位置画一条线段。我的代码里都有详细注释。 翠花,上效果图~ Shader "Unlit/normal" { //变量接口 Properties { //线段长度 _LineLength ( "Length" , float ) = 1. //线段颜色 _LineColor ( "Color" , COLOR ) = ( 0 , 1 , 0 , 1 ) } //着色器正文 SubShader { //着色器程序块 Pass { Tags { "RenderType" = "Opaque" } LOD 200 CGPROGRAM # pragma target 5.0 //顶点着色器,用于处理位置信息 # pragma vertex vert //片元着色器,用于处理颜色 # pragma fragment frag //几何着色器,DirectX 10新增的,介于顶点和片元着色器之间的可选着色器 # pragma geometry geo //引入空间转换宏 # include "UnityCG.cginc" float _LineLength ; fixed4 _LineColor ; //输入到顶点着色器的数据 struct v2g { //顶点位置 float4 pos :

Shader学习七,UnityCG.cginc

给你一囗甜甜゛ 提交于 2020-01-15 00:47:17
常用的着色器文件:E:\Other\install\Unity_2018.3.13f1\Unity\ Editor\Data\CGIncludes 我的安装路径是这个没有CGIncludes这个文件夹的可能就要去官网下载对应版本的着色器了 常用的文件如下: UnityCG.cginc:包含了最常用的帮助函数,宏和结构体等 UnityShaderVariables.cginc:在编译UnityShader时,会被自动包含进来。包含了许多内置的全局变量,如UNITY_MATRIX_MVP等 Lighting.cginc:包含各种内置的光照模型,如果编写的是SurfaceShader的话会自动包含进来 HLSLSupport.cginc:在编译UnityShader时,会自动包含进来。声明了很多用于跨平台编译的宏和定义 UnityCG.cginc中一些常用的结构体 appdata_base:可用于顶点着色器的输入,包含顶点位置,顶点法线,第一组纹理坐标 appdata_tan:可用于顶点着色器输入,包含顶点位置,顶点切线,顶点法线,第一组纹理坐标 appdata_full:可用于顶点着色器的输入,包含顶点位置,顶点切线,顶点法线,四组(或更多)纹理坐标 appdata_img:可用于顶点着色器的输入,包含顶点位置,第一组纹理坐标 v2f_img:可用于顶点着色器的输出

ThreeJS 给 Shader传参

一笑奈何 提交于 2020-01-14 23:31:43
参考: https://www.cnblogs.com/softimagewht/p/4750847.html ThreeJS 给 Shader传参 一、Shader三种变量类型(uniform, attribute 和varying) 1、uniform 顶点着色器 和 片元着色器 都可以使用 一般用来传递:变换矩阵,材质,光照参数和颜色等信息 用法: 外部(js)给着色器传数据 // 着色器代码 uniform vec4 u_FragColor ; void main ( ) { gl_FragColor = u_FragColor ; } // js代码 var u_FragColor = gl . getUniformLocation ( gl . program , 'u_FragColor' ) ; gl . uniform4f ( u_FragColor , 0.0 , 1.0 , 1.0 , 1.0 ) ; 2、attribute 只能在 顶点着色器 中使用 一般用来传递顶点的数据,如:顶点坐标,法线,纹理坐标,顶点颜色 用法: 外部(js)给着色器传数据 类型: float,vec2,vec3,vec4,mat2,mat3,mat4 // 着色器代码 attribute vec4 a_Position ; void main ( ) { gl_position =

LibGDX - Shader working on Desktop but not on Android

微笑、不失礼 提交于 2020-01-14 11:48:11
问题 I have written a simple program that renders a sphere in a 3d environment and colores it according to four light sources around the sphere. When I run the program on the desktop it works just fine but on an Android device the sphere is just plain colored. Here are images to illustrate what I am talking about: -> Desktop -> Android And here is the shader code: sphere.vert #ifdef GL_ES precision mediump float; #endif uniform mat4 u_projectionMatrix; uniform mat3 u_normalMatrix; uniform mat4 u

unity shader 着色器实例 代码+注释 【可调整贴图的 亮度、对比度、饱和度】

喜你入骨 提交于 2020-01-14 08:08:34
调整贴图的 亮度、对比度、饱和度的shader Shader "Custom/duibidu" { Properties { _MainTex ( "Albedo (RGB)" , 2 D ) = "white" { } _Brightness ( "Brightness" , Float ) = 1 //调整亮度 _Saturation ( "Saturation" , Float ) = 1 //调整饱和度 _Contrast ( "Contrast" , Float ) = 1 //调整对比度 } SubShader { Pass { ZTest Always Cull Off ZWrite Off Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM sampler2D _MainTex ; half _Brightness ; half _Saturation ; half _Contrast ; //vert和frag函数 # pragma vertex vert # pragma fragment frag # include "Lighting.cginc" struct appdata_t { float4 vertex : POSITION ; half4 color : COLOR ; float2 texcoord :

How to add fog to texture in shader (THREE.JS R76)

情到浓时终转凉″ 提交于 2020-01-14 03:55:35
问题 So firstly, I am aware of this post: ShaderMaterial fog parameter does not work My question is a bit different... I am trying to apply the fog in my three.js scene to a shader thats using a TEXTURE and I can't figure it out. My best guess as to what is supposed to go into the frag was: resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor); This works when the texture2D part is just a normal color but as a texture it doesn't render. THREE.glowShader = { vertexShader: [ `

Z-fighting solutions in depth test in OpenGL - how do they work?

折月煮酒 提交于 2020-01-12 04:40:33
问题 Description I've had major problems with Z-Fighting in OpenGL and I've spent quite some time finding solutions for this problem. Some of the ones I've found and I understand and didn't like: Moving polygons away from each other ( like glPolygonOffset in OpenGL ) Dividing the scene according to Z coordinate and drawing parts of the scene with separate clean z-buffers. The ones I don't understand: Using Projection Matrix https://software.intel.com/en-us/articles/alternatives-to-using-z-bias-to

Z-fighting solutions in depth test in OpenGL - how do they work?

冷暖自知 提交于 2020-01-12 04:40:27
问题 Description I've had major problems with Z-Fighting in OpenGL and I've spent quite some time finding solutions for this problem. Some of the ones I've found and I understand and didn't like: Moving polygons away from each other ( like glPolygonOffset in OpenGL ) Dividing the scene according to Z coordinate and drawing parts of the scene with separate clean z-buffers. The ones I don't understand: Using Projection Matrix https://software.intel.com/en-us/articles/alternatives-to-using-z-bias-to