I've been trying to implement a door for my game but when I change the material to the open door material I get a result like this:
These are the settings for the material:
I would like to be able to have an open door with normal transparency instead of this weird glitch. Any help would be much appreciated.
I figured out the solution and it's quite simple! The shader needed to be Legacy Shaders/Transparent/Cutout/Diffuse. My shader was Legacy Shaders/Diffuse,
You might not need to change the shader. In the unity's standar shader if the render mode is changed to transparent then the change in the color's alpha takes place in the game.
It usually happens that the alpha change does not work when it is changed in the color palette because the render mode needs to be changed from the opaque mode for the tranparency to work.
Related
I have a first person controller and currently if I walk into a slightly transparent object, it disappears until I walk out of it.
I have a 'water' cube object that is very light blue and transparent, and when I move my camera into third person view then enter the water, my screen turns light blue which is good. In first person mode (which is what I'm trying to figure out), the cube disappears and my screen color remains the same.
I know it has something to do with my camera but even after going through all the features on unity docs and changing a few settings in the inspector, it all remains the same.
Like mentioned in the comments your cube is not visible because the backside of its faces is being culled, meaning they are not rendered. This is not a camera setting but a property of the shader your water cubes material is using.
You could create get a duplicate of the shader your are using where you add Cull Off to change this.
Read about it here.
If you want to go that route you need the source files for your shader. Assuming it is one of the Unity Built in shaders you can get them from the Unity Download archive here for your Unity version.
Clipping the camera trough objects is rarely a desired and you should look at a different way of achieving your effect like using a post-processing volume because the "water" would still be a cube and be drawn behind everything in front of its faces.
For example in a FPS type game this would result in the gun not changing color.
So I'm trying to add an effect to a game object where the transparency of its materials will grow over time until it hits a threshold, then go back to normal, and repeat for a predetermined amount of time. I made it so I can make them transparent after a bit of research, but my issue is now just trying to use the best transparent shader.
I first used the UI/Unlit/Transparent shader where I could just grab the alpha value and increment/decrement it as I wanted and made it go transparent, but my issue was that the tint of that material would make it blindingly white, which I don't know if I can do anything about since I am using PNGs as the material so I can't just edit the tint to not affect the material I think.
Then I used the Unlit/Transparent shader but that only has _MainText or Diffuse, which doesn't have a way to edit the transparency without a custom shader is what I've found after scrolling through Unity Answers and other StackOverflow posts.
Is my only option to write a custom shader for Diffuse to get this to work or is there something obvious that I'm missing for these shaders?
Alright I figured out that all I had to do was check off the "Use Alpha Clip" option on the UI/Unlit/Transparent shader and it only uses the alpha variable and not the tint
I want to change my text color after sometime and want to continue the process. I was trying to do that by changing the material color.but the text gets filled up when I am trying to add a material on it. here's the image which will help you to understand.The first one is without a material and the second one is with a material.
You can use a user defined material for the UI. The reason you see a blcock shaped image instead of your Text is because of the shader of the Material. You cannot use the Standard shader or any shader not intended to be used for the UI. You must use the shader under the UI shader menu.
Select your scoreMat Material and change its shader to UI ---> Default shader.
Is there a way to make an object half opaque? I tried this:
renderer.material.color = new Color(255f, 255f, 255f, 0.5f);
But it just makes the item white and the textures are no longer showing.
I have tried using Transparent/Bumped Specular but that makes the object too transparent, even when I don't want the object transparent at the time.
What I am trying to accomplish is to make it transparent to look like the player is inactive during a character selection screen. When the player presses A they will go to full opaque and then can select their player.
Editor Mode:
Play Mode:
So there are a couple things that I'd like to point out to you on this. First off, Unity's Color class is based on values from 0 to 1. So you have 255f in your RGB's, this is giving you what you expect now, but really it's just setting them to 1 in the constructor. So if you want colors in the future do:
new Color(rValue/255f, gValue/255f, bValue/255f, aValue/255f);
Just wanted to point that out while you were here.
So to your actual question, what you're doing with that line of code is you're saying, take the material attached to this object and make it completely white (if i'm wrong with 1,1,1 being white, someone please comment) and half transparent. But that doesn't apply to the object itself, that only applies to the material attached.
So if you want to modify the platform to be transparent, my recommendation is store both the transparent and non-transparent materials that you want on the script where you're changing which one is being used. Then in the code, instead of changing colors, change what material the renderer is using instead.
Hope this helps.
So, I'm trying to make a game in XNA, and I'm applying a pixel shader to my level so I can add effects to the gameplay screen. The shader itself is working nicely, but it has one flaw that really pushes back performance. As long as the shader is active, anything I draw to the screen acts as though it was drawn with it's alpha channel at the maximum. I'm drawing a lot of things using XNA's built in Color class, and much of it has varying alpha. However, the shader seems to ignore all of this. This occurs even if I just return the source from the shader.
I've seen a few possible solutions. The first of these was to draw to a RenderTarget2D and, while this did solve this issue, it caused more serious problems with alpha that I don't even want to go into.
I have seen a few people claim that multiplying the colours by the alpha value in the shader seems to help, but that made absolutely no difference, which suggests to me that the alpha value input is always being read as 1.
Here are some images to illustrate my problem:
Hopefully, someone knows how to resolve this.
In your Draw() method, you need to call:
GraphicsDevice.BlendState = BlendState.NonPremultiplied; before calling any methods that invoke your shader (i.e. DrawUserIndexedPrimitives, etc.).
Otherwise, the framework assumes the alpha value has been premultiplied and that it can just blit the RGB values right to the framebuffer.