Thursday, May 8, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

Model Texture Transition and Procedural Radial Noise using WebGL

May 2, 2024
in Cloud & Programming
Reading Time: 2 mins read
0 0
A A
0
Share on FacebookShare on Twitter


Today, I’d like to share a cool WebGL experiment that draws inspiration from a discovery on Pinterest. The demo highlights two interesting visual effects. Firstly, it features a seamless texture transition on a 3D model of a can, accompanied by a dynamic noise effect. Secondly, it incorporates a radial noise field that pulsates from the center, extending beyond the boundaries of the screen.

While React Three Fiber facilitates the setup, the real magic resides in the shader code, so this shouldn’t be an obstacle.

Background Effect

For this effect we will have a plane geometry that fits the screen. Then we will mostly focus on what happens on the fragmentShader. So we create a ring shape that pulsates on u_progress transition from 0 to 1:

float radius = 1.5;
float outerProgress = clamp(1.1*u_progress, 0., 1.);
float innerProgress = clamp(1.1*u_progress – 0.05, 0., 1.);

float innerCircle = 1. – smoothstep((innerProgress-0.4)*radius, innerProgress*radius, dist);
float outerCircle = 1. – smoothstep((outerProgress-0.1)*radius, innerProgress*radius, dist);

float displacement = outerCircle-innerCircle;

//…

gl_FragColor = vec4(vec3(displacement), 1.0);

We proceed by applying a procedural noise using classic 3D Perlin Noise obtained from here:

vec2 newUv = (vUv – vec2(0.5)) * vec2(u_aspect,1.);

float dist = length(newUv);

float density = 1.8 – dist;

float noise = cnoise(vec4(newUv*40.*density, u_time, 1.));

And to spice it up a little bit we will add some grain effect 🧂:

float grain = (fract(sin(dot(vUv, vec2(12.9898,78.233)*2000.0)) * 43758.5453);

Model Texture Transition

For mimicking the drink flavor change in my demo, I opted for a simple color transition in the can model texture. However, you can achieve the transition using textures instead. To begin, we transform our glb model into declarative and reusable JSX components, a task conveniently handled by gltfjsx tool.

Subsequently, we modify the material of the can body using the onBeforeCompile method.

useEffect(() => {
materials.Body.onBeforeCompile = (shader) => {
shader.uniforms = Object.assign(shader.uniforms, uniforms);

//…

shader.fragmentShader = shader.fragmentShader.replace(
`#include `,
`
#include

//…

`
);
};
}, [uniforms]);

Then, in the fragmentShader we will mix the the two colors with a noise mask in the seam:

//…

diffuseColor.rgb += mix(u_color1,u_color2,mask);

//…

Another nice feature provided by drei‘s library is PresentationControls, which offers us the capability to rotate the model effortlessly right out of the box:

//…



//..

Final words

I hope you enjoyed this short walk-through and the demo has been inspiring for you. There’s endless potential for customization and creativity, so feel free to play around with it and adjust values. Who knows, you may end up with something even cooler ✨

References and Credits

Reaction-Diffusion Compute Shader in WebGPU



Source link

Tags: 3d canmodelNoiseProceduralRadialTexturethree.js effecttransitionwebglwebgl can
Previous Post

The Unsexy Future of Generative AI Is Enterprise Apps

Next Post

Go DESi raises Rs 41 crore from Aavishkaar Capital, others

Related Posts

Top 20 Javascript Libraries You Should Know in 2024
Cloud & Programming

Top 20 Javascript Libraries You Should Know in 2024

June 10, 2024
Simplify risk and compliance assessments with the new common control library in AWS Audit Manager
Cloud & Programming

Simplify risk and compliance assessments with the new common control library in AWS Audit Manager

June 6, 2024
Simplify Regular Expressions with RegExpBuilderJS
Cloud & Programming

Simplify Regular Expressions with RegExpBuilderJS

June 6, 2024
How to learn data visualization to accelerate your career
Cloud & Programming

How to learn data visualization to accelerate your career

June 6, 2024
BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager
Cloud & Programming

BitTitan Announces Seasoned Tech Leader Aaron Wadsworth as General Manager

June 6, 2024
Copilot Studio turns to AI-powered workflows
Cloud & Programming

Copilot Studio turns to AI-powered workflows

June 6, 2024
Next Post
Go DESi raises Rs 41 crore from Aavishkaar Capital, others

Go DESi raises Rs 41 crore from Aavishkaar Capital, others

Bridging the Binary Gap: Challenges in Training Neural Networks to Decode and Summarize Code

Bridging the Binary Gap: Challenges in Training Neural Networks to Decode and Summarize Code

US Federal Prosecutors Investigate Block Inc. for Compliance Violations

US Federal Prosecutors Investigate Block Inc. for Compliance Violations

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

A Complete Guide to BERT with Code | by Bradney Smith | May, 2024

May 19, 2024
A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

April 10, 2024
Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

Part 1: ABAP RESTful Application Programming Model (RAP) – Introduction

November 20, 2023
Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

Saginaw HMI Enclosures and Suspension Arm Systems from AutomationDirect – Library.Automationdirect.com

December 6, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In