|
I'd like to use Color Correction Curves image effect in my Unity Pro 3.x project and be able to adjust the curves from sliders (Javascript). The values in the script are from animation curves and I'm unable to figure out how to address them via a slider without getting an error. I realize it's because I'm trying to set the AnimationCurve as an int, but I don't know how to access it otherwise. Here's the slider for the red channel: Can someone tell me how to change that line so it will access the values correctly? (Javascript if possible)
(comments are locked)
|
|
If you don't want to go with the 'write your own shader' option, what you're trying to do is quite possible. Probably the most straightforward way to manage this should be this:
(to a given definition of 'straightforward'...) EDIT nah screw that, here have a 'brightness' screen effect. CODE:
SHADER: You need to attach this to it before it'll work. Whelp, time for the holistic solution. I use C#, so apologies if you need to translate it a bit.
Jan 28 '12 at 09:19 AM
syclamoth
No problem at all.
Jan 28 '12 at 09:21 AM
Ony
Make sure you don't set 'brightness' higher than 1 or lower than 0. I've had experiences with random crashes and instability occurring when the values plugged into a 'range' input in a shader aren't clamped properly.
Jan 28 '12 at 09:22 AM
syclamoth
PERFECT. Thank you!
Jan 28 '12 at 09:25 AM
Ony
I just realized that neither of the solutions (this shader or the color correction one) affects the GUI. I wonder if that's even easily possible in Unity and I wish there was a simple brightness control already built in.
Jan 28 '12 at 09:39 AM
Ony
(comments are locked)
|

Well, you've basically answered your own question here. It's not possible (or even sane) to attempt to boil down or assign a single number value to an AnimationCurve. An animtaioncurve contains way too much data for that to ever work. What, exactly, do you hope for it to do? It's possible that there's a better way than the method you're trying here.
I just read up on animationcurves, and it should be pretty simple to modify their values from a script. What part of the curve are you most interested in? Do you want to scale the entire curve by some amount?
Basically I'm trying to do a fairly simple brightness setting. I need to take the right side (2nd) value of the curve for each color channel and raise it or lower it to the slider amount. I've got the curves set to linear so there aren't any bezier curves or anything, just the two values for each curve.
That may not even be the best way to do a brightness setting but I've played with all of the Pro image effects and it seems to be the one that does it the best when I manually adjust the curves.
If you want a brightness setting, why not write your own shader? Experimenting with shaders can be rewarding- not many people here really know how they work, and they're really useful.
Because I just wanted to add a simple brightness setter to my game while this latest version is in beta testing. One of the beta testers asked for it and I figured I would try to put it in. I've already been two months on this latest update and not really wanting to write my own shader to do this as it's not that important. I just figured someone could tell me how to access the animation curves via a slider.
I understand the appeal of writing shaders, I've got a ton of them (skin shaders, etc.) all customized in the game already. It's rewarding I agree, but I am better at customizing them than writing from scratch.