[英]A-Frame Image Brightness
I have an A-Frame AR scene with an image in it (transparent png) that i can move around and resize through gestures.我有一个 A-Frame AR 场景,其中包含一个图像(透明 png),我可以通过手势四处移动和调整大小。
What I'm trying to do now is change the brightness of that image according to the light estimated from the camera input.我现在要做的是根据从相机输入估计的光线来改变图像的亮度。 I have the light estimation bit working and my initial idea was to simply apply a CSS
filter: brightness(xx)
to the image using the value outputted by the light estimation.我有光估计位工作,我最初的想法是使用光估计输出的值简单地将 CSS
filter: brightness(xx)
到图像。
Sadly applying the CSS on the <a-image>
doesn't seem to have any effect.可悲的是,在
<a-image>
上应用 CSS 似乎没有任何效果。
Therefore I'm thinking this can probably be achieved with materials and shaders, but I don't know how that would go, I tried using a flat shader and changing it's opacity but that changes the opacity of the whole image so i end up with a slightly opaque black shade.因此,我认为这可能可以通过材质和着色器来实现,但我不知道会怎样,我尝试使用平面着色器并更改它的不透明度,但这会改变整个图像的不透明度,所以我最终得到略微不透明的黑色阴影。
Here's an example of the shading I was trying:这是我尝试的阴影示例:
<a-scene>
<a-image src="http://assets.stickpng.com/thumbs/580b57fcd9996e24bc43c52d.png"
position="0 2 -3"
rotation="0 0 0"
height="5"
width="5"
material="shader:flat;color:black;opacity: 0.5; transparent: true">
</a-image>
</a-scene>
I also tried also using a standard shader with emissiveIntensity
but i can't seem to make it work with black, any other color seems to get more or less where i want, although i can't get a fully dark image (as it would be if brightness was 0):我还尝试使用具有
emissiveIntensity
的标准着色器,但我似乎无法使其与黑色一起使用,任何其他颜色似乎或多或少地达到我想要的位置,尽管我无法获得完全黑暗的图像(因为它会如果亮度为 0):
//if i change emissive to black then the image is unaffected
material="shader:standard;color:white;emissive:red;emissiveIntensity:0.5;
//like this i can get full black but the image is no longer visible, only the shape
material="shader:standard;color:black;emissive:white;emissiveIntensity:0.5"
Any idea how to achieve this?知道如何实现这一目标吗?
I got it, all i had to do was set the material to a standard shader with nothing else and then change the intensity of the ambient light that i added manually to replace the default ones a-frame adds.我明白了,我所要做的就是将材质设置为标准着色器,没有其他任何东西,然后更改我手动添加的环境光的强度,以替换 a-frame 添加的默认环境光。
material="shader:standard"
If by any chance there is a better way to do this please post an answer.如果有任何机会有更好的方法来做到这一点,请发布答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.