shader

Speed of cos() and sin() function in GLSL shaders?

不问归期 提交于 2019-12-01 13:52:01
问题 I'm interested in information about the speed of sin() and cos() in Open GL Shader Language . The GLSL Specification Document indicates that: The built-in functions basically fall into three categories: ... ... They represent an operation graphics hardware is likely to accelerate at some point. The trigonometry functions fall into this category. EDIT: As has been pointed out, counting clock cycles of individual operations like sin() and cos() doesn't really tell the whole performance story.

成员函数模板

≡放荡痞女 提交于 2019-12-01 13:40:56
Code Snippet using namespace Magnum; using namespace Magnum::Math::Literals; class CameraObject; class ModelViewerApp; class CameraObject: public Interconnect::Receiver, public Object3D { public: CameraObject(ModelViewerApp& app); void mousePressEvent(Platform::Application::MouseEvent& event) {} void mouseReleaseEvent(Platform::Application::MouseEvent& event) {} void mouseMoveEvent(Platform::Application::MouseMoveEvent& event) { ... event.setAccepted(true); } private: Vector2i _prevPos{-1, -1}; }; class ModelViewerApp: public Platform::Application, public Interconnect::Emitter{ private:

Do I have to use shared vertices in mesh in Unity?

断了今生、忘了曾经 提交于 2019-12-01 12:09:42
I want to create procedurally generated landscape meshes with a flat shaded look in Unity3D. I thought it would be the best to create three unique vertices per triangle and use one calculated normal for the vertices. Building this mesh would lead to redundant vertex position information. (Would it have an impact on render time?) Anyway... the problem is that I would like to use shading techniques e.g. ambient occlusion on this mesh. I don't want to mess up the mesh topology that Unity3D expects for its shaders. Is it better to create the meshwith shared vertices, add perhaps a custom vertex

Analysis of a shader in VR

别说谁变了你拦得住时间么 提交于 2019-12-01 11:35:12
问题 I would like to create a shader like that that takes world coordinates and creates waves. I would like to analyse the video and know the steps that are required. I'm not looking for codes, I'm just looking for ideas on how to implement that using GLSL or HLSL or any other language. Here low quality and fps GIF in case link broke. Here is the fragment shader: #version 330 core // Interpolated values from the vertex shaders in vec2 UV; in vec3 Position_worldspace; in vec3 Normal_cameraspace; in

why Particle system with shader doesn't work? three.js

安稳与你 提交于 2019-12-01 10:50:16
Hi can anyone help me whith this? I have this shader, it works with THREE.Mesh but doesn't with THREE.Particlesystem? I want each particle to have a portion of a given map(texture) and change their positions accordingly, something like this http://www.chromeexperiments.com/detail/webcam-displacement/?f=webgl <script id="vs" type="x-shader/x-vertex"> uniform sampler2D map; varying vec2 vUv; void main() { vUv = uv; vec4 color = texture2D( map, vUv ); float value = ( color.r + color.g + color.b ) / 3.0; vec4 pos = vec4( position.xy, value * 100.0, 1.0 ); gl_PointSize = 20.0; gl_Position =

comparing methods of creating skybox material in three.js

别等时光非礼了梦想. 提交于 2019-12-01 09:07:06
When it comes to making skyboxes in three.js, I have seen two different schools of thought. Assuming that we have the code var imagePrefix = "images/mountains-"; var directions = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"]; var imageSuffix = ".jpg"; var skyGeometry = new THREE.CubeGeometry( 10000, 10000, 10000 ); In both methods, one creates a really big cube and applies textures. The difference is whether shaders are used. For example: Material without using shader: var materialArray = []; for (var i = 0; i < 6; i++) materialArray.push( new THREE.MeshBasicMaterial({ map: THREE.ImageUtils

资源重复问题、针对shader和Unity自带资源

两盒软妹~` 提交于 2019-12-01 08:25:47
1.资源重复问题:项目的资源可以通过AssetBundle Browser找出 2.针对shader和Unity自带资源; 主要存在的问题: (1)使用默认shader,材质,会导致shader的重复打包,增大包体。 Shader:项目中使用到的shader都需要放入shader的AssetBundle中,有两种方式: (1)改名放入到项目(需要都重新指定,不方便使用) (2)不改名直接放入 不改名的方式放入项目内,新指定的在项目已有的shader,都会指定为项目内的路径,不会造成重复打包。 但之前创建的Material不会自动指定为项目内路径,还是会重复打包,需要重新指定Shader 现在默认shader项目内路径为:Assets/Resources/GameRes/shaders/default/ 旧的shader可以使用代码一键重新指定,会自动指定为项目内路径,不会重复打包,但部分参数可能会修改,需要检查一下 所有使用默认的资源的都要放到项目内,避免重复打包。建议这些默认的材质都在项目内Copy一份,放到单独一个AssetBundle中 (1)Particle System 默认使用的材质和shader都是内置的,会重复打包。 (2)场景里天空盒设置使用默认SkyBox材质会每个场景重复打包 来源: https://www.cnblogs.com/wayne1984/p

Using lights in three.js shader

给你一囗甜甜゛ 提交于 2019-12-01 08:05:50
问题 I'm trying to access the scene's lights from a shader in three.js. This question is nearly a duplicate of Three.js ShaderMaterial issue with lights but the comments on that question aren't helping me resolve the issue. Here is the vertex shader: #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; int shadow; float shadowBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; #endif varying vec3 color; void main()

comparing methods of creating skybox material in three.js

岁酱吖の 提交于 2019-12-01 06:46:30
问题 When it comes to making skyboxes in three.js, I have seen two different schools of thought. Assuming that we have the code var imagePrefix = "images/mountains-"; var directions = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"]; var imageSuffix = ".jpg"; var skyGeometry = new THREE.CubeGeometry( 10000, 10000, 10000 ); In both methods, one creates a really big cube and applies textures. The difference is whether shaders are used. For example: Material without using shader: var materialArray =

Run on buffer object and change it's data by shader? [closed]

半世苍凉 提交于 2019-12-01 06:29:21
Is there a way to run a shader on Buffer Object and modifying it with some other data with shader? In other words: Is there a way to create uniform global variable in shader and modifiable? Yes, though it depends on your hardware. All of these mechanisms require hardware capable of GL 3.x or above. Transform Feedback This allows you to capture the results of vertex processing in one or more buffer objects. This is the most crude mechanism, because each vertex shader can only access the vertex data it is given as input, and can only write to the output vertex. So the shader can't access the