Search Unity

Showing off custom game scripts and a new window shader.

Discussion in 'Made With Unity' started by musichopper, Sep 18, 2010.

  1. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    Hello, I was asked to post a demo of a shader (my first ever) I just made. It allows for glass to be see through while being reflective at the same time with controls in the alpha for the ratio. It reacts to light on both sides like real life etc.

    I also have my own code for Dynamic Depth Of Field. It adjusts depending on what you are looking at. I toned the DOF itself way down so it wouldn't be too annoying at times.

    I made my very own door script that allows you to manipulate doors in a very natural way that uses physics and simple mouse control. You click and hold the button and drag it up down/left and right. I have it set up so the controls change depending on orientation for a seamless realistic range of motion.

    I also have my own smooth mouselook code at play.. so when you are out in the open and not looking at those laggy windows 8^) You can see how smooth it feels.. reminds me of the feel in games like crysis a little but when the framerate is above 50ish.

    I added a bunch of (complex) upgrades to the click drag script for picking up objects. I made it so the objects always move with you in the proper rotational alignment and allow you to rotate objects by holding the middle mouse button and moving the mouse. You can also use that same mouse scroll up and down to move the object closer and further from you. I also coded a way where it checks if the object should be dropped...like if you walk behind a wall and back up too far before it can sort itself out and find its way back to you... it falls and you have to pick it up again. I have it set for a very generous distance as to not upset players in some cases lol. I can move it to drop as soon as you lose realistic holding distance from it of course. You can toss the object by moving the mouse right as you release it. It knows the force depending on the rate of motion in the mouse. I am going to add some extra math for this soon so you can release the left mouse button a little later than the motion and it will retain the same velocity..this will add more realism and make it easier for players. You can simply click the right mouse button while its still being held to throw it forward.

    I also did up a quick little code to make the enemy take attention to anything it considers dangerous or interesting.. If you pick up the crate and toss it.. he will take notice 8^). I have it set up in a dynamic way and I am still working out the full depths of the AI at the moment. This is a very simple example of course.

    I also have a custom FPC script that allows smoother motion ramping and adjusts values for speed and jump based on player stamina.. that is diminished by running.. (holding shift to run) and jumping. It regains stamina over time and regains it faster while crouched "c" button toggle. If you lose too much stamina the player breathes heavily (visually for now) and his vision is altered a little until it regains. I used to have it set up where if you are running you cant turn as quickly.. this is more realistic of course.. but gets annoying when testing, so I turned that function off.

    I have my own flashlight. I had very nice rays of light but it was very very slow at runtime so I killed it. TAB key toggles the flashlight.

    I suck at modeling so I am working on that a little. I also need to work on how to optimize meshes better.

    I forget what else I happened to do for this little example deal.. please just ask questions if you wondered how something is being done etc.


    Here is the web Player:
    http://musichopper.com/glass/glass.html

    Hope you like it!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't think your shader works on older cards (like my X800). It looks like the first pic, then settles down after a few seconds to the second one, though it still kinda "bounces" up and down. Trippy, anyway. ;)

    --Eric
     

    Attached Files:

  3. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,967
    the alien freaked me out, man!
    The depth of field is great! I love dof, if it was my call I'd put dof in every game in the universe. You could try making the camera focus somehow take into account not just the veriest center of the screen, but several points as well, I wanted to check out the aliens face, but the only way to focus it is to face his head so it's right on the center of the screen. Also, another thing that'd be extremly awesome, would be to adjust the camera focus gradually (like a camera would), right now i think it focus things instantly.
    Anyway this is looking great, hope to see more soon!
     
  4. tatelax

    tatelax

    Joined:
    Feb 4, 2010
    Posts:
    1,168
    That was really creepy! Too blurry. Liked everything else though.
     
  5. coin-god

    coin-god

    Joined:
    Jan 21, 2010
    Posts:
    325
    Love the door script and the DOF. Didnt know exactly what the alien would do, I hold the box and he does nothing.
     
  6. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    You have to throw the box so he notices it. Because an object at a high velocity near an entity will make it take attention of course lol.

    I am gonna be coding an object of interest for the DOF so it will make sure that any important game elements will take focus automatically. Like an enemy running at you etc. I used to have the DOF focus slowly but then I did real life tests and tried to notice how fast our eyes adjust to depth changes with my hand in front of my face etc... its instant pretty much so I went with that. I would like to have something in between though cause it would really show off the cool effect a little more like you are saying.

    Glad you like the stuff. I wonder why the shader isn't working for some people. hmm

    I made a new mesh for the alien and it is SUPER high quality.. looks sorta like a movie quality. I did it in Zbrush.. but when I try to export the displacement map from the highest division it runs out of ram and crashes LOL. Guess I need a better computer.

    That alien scared the S*** out of me... the first time I was setting up the headlook stuff it didn't work.. then suddenly it kicked on when I was up close and it quick looked right at me and I almost S*** myself. lol
     
  7. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    I intentionally put some alpha on the cabin texture so it would seem to make the inner environment glow with a dust. I feel it adds the proper environment. It looked better with an older worn out wood texture I used but that texture was low quality so I went with a higher res one for now. I also threw in some particles for added dust in there. I just wish the thing wouldn't drop so strongly in framerate when you look at the house lol. It's making me mad.
     
  8. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Wow, this is such a cool demo. It's got tons of pro level stuff going on.

    Are you going to make a game out of it?

    btw, the physics door and box-carrying reminds me of Penumbra, an awesome horror game.
     
  9. Anim

    Anim

    Joined:
    Aug 11, 2008
    Posts:
    289
    Like the glass,

    Any chance of a simple walk-through on how to get it working on my own project?

    Cheers
    Anim
     
  10. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    8^) GREAT GAMES! Their newest game demo inspired me to try and figure out the way they might be doing the door handling. I know I am doing the item carry differently for sure but the door stuff might be similar.. no idea. I used dot product math and a very short bit of code to get it to work with that same feel.

    I talked to them a while back about some game ideas I had but they never got back to me. I took the game ideas to a young man from Germany. He seemed to fall off the face of the earth though. So, yes I am working on a game 8^) actually two of them I have ideas for. They are very good ideas (I know when I have bad ones) I invented friggin guitar hero when I was in High School but never got a patent ARRRG! I programmed it and everything.. spent years. I told myself if I ever have another great idea like that I will keep it secret and at the right time, get a patent. It will be a new genre of game for the one idea. Very heavy on back end AI and open ended with severe replayabality.

    The stuff you are seeing here is nothing too new. I am just doing up a survival horror but no "weapons" and the "zombies" are Aliens. I have a GREAT fear of them and have some plans and some issues regarding "the super enemy" an Alien would likely be.. need to bring in some weakness to allow for strategy but make it fun for the player to discover over time and like Steven King novels.. have two primary fear and tension elements at the same time. While escaping the alien(s) the player will try to keep it secret so people don't think he is nuts.. then he gets himself in a situation where he is now found at fault for a crime that happened via escaping the Alien(s). Pretty tough to be on the run and at the same time watching out for those gray people. I planned on having a large portion of the game spent in the same area and the player needs to really use their wits and environment to their advantage.

    I already have had an idea for a player of a game digging a tunnel. I know exactly how to do it and have been looking for an excuse for years to put it in something. This one should provide a good opportunity as part of an escape or attempted escape. Safety in isolation and the cold comfort of solitude. It is basically giving the player a feeling of safety in some way and then removing that safety.. then they need to find a new way to remain safe and push the limits from time to time involving risk vs reward. The player will require food and standard human needs. This will somewhat add an extra stressor to how it all plays out.

    This will be pretty much a scripted storyline that the player has no idea they are forced into following. It will allow for branches in the path as well as ending variation. Not 100% open ended. You will also have a pet to use to your advantage. A dog I am thinking as they provide extra sensory help.

    You will be allowed to build things. I will tell you this, After stuck in a house for a very long time needing to escape in any way I could. I would use the house to my advantage. Take wood from certain walls and break it down to use to board up windows and doors. Would be an early attempt. What happens when you run out of food because in your haste to find a safe place you failed to bring a can opener to open all that canned food you carried into the safe place? You need to go back out and get it. The simplest of tasks will play an epic role in survival. Every moment should be very tense, followed by moments of feelings of safety that are brought on as a reward for the players actions, this will ultimately lead the player to survival and a "happy" ending.

    Would you tie your dog up where the aliens seem to be so it can warn you someone(thing) is there? and risk its life? Or will you bring it with you for some added defense?

    Lots of ideas that can work with the proper levels of basic AI happening all at the same time.

    My main trouble at the moment is finding their weakness that would allow fun and challenging ways to use it. (NOT WATER) 8^)

    Stories of Aliens involve them walking through walls, using mind control, basically being god like. I need to find a way(s) around this for the whole thing to work.
     
  11. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    1.) Make sure to use a plane
    2.) make sure it is scaled uniformily.. (x y and z have to have the exact same value).
    3.) Make sure your video card allows for two textures.
    4.) You have to use a new material on each window plane object. The easy way is to rightclick the mirror material and select new/material...It will make a copy for you. If you don't it will have issues.
     
  12. Anim

    Anim

    Joined:
    Aug 11, 2008
    Posts:
    289
    Post the scripts too !
     
  13. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    I really like how you handled being able to pick up and rotate objects! It was very smooth (for the most part).
     
  14. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    Thank you!

    I figured out that all of my lag comes from the window shader. It is really slowing things down a bunch. Going to have to remove it I guess. Unless I can figure out a less laggy way to do it somehow.
     
  15. daz

    daz

    Joined:
    Nov 23, 2009
    Posts:
    17
    With all of the amazingly intensive aspects of this demo, you probably should have released a standalone. My browsers suck at the web plugin.

    Anyway, hilariously CPU intensive (and probably GPU as well), ran OKish for me but I'm sure it would have run much better as a standalone. The blur and blur from DOF was a bit on the obnoxious side. Tone it down.

    Aside from that, looking good so far.
     
  16. musichopper

    musichopper

    Joined:
    Jul 22, 2009
    Posts:
    55
    lol. Yeah, it looks way better non browser for sure. Still laggy with the windows though. Makes me sad.
     
  17. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    nice glass and alien :),"i want to believe" fans huh?any chances for glass shader source? :wink:
     
  18. Mirace

    Mirace

    Joined:
    Nov 29, 2010
    Posts:
    481
    i would like to have that door drag script, does any1 have it?
     
  19. pinkhair

    pinkhair

    Joined:
    Dec 17, 2010
    Posts:
    141
    I think if it were a full game I'd have to turn the DOF off before it gave me a colossal headache, but I thought the physics and the glass were both top notch.

    I really liked the penumbra style object/door handling- it was very intuitive, though maybe for doors at least it might be good to let you hold onto a door when you open it instead of automatically releasing- you might see something you don't like and want to close it!
     
  20. nath0rn

    nath0rn

    Joined:
    Sep 25, 2010
    Posts:
    5
    omg release the contents of this fantastic game so I can steal the scripts and claim them as my own! then impress all my friends LOL
     
  21. bradjensen68

    bradjensen68

    Joined:
    Feb 2, 2009
    Posts:
    274
    You need a copyright, not a patent. Patents are for inventions, copyrights are for works of art such as movies, books, and games. Also, a copyright doesn't guarantee success, nor would it necessarily protect you from someone making a similar but not entirely identical game. I wouldn't worry about the copyright so much before you find a publisher or serious investor.