IOS – OpenGL ES 圖像浮雕3d效果 GPUImageEmbossFilter

来源:https://www.cnblogs.com/shuopython/archive/2022/06/24/16410433.html
-Advertisement-
Play Games

目錄 一.簡介 二.效果演示 三.源碼下載 四.猜你喜歡 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 基礎 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 轉場 零基礎 O ...


目錄

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 基礎

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 轉場

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 特效

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 函數

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES GPUImage 使用

零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES GLSL 編程

一.簡介

GPUImage 共 125 個濾鏡, 分為四類

1、Color adjustments : 31 filters , 顏色處理相關
2、Image processing : 40 filters , 圖像處理相關.
3、Blending modes : 29 filters , 混合模式相關.
4、Visual effects : 25 filters , 視覺效果相關.

GPUImageEmbossFilter 屬於 GPUImage 圖像視覺效果相關,用來處理圖像浮雕 3d 效果。shader 源碼如下:

/******************************************************************************************/
//@Author:猿說編程
//@Blog(個人博客地址): www.codersrc.com
//@File:IOS – OpenGL ES 圖像浮雕3d效果 GPUImageEmbossFilter
//@Time:2022/06/10 06:30
//@Motto:不積跬步無以至千里,不積小流無以成江海,程式人生的精彩需要堅持不懈地積累!
/******************************************************************************************/

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImage3x3ConvolutionFragmentShaderString = SHADER_STRING
(
 precision highp float;

 uniform sampler2D inputImageTexture;

 uniform mediump mat3 convolutionMatrix;

 varying vec2 textureCoordinate;
 varying vec2 leftTextureCoordinate;
 varying vec2 rightTextureCoordinate;

 varying vec2 topTextureCoordinate;
 varying vec2 topLeftTextureCoordinate;
 varying vec2 topRightTextureCoordinate;

 varying vec2 bottomTextureCoordinate;
 varying vec2 bottomLeftTextureCoordinate;
 varying vec2 bottomRightTextureCoordinate;

 void main()
 {
     mediump vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
     mediump vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;
     mediump vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;
     mediump vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);
     mediump vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
     mediump vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
     mediump vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
     mediump vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;
     mediump vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;

     mediump vec3 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];
     resultColor += leftColor * convolutionMatrix[1][0] + centerColor.rgb * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];
     resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];

     gl_FragColor = vec4(resultColor, centerColor.a);
 }
);
#else
NSString *const kGPUImage3x3ConvolutionFragmentShaderString = SHADER_STRING
(
 uniform sampler2D inputImageTexture;

 uniform mat3 convolutionMatrix;

 varying vec2 textureCoordinate;
 varying vec2 leftTextureCoordinate;
 varying vec2 rightTextureCoordinate;

 varying vec2 topTextureCoordinate;
 varying vec2 topLeftTextureCoordinate;
 varying vec2 topRightTextureCoordinate;

 varying vec2 bottomTextureCoordinate;
 varying vec2 bottomLeftTextureCoordinate;
 varying vec2 bottomRightTextureCoordinate;

 void main()
 {
     vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
     vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;
     vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;
     vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);
     vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
     vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
     vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
     vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;
     vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;

     vec3 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];
     resultColor += leftColor * convolutionMatrix[1][0] + centerColor.rgb * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];
     resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];

     gl_FragColor = vec4(resultColor, centerColor.a);
 }
);
#endif

二.效果演示

使用 **GPUImageEmbossFilter 完成圖像浮雕 3d 效果**,原圖如下:

使用 **GPUImageEmbossFilter 完成**圖像浮雕 3d 效果****,效果如下:

三.源碼下載

OpenGL ES Demo 下載地址 : IOS – OpenGL ES 圖像浮雕 3d 效果 GPUImageEmbossFilter

