playMaker

Author Topic: VR knob dial to control material emission intensity?  (Read 2796 times)

enni

  • Playmaker Newbie
  • *
  • Posts: 4
VR knob dial to control material emission intensity?
« on: March 05, 2022, 06:12:58 AM »
Hi. I have a VR knob which rotates 180°, with a canvas text displaying the ° amount rotated.  I want to control the emissive color of another game objects material with that. [I tried to use the knobs Y rotation but the rotation includes negative values and positive eg. -64° to +116° and I am not sure how to offset, or clamp, that into a useful range]

So far I did 'UI Text Get Text' from the text object and 'Convert String To Int' - I think I now need to clamp the Integer value into a range of 0-255? 

I then plugged the result into 'Set Material Color' with the '_EmissionColor' attribute, but that does not work (only accepts 'color' type  variables)

Does anyone know how I can get his done?  Perhaps there's a better and simpler way as the confusing path I am on -- I am new to playmaker... thank you.
« Last Edit: March 05, 2022, 02:11:21 PM by enni »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: VR knob dial to control material emission intensity?
« Reply #1 on: March 05, 2022, 05:54:18 PM »
Hi.
The range should be between 0-1

you could clamp between 0-180
then get the rotation and divide by 180, this should result in a normalized value (0-1)

you could also camp between for example -170 - +170.
Then add 170 (so lowest = 0), then divide by 340

enni

  • Playmaker Newbie
  • *
  • Posts: 4
Re: VR knob dial to control material emission intensity?
« Reply #2 on: March 06, 2022, 07:50:33 AM »
Thank you, djaydino.  That worked!  When I turn the knob, the tv screen in my game gets brighter (Y Rotation drives Emission Color). How can I accomplish that? I can make it work to switch emission on/off. But I can’t figure out a way to rotate the knob which gradually brightens the tv screen in my game. I was going to use the text object (as described in my earlier post) and then read the output into the emission color attribute - per frame. Really need some help on this.  Thank you!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: VR knob dial to control material emission intensity?
« Reply #3 on: March 06, 2022, 09:37:24 AM »
Hi.
Do you mean in VR how player can turn the knob object?

I have not worked in VR yet, but maybe you should join the discord channel.
I sure there will be some peeps there that have some experience in VR

enni

  • Playmaker Newbie
  • *
  • Posts: 4
Re: VR knob dial to control material emission intensity?
« Reply #4 on: March 06, 2022, 02:53:15 PM »
Hi, djaydino. Thank you for following up.

No, not in VR. I have that all up and running. What I meant is that I am struggling with the logic using playmaker for the task: The user grabs the knob, turns it [rotate Y], and the TV screen in my game gets brighter (or darker). In the pictures below  the user turned the knob 71° which would make the screen brighter.

My knob has a canvas and UI text attached which displays the current amount of the rotation.




Currently, in playmaker, I am getting the knob rotation position via the 'UI Text Get Text' - then I 'Convert String To Int' - then I am trying to clamp the value and plug the result into 'Set Material Color'. This needs to be continues at runtime, so I enable 'Every Frame' on the actions so the brightness levels happen gradually [like a volume knob]...

... to drive the _EmissionColor intensity of my game object.


The trouble is that I cant figure out how to create the variable for the 'Set Material Color' action as this requires a 'Color' variable and mine is currently an Int value.
So, INT to COLOR value so to speak.

I am sure I'm doing this wrong. Do you have any suggestions?

Thank you.


« Last Edit: March 07, 2022, 09:57:47 PM by enni »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: VR knob dial to control material emission intensity?
« Reply #5 on: March 07, 2022, 09:53:54 AM »
Hi.
I believe that you can use 'Set Material Float' and use _Emission as value (this can be different depending on the shader, _Intensity could also be possible)

Quote
In the pictures below  the user turned the knob 71° which would make the screen brighter.
Hmm i think you forgot to add the picture :)

if you need the emission value between for example 0-4 then use the normalized value to divide. (emission / normalized value )

enni

  • Playmaker Newbie
  • *
  • Posts: 4
Re: VR knob dial to control material emission intensity?
« Reply #6 on: March 07, 2022, 11:46:42 PM »
thank you!! that worked - only change I've made is using 'Set Material HDR Color' -- thanks again

Flamehead

  • Playmaker Newbie
  • *
  • Posts: 7
Re: VR knob dial to control material emission intensity?
« Reply #7 on: June 04, 2022, 09:29:53 AM »
thank you!! that worked - only change I've made is using 'Set Material HDR Color' -- thanks again

Can you show how you got this to work? I'm trying to animate the emission intensity value in the HDR shader and it's not working for me.