Author Topic: Migrating lightmix interactiveness to HTML5 or the like.. ?  (Read 2852 times)

2017-09-17, 09:42:51

vkiuru

  • Active Users
  • **
  • Posts: 320
    • View Profile
Hi all,

tried searching but came up with no results that would solve or answer my problem. Is there an existing solution to getting interactive renderings "converted" to a www-friendly format?

While my main question would be about the handling of lights since I'm not sure we have all the sufficient, filter kind of render elements to manually build an interactive light setup, I'd also need the possibility to change object color and other such simple tasks so I'm wondering, with the color changes etc, if everything is build up from scratch so to speak it'd pretty fast become bloated and frankly too complicated for me to handle, so if there's a way to easily migrate interactivity of the light mixer to another environment altogether, preferably as a HTML5 solution, I'd be interested in any ideas or references others might have in regards to such a system? This would still have to have the possibility to add other features like changing color based on mask or switching an object to another altogether so before I spend my time learning or pay someone to do research on an area I'm not an expert at, I'd like to know if there are shortcuts here to get a funky web-based thing going :)

Thanks, I'd really appreciate all and any ideas before I start to assemble some horrid piece of code that would ultimately not work at all!

Best regards,
Ville Kiuru

2017-09-18, 23:33:21
Reply #1

mferster

  • Active Users
  • **
  • Posts: 525
    • View Profile
I did some searching and could not find any no ready made solution to what you are looking for.

It's certainly possible to make something that uses the html5 canvas element to composite all your light select elements together into one combined image. If you are feeling ambitious, then code some sliders to change the opacity and redraw the canvas whenever the slider is moved. Tinting would be harder to accomplish and have it look good, I would have to think about that some more. Here is some code to load the images and then composite on top of each other. Don't really have time to build the sliders part though.

<html>

<head>


</head>
    <body>
        <canvas width="800" height="1200" id="canvas"></canvas>
      
      <script type="text/javascript">
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

var img1 = loadImage('image1.jpg', main);
var img2 = loadImage('image2.jpg', main);
var img3 = loadImage('image3.jpg', main);

var imagesLoaded = 0;
function main() {
    imagesLoaded += 1;

    if(imagesLoaded == 3) {

      ctx.globalCompositeOperation = "screen";
             ctx.globalAlpha = 1;
      ctx.drawImage(img1, 0, 0);
      ctx.globalAlpha = 1;
             ctx.globalAlpha = 1;
        ctx.drawImage(img2, 0, 0);
                  ctx.globalAlpha = 1;
      ctx.drawImage(img3, 0, 0);
            
    }
}

function loadImage(src, onload) {

    var img = new Image();

    img.onload = onload;
    img.src = src;

    return img;
}
</script>
    </body>
</html>



you would change the globalAlpha values to change the contributions of each individual image
« Last Edit: 2017-09-19, 00:40:28 by mferster »

2017-09-19, 04:42:07
Reply #2

Njen

  • Active Users
  • **
  • Posts: 557
    • View Profile
    • Cyan Eyed
Mixing individual light layers (which is what it appears you are using as an example by blending alpha channels) is an incorrect method of combining lighting layers. The RGB channels simply needs to be added together, no need for alpha channels.

Changing object colours is a bit more tricky. First you need to use a mask pass to get the object you want to change (some sort of RGB mask pass), then you need access to the diffuse/reflect source colour pass, multiply that with the raw lighting pass, then use the mask to mix in the element back on top. I'm pretty sure some smart person might be able to do it, but it won't be trivial.
« Last Edit: 2017-09-19, 12:40:08 by Njen »

2017-09-19, 17:07:17
Reply #3

Jpjapers

  • Active Users
  • **
  • Posts: 1716
    • View Profile
https://css-tricks.com/basics-css-blend-modes/

You can do additive blend with CSS. The cmyk split example is particularly cool. I dont see why you couldnt do this for Html5 lightmix. The object colou would be harder as it would obviously affect the GI

2017-09-20, 19:48:47
Reply #4

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 9048
  • Turning coffee to features since 2009
    • View Profile
guys,
for lightmix to work, you need to blend the images in linear space. For Jpeg, that would mean removing gamma, adding layers, adding gamma to the result. This is not as easily doable, probably only reasonable way to do it in browser would be with webGL pixel shader
Rendering is magic.How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2017-09-22, 06:09:53
Reply #5

vkiuru

  • Active Users
  • **
  • Posts: 320
    • View Profile
Wow, appreaciate the input everyone! :O As Ondra pointed out, there's the issue with 8-bit jpgs or however you want to put it. But it's all good advice and we'll definitely keep and eye out on these. Coming from a Vray background I'm aware of some of the tricky parts of changing object color, taking in account the reflective parts.. all the "filter" layers it would need. Thanks for the advice, even though it's not an easy subject it won't go to waste :)