四.猜你喜歡

  1. IOS – OPenGL ES 設置圖像亮度 GPUImageBrightnessFilter
  2. IOS – OPenGL ES 調節圖像曝光度 GPUImageExposureFilter
  3. IOS – OpenGL ES 調節圖像對比度 GPUImageContrastFilter
  4. IOS – OPenGL ES 調節圖像飽和度 GPUImageSaturationFilter
  5. IOS – OPenGL ES 調節圖像伽馬線 GPUImageGammaFilter
  6. IOS – OpenGL ES 調節圖像反色 GPUImageColorInvertFilter
  7. IOS – OpenGL ES 調節圖像褐色 GPUImageSepiaFilter
  8. IOS – OpenGL ES 調節圖像灰色 GPUImageGrayscaleFilter
  9. IOS – OpenGL ES 調節圖像 RGB 通道 GPUImageRGBFilter
  10. IOS – OpenGL ES 調節圖像不透明度 GPUImageOpacityFilter
  11. IOS – OpenGL ES 調節圖像陰影 GPUImageHighlightShadowFilter
  12. IOS – OpenGL ES 調節圖像色彩替換 GPUImageFalseColorFilter
  13. GPUImage – 色彩直方圖 GPUImageHistogramFilter
  14. GPUImage – 色彩直方圖 GPUImageHistogramGenerator
  15. GPUImage – 像素平均色值 GPUImageAverageColor
  16. GPUImage – 亮度平均 GPUImageLuminosity
  17. IOS – OpenGL ES 調節圖像色度 GPUImageHueFilter
  18. IOS – OpenGL ES 指定顏色摳圖 GPUImageChromaKeyFilter
  19. IOS – OpenGL ES 調節圖像白平衡/色溫 GPUImageWhiteBalanceFilter
  20. IOS – OpenGL ES 設置圖像 lookup 濾鏡 GPUImageLookupFilter
  21. IOS – OpenGL ES 設置圖像濾鏡 GPUImageAmatorkaFilter
  22. IOS – OpenGL ES 設置圖像濾鏡 GPUImageSoftEleganceFilter
  23. IOS – OpenGL ES 設置圖像銳化 GPUImageSharpenFilter
  24. IOS – OpenGL ES 繪製十字 GPUImageCrosshairGenerator
  25. IOS – OpenGL ES 繪製線條 GPUImageLineGenerator
  26. IOS – OpenGL ES 設置圖像黑白燥點 GPUImageLocalBinaryPatternFilter
  27. IOS – OpenGL ES 設置圖像卡通效果(黑色粗線描邊) GPUImageToonFilter
  28. IOS – OpenGL ES 桑原濾波/水粉畫模糊效果 GPUImageKuwaharaFilter
  29. IOS – OpenGL ES 黑白馬賽克效果 GPUImageMosaicFilter
  30. IOS – OpenGL ES 像素化馬賽克效果 GPUImagePixellateFilter
  31. IOS – OpenGL ES 同心圓像素化馬賽克效果 GPUImagePolarPixel
  32. IOS – OpenGL ES 黑白網狀效果 GPUImageCrosshatchFilter
  33. IOS – OpenGL ES 色彩丟失/模糊效果 GPUImageColorPackingFilter
  34. IOS – OpenGL ES 圖像暈影 GPUImageVignetteFilter
  35. IOS – OpenGL ES 圖像漩渦 GPUImageSwirlFilter
  36. IOS – OpenGL ES 圖像魚眼擴散效果 GPUImageBulgeDistortionFilter
  37. IOS – OpenGL ES 圖像魚眼移動效果 GPUImageBulgeDistortionFilter
  38. IOS – OpenGL ES 圖像凹面鏡移動效果 GPUImagePinchDistortionFilter
  39. IOS – OpenGL ES 圖像凹面鏡放大效果 GPUImagePinchDistortionFilter
  40. IOS – OpenGL ES 圖像哈哈鏡效果 GPUImageStretchDistortionFilter
  41. IOS – OpenGL ES 圖像水晶球效果 GPUImageGlassSphereFilter
  42. IOS – OpenGL ES 圖像球形折射 GPUImageSphereRefractionFilter
  43. IOS – OpenGL ES 圖像色調分離噪點效果 GPUImagePosterizeFilter
  44. IOS – OpenGL ES 圖像 CGA 色彩濾鏡 GPUImageCGAColorspaceFilter
  45. IOS – OpenGL ES 圖像柏林噪點/花邊噪點 GPUImagePerlinNoiseFilter
  46. IOS – OpenGL ES 圖像加亮邊緣 GPUImage3x3ConvolutionFilter
  47. IOS – OpenGL ES 圖像浮雕 3d 效果 GPUImageEmbossFilter

本文由博客 - 猿說編程 猿說編程 發佈!


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 程式包編譯安裝的步驟: 源代碼-->預處理-->編譯-->彙編-->鏈接-->執行 多文件:文件中的代碼之間,很可能存在跨文件依賴關係 編譯源碼的項目工具 使用相關的項目管理工具可以大大減少編譯過程的複雜度 根據源碼類型來對這些工具進行分類: C、C++的源碼編譯:使用 make 項目管理器 con ...
  • 1、簡述 binlog 二進位日誌文件,這個文件記錄了MySQL所有的DML操作。通過binlog日誌我們可以做數據恢復,增量備份,主主複製和主從複製等等。 2、Docker中無法使用vim問題解決 https://blog.csdn.net/Tomwildboar/article/details/ ...
  • Android multiple back stacks導航 談談android中多棧導航的幾種實現. 什麼是multiple stacks 當用戶在app里切換頁面時, 會需要向後回退到上一個頁面, 頁面歷史被保存在一個棧里. 在Android里我們經常說"back stack". 有時候在app ...
  • 隨著人們對生活的儀式感的追求,移動設備、可穿戴設備、智能家居設備、車載信息娛樂系統也變得越來越流行。在這些應用上,滑鼠、鍵盤這樣的交互方式不再便捷,而語音作為人類之間最自然的交流方式,語音識別技術儼然已成為各大應用的“標配”。語音識別場景應用十分廣泛,如語音輸入法、語音搜索、實時字幕、游戲娛樂、社交 ...
  • 首先網上很多教程是關於使用swift SMAMB2包的,大部分都是 pod "SMAMB2" 這種方式還是非常簡單的,如果僅僅是這樣還不至於專門寫一篇文章來紀念他。問題就出在我的項目需要用到SMB協議去讀取文件,但是並不是直接讀取! 通俗一點來講就是我的用法和 SMAMB2包提供的用法不同! 那就意 ...
  • Next.js 提供了 Fast-Refresh 能力,它可以為您對 React 組件所做的編輯提供即時反饋。 但是,當你通過 Markdown 文件提供網站內容時,由於 Markdown 不是 React 組件,熱更新將失效。 怎麼做 解決該問題可從以下幾方面思考: 伺服器如何監控文件更新 伺服器 ...
  • dll ? 動態鏈接庫英文為DLL,是Dynamic Link Library的縮寫。DLL是一個包含可由多個程式,同時使用的代碼和數據的庫。 起因 在查看hzero前端項目框架介紹時提到了dll,外加之前經常看見dll文件,於是有了興趣瞭解一下 webpack dll。 webpack官網介紹 D ...
  • 【layui2.6.8】有多個文件上傳的組件需要根據後臺數據在頁面載入時動態渲染在一個彈框裡面。彈窗從table表格數據的【編輯】按鈕打開,根據點擊行展示不同的文件,對文件進行查詢、刪除、下載等管理。問題:選擇文件,不上傳,關閉彈窗再打開,剛選的文件雖然不見了,但依然能上傳那個文件,需要打開彈窗時清 ...
一周排行
    -Advertisement-
    Play Games
  • Dapr Outbox 是1.12中的功能。 本文只介紹Dapr Outbox 執行流程,Dapr Outbox基本用法請閱讀官方文檔 。本文中appID=order-processor,topic=orders 本文前提知識:熟悉Dapr狀態管理、Dapr發佈訂閱和Outbox 模式。 Outbo ...
  • 引言 在前幾章我們深度講解了單元測試和集成測試的基礎知識,這一章我們來講解一下代碼覆蓋率,代碼覆蓋率是單元測試運行的度量值,覆蓋率通常以百分比表示,用於衡量代碼被測試覆蓋的程度,幫助開發人員評估測試用例的質量和代碼的健壯性。常見的覆蓋率包括語句覆蓋率(Line Coverage)、分支覆蓋率(Bra ...
  • 前言 本文介紹瞭如何使用S7.NET庫實現對西門子PLC DB塊數據的讀寫,記錄了使用電腦模擬,模擬PLC,自至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1.Windows環境下鏈路層網路訪問的行業標準工具(WinPcap_4_1_3.exe)下載鏈接:http ...
  • 從依賴倒置原則(Dependency Inversion Principle, DIP)到控制反轉(Inversion of Control, IoC)再到依賴註入(Dependency Injection, DI)的演進過程,我們可以理解為一種逐步抽象和解耦的設計思想。這種思想在C#等面向對象的編 ...
  • 關於Python中的私有屬性和私有方法 Python對於類的成員沒有嚴格的訪問控制限制,這與其他面相對對象語言有區別。關於私有屬性和私有方法,有如下要點: 1、通常我們約定,兩個下劃線開頭的屬性是私有的(private)。其他為公共的(public); 2、類內部可以訪問私有屬性(方法); 3、類外 ...
  • C++ 訪問說明符 訪問說明符是 C++ 中控制類成員(屬性和方法)可訪問性的關鍵字。它們用於封裝類數據並保護其免受意外修改或濫用。 三種訪問說明符: public:允許從類外部的任何地方訪問成員。 private:僅允許在類內部訪問成員。 protected:允許在類內部及其派生類中訪問成員。 示 ...
  • 寫這個隨筆說一下C++的static_cast和dynamic_cast用在子類與父類的指針轉換時的一些事宜。首先,【static_cast,dynamic_cast】【父類指針,子類指針】,兩兩一組,共有4種組合:用 static_cast 父類轉子類、用 static_cast 子類轉父類、使用 ...
  • /******************************************************************************************************** * * * 設計雙向鏈表的介面 * * * * Copyright (c) 2023-2 ...
  • 相信接觸過spring做開發的小伙伴們一定使用過@ComponentScan註解 @ComponentScan("com.wangm.lifecycle") public class AppConfig { } @ComponentScan指定basePackage,將包下的類按照一定規則註冊成Be ...
  • 操作系統 :CentOS 7.6_x64 opensips版本: 2.4.9 python版本:2.7.5 python作為腳本語言,使用起來很方便,查了下opensips的文檔,支持使用python腳本寫邏輯代碼。今天整理下CentOS7環境下opensips2.4.9的python模塊筆記及使用 ...