texture

WebGL编程笔记3:纹理图片texture

北城以北 提交于 2020-03-29 17:41:06
HTML部分 <script type="text/javascript" src="gl-matrix.js"></script> <canvas id="myCanvas" width="400" height="400" style="border: 1px solid red"></canvas> JavaScript部分 以下两点若不注意texture2D有可能取不到值,一片黑色。 老的显卡只支持图片尺寸为2的n次幂的纹理图片。 TEXTURE_MAG_FILTER和TEXTURE_MIN_FILTER参数需要制定。 const vertex = ` attribute vec3 v3Position; uniform mat4 u_matrix; attribute vec2 inUv; varying vec2 outUv; void main() { gl_Position = u_matrix * vec4(v3Position, 1.0); outUv = inUv; } `; // texture2D(u_texture, vec2(outUv.x, outUv.y)); // texture2D(u_texture, outUv; // 从纹理texture中根据outUv坐标取色素rgba const fragment = ` precision

Toggle

﹥>﹥吖頭↗ 提交于 2020-03-09 20:00:37
public class demo : MonoBehaviour { public Texture texture; private bool textBool = false;toggle private bool textureBool = true; private void OnGUI() { if (!texture) { //判断图片是否参加 Debug.LogWarning("请添加一张图片"); return; } textBool=GUI.Toggle(new Rect(Screen.width / 8.5f, Screen.height / 7, Screen.height / 5, Screen.height / 5),textBool,"开关控件"); textureBool=GUI.Toggle(new Rect(Screen.width / 4, Screen.height / 7, Screen.height / 5, Screen.height / 5),textureBool,texture); } } 来源: https://www.cnblogs.com/zyz322/p/12450399.html

starling 笔记

瘦欲@ 提交于 2020-02-24 06:36:18
starling 笔记 : 基于Stage3Dg开发出来的一个可以使用GPU加速2D应用程序的框架。是一个渲染框架! 特色:直观,轻量,免费。 Starling与Sparrow框架很相近。 驱动关系: GPU-->OpenGL/ES2-DirectX-->stage3D-->starling 传统使用的Stage使用cup渲染,Starling使用GPU,减少CUP操作可以提升性能和体验。 flash 显示层次结构 :stage video-->stage3D-->Display List。(这里注意的是 原生flash显示对象会覆盖stage3D,因为dispalylist层次结构在前面) var starling:Starling=new Starling(rootClass,stage);//创建starling以对象 starling.start();//启动(这一步不能忘记了) Starling的构造函数 public function Starling(rootClass:Class, stage:flash.display.Stage, viewPort:Rectangle=null, stage3D:Stage3D=null, renderMode:String="auto") rootClass 参数期待被传入一个继承自starling.display

Camera.targetTexture和SetTargetBuffers的区别

只愿长相守 提交于 2020-02-21 14:15:25
知识点1:Camera.targetTexture https://docs.unity3d.com/ScriptReference/Camera-targetTexture.html public RenderTexture targetTexture; usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. this is done by creating a RenderTexture object and setting it as targetTexture on the camera. the camera will then render into that texture. when targetTexture is null, camera renders to screen. when rendering into a texture, the camera always renders into the whole texture; it is also possible to make camera render into separate RenderBuffers , or

Unity 视频缩略图获取

↘锁芯ラ 提交于 2020-01-20 08:25:44
IEnumerator GetVideoThumb(string urlpath,int index) { print(index); Transform go= Instantiate(VideoPlayerPrefab); VideoPlayer tmpVp= go.gameObject.AddComponent<VideoPlayer>(); go.gameObject.AddComponent<IndexNumber>(); go.GetComponent<IndexNumber>().index = index; tmpVp.source = VideoSource.Url; tmpVp.url = urlpath; tmpVp.sendFrameReadyEvents = true; //绑定的事件会不断调用 tmpVp.frameReady += OnNewFrame; tmpVp.Play(); yield return null; //while (tmpVp.texture == null|| tmpVp.isPlaying==false) //{ // yield return new WaitForSeconds(1.5f); //} //Texture2D videoFrameTexture = new Texture2D(Screen.width,

webgl 灰度shader

给你一囗甜甜゛ 提交于 2019-12-08 14:16:55
var canvasElement=document.getElementById('webgl'); var gl=canvasElement.getContext('webgl'); //顶点着色器源码 var vertexShaderSource = '' + 'attribute vec4 a_Position;'+//顶点位置坐标 'attribute vec2 a_TexCoord;' +//纹理坐标 'varying vec2 v_TexCoord;'+//插值后纹理坐标 'void main(){' + 'gl_Position = a_Position;' +//逐顶点处理 'v_TexCoord = a_TexCoord;' +//纹理坐标插值计算 '}'; //片元着色器源码 var fragShaderSource = '' + 'precision highp float;' +//所有float类型数据的精度是lowp 'varying vec2 v_TexCoord;'+//接收插值后的纹理坐标 'uniform sampler2D u_Sampler;' +//纹理图片像素数据 'void main(){' + //采集纹素 'vec4 texture = texture2D(u_Sampler,v_TexCoord);' + /

Textures_练习四

自闭症网瘾萝莉.ら 提交于 2019-12-05 20:27:28
使用一个uniform变量作为mix函数的第三个参数来改变两个纹理可见度,使用上和下键来改变箱子或笑脸的可见度 fs.in 1 #version 330 core 2 out vec4 FragColor; 3 4 in vec3 ourColor; 5 in vec2 TexCoord; 6 7 // texture samplers 8 uniform sampler2D texture1; 9 uniform sampler2D texture2; 10 uniform float rate; 11 12 void main() 13 { 14 // linearly interpolate between both textures (80% container, 20% awesomeface) 15 FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), rate); 16 } View Code main函数 1 #include <glad/glad.h> 2 #include <GLFW/glfw3.h> 3 #define STB_IMAGE_IMPLEMENTATION 4 #include <stb/stb_image.h> 5 6 #include <Shader

OpenGL 总结以下坐标系统之前

不问归期 提交于 2019-12-05 03:18:15
迄今为止,2D平面就已经差不多OK了。为了更好的学习3D,总结一些需要注意的小细节或者是小套路。 首先,还是要多写代码,好多东西都是记住的 使用 glfw 那一套一定要熟练哦~ glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", NULL, NULL); if (window == NULL) { std::cout << "window init error" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glewExperimental = true; if (glewInit() != GLEW_OK) { std::cout << "glew init error" << std::endl; glfwTerminate(); return -1; } glViewport

Texture Streaming

馋奶兔 提交于 2019-12-04 11:18:32
TextureStreamingJob崩溃分析一则: https://blog.uwa4d.com/archives/TechSharing_163.html TextureStreaming-API: https://docs.unity3d.com/jp/current/Manual/TextureStreaming-API.html Asynchronous Texture Upload: https://docs.unity3d.com/Manual/AsyncTextureUpload.html 优化加载性能:了解异步上传管线AUP UWA学堂:Unity引擎加载模块和内存管理的量化分析及优化方法 来源: https://www.cnblogs.com/TravelingLight/p/11857471.html

What is a dependent texture read?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been reading papers on computer graphics, and every so often I come across the term "dependent texture read" or "dependent texture fetch" used in the context of querying textures in shader code. What is a dependent texture read, and what is the difference between this and a "normal" texture read? 回答1: A "dependent texture read" is when return values from one texture lookup (or other in-shader computations) are used to determine WHERE to look up from a second texture. An important implication is that the texture coordinates (where you