Code Monkey home page Code Monkey logo

Comments (5)

wcandillon avatar wcandillon commented on July 20, 2024 1

I'm closing this, it looks like it will be fixed upstream with Skia: https://groups.google.com/g/skia-discuss/c/WzZaQU3-Lds

I hope this helps

from react-native-skia.

wcandillon avatar wcandillon commented on July 20, 2024

from react-native-skia.

daehyeonmun2021 avatar daehyeonmun2021 commented on July 20, 2024

@wcandillon I tried the code below on the web but it doesn't work. 🥲

const half3 W = half3(0.2125, 0.7154, 0.0721);

half3 overlayBlender(half3 Color, half3 filter) {
  half3 filter_result;
  float luminance = dot(filter, W);
  
  if (luminance < 0.5)
    filter_result = 2. * filter * Color;
  else
    filter_result = 1. - (1. - (2. * (filter - 0.5))) * (1. - Color);
    
  return filter_result;
}

half3 BrightnessContrastSaturation(half3 color, float brt, float con, float sat) {
  half3 black = half3(0., 0., 0.);
  half3 middle = half3(0.5, 0.5, 0.5);
  float luminance = dot(color, W);
  half3 gray = half3(luminance, luminance, luminance);
  
  half3 brtColor = mix(black, color, brt);
  half3 conColor = mix(middle, brtColor, con);
  half3 satColor = mix(gray, conColor, sat);
  return satColor;
}

half4 setFilter(vec2 uv) {    
  half3 imageColor = iImage1.eval(uv).rgb;

  // Adjust the brightness/contrast/saturation
  float T_bright = 1.0;
  float T_contrast = 1.0;
  float T_saturation = 1.0;
  half3 bcs_result = BrightnessContrastSaturation(imageColor, T_bright, T_contrast, T_saturation);
  
  // More red, less blue
  half3 rb_result = half3(bcs_result.r * 1.3, bcs_result.g, bcs_result.b * 0.9);
  
  // Add filter (overlay blending)
  half3 after_filter = mix(rb_result, overlayBlender(rb_result, imageColor), 0.55);
  
  return half4(after_filter, 1);
}

half4 main(float2 fragCoord) {  
  return setFilter(fragCoord);
}

from react-native-skia.

wcandillon avatar wcandillon commented on July 20, 2024

Thank you @daehyeonmun2021 for such a concise and nicely reproducible example. if you replace the use of the filter variable name, it will work nicely on Android too. I am currently investigating why this error wasn't nicely throw on the React Native side.

from react-native-skia.

daehyeonmun2021 avatar daehyeonmun2021 commented on July 20, 2024

@wcandillon Thanks :D

from react-native-skia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.