shader

How to make a normal map in THREE.js correctly?

断了今生、忘了曾经 提交于 2019-12-06 03:24:48
问题 I just tried to apply the Normal map Ninja demo to a cube in my scene with the following code - using new latest Three.js version from dev branch: // common material parameters var ambient = 0x050505, diffuse = 0x331100, specular = 0xffffff, shininess = 10, scale = 23; // normal map shader var shader = THREE.ShaderUtils.lib[ "normal" ]; var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); uniforms[ "enableAO" ].value = true; uniforms[ "enableDiffuse" ].value = false; uniforms[

SCN shader modifier in metal - pass uniform to shader

*爱你&永不变心* 提交于 2019-12-06 02:58:23
I'm trying to use shaders modifiers with Metal. I cannot figure out to declare uniforms... So far my fragment modifier is: // color changes #pragma arguments float4x4 u_color_transformation; #pragma body _output.color.rgb = vec3(1.0) - (u_color_transformation * _output.color).rgb; This outputs a purple texture, with no log.. If I just have _output.color.rgb = (u_color_transformation * _output.color).rgb , things are ok. I think I'm following the doc but maybe not! The uniform is set with: material.shaderModifiers = [ SCNShaderModifierEntryPoint.fragment: theShaderAbove ] material.setValue

iPhone iOS5 querying OpenGL ES 2.0 pipeline objects if they are hidden in the view or not…“Occlusion”

元气小坏坏 提交于 2019-12-06 02:28:25
问题 EXT_occlusion_query_boolean is new with OS5.0, it looks to me like not a single person on the entire internet has posted about these new extensions nor used this code.... so here they are set up properly...which is not documented anywhere as far as i can tell... you can imagine how they would go in your code from this little sudo code here: import UIKit/UIKit.h import GLKit/GLKit.h import "GLProgram.h" GLuint testBox,hasBeenTested,theParams; //... glGenQueriesEXT(1, &testBox); glBeginQueryEXT

Most Efficient way of Multi-Texturing - iOS, OpenGL ES2, optimization

喜你入骨 提交于 2019-12-06 01:53:51
问题 I'm trying to find the most efficient way of handling multi-texturing in OpenGL ES2 on iOS. By 'efficient' I mean the fastest rendering even on older iOS devices (iPhone 4 and up) - but also balancing convenience. I've considered (and tried) several different methods. But have run into a couple of problems and questions. Method 1 - My base and normal values are rgb with NO ALPHA. For these objects I don't need transparency. My emission and specular information are each only one channel. To

3D Graphics Batching

筅森魡賤 提交于 2019-12-06 01:05:46
问题 A lot of sites/articles say 'batch! batch! batch!'. Can someone explain what 'batching' represents with respect to shaders? Namely, does changing textures changing arbitrary shader variables mean something can't be 'batched'? (Sorry if this is a retarded question :D) 回答1: The easiest way to summarize it is to try to make as few API calls as you can to draw what you need to draw. Using vertex arrays or VBOs (not even optional in modern APIs), texture atlases and avoiding the need for state

高级UI晋升之自定义View实战(五)

强颜欢笑 提交于 2019-12-06 00:14:55
更多Android高级架构进阶视频学习请点击: https://space.bilibili.com/474380680 本篇文章将从自定义View利器Canvas和Paint来进行详解 一、Canvas 为了后文更为方便的讲解Canvas的常用方法的使用,我们先来做一些准备工作,创建一个自定义View框架,先初始化一下Paint画笔,并设置相关方法: public class StudyView extends View { private Paint mPaint; private Context mContext; public StudyView(Context context) { super(context); init(context); } public StudyView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(context); } private void init(Context context) { mContext = context; mPaint = new Paint(); mPaint.setAntiAlias(true); // 消除锯齿 mPaint.setStrokeWidth(5); // 设置笔尖宽度 mPaint

shader 3D物体透明遮罩

梦想的初衷 提交于 2019-12-06 00:13:30
Shader"Custom/Mask"{ SubShader{ //Geometry=2000 Tags{"Queue" = "Geometry-10"} Lighting off //相当于小于或者等于本身深度值时,该物体渲染 ZTest LEqual //打开深度写入 ZWrite On //通道遮罩,为0时不写入任何颜色通道,除了深度缓存 ColorMask 0 Pass{} } } 效果如图 不能在skybox 环境下使用 来源: https://www.cnblogs.com/pz904/p/11952958.html

Three.js, custom shader and png texture with transparency

瘦欲@ 提交于 2019-12-05 23:51:48
问题 I have an extremely simple PNG texture: a grey circle with a transparent background. I use it as a uniform map for a THREE.ShaderMaterial : var uniforms = THREE.UniformsUtils.merge( [basicShader.uniforms] ); uniforms['map'].value = THREE.ImageUtils.loadTexture( "img/particle.png" ); uniforms['size'].value = 100; uniforms['opacity'].value = 0.5; uniforms['psColor'].value = new THREE.Color( 0xffffff ); Here is my fragment shader (just part of it): gl_FragColor = vec4( psColor, vOpacity ); gl

Trouble with imageStore() (OpenGL 4.3)

◇◆丶佛笑我妖孽 提交于 2019-12-05 23:12:29
I'm trying to output some data from compute shader to a texture, but imageStore() seems to do nothing. Here's the shader: #version 430 layout(RGBA32F) uniform image2D image; layout (local_size_x = 1, local_size_y = 1) in; void main() { imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(0.0f, 1.0f, 1.0f, 1.0f)); } and the application code is here: GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_FLOAT, 0); glBindImageTexture(0, tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F); glUseProgram(program-

Per-Vertex Normals from perlin noise?

谁说胖子不能爱 提交于 2019-12-05 22:13:03
问题 I'm generating terrain in Opengl geometry shader and am having trouble calculating normals for lighting. I'm generating the terrain dynamically each frame with a perlin noise function implemented in the geometry shader. Because of this, I need an efficient way to calculate normals per-vertex based on the noise function (no texture or anything). I am able to take cross product of 2 side to get face normals, but they are generated dynamically with the geometry so I cannot then go back and