11

I'll try to answer to the best of my knowledge, with little knowledge about the specific case of UE4, but rather on the general technique. Graph based materials are as much programming as writing the code yourself. It just doesn't feel like it for people with no background on code, making it seemingly easier. So, when a designer links a "Add" node, he is ...


10

since you admittedly don't have much experience with 3D and (presumably) OpenGL, I'll give you a "bird's eye" overview of the process. I'll do my considerations about OpenGL, but the basic reasoning yields for other APIs too. When you render something with a modern version of OpenGL you create objects that will reside into the GPU memory, and then mostly ...


9

Well, Shading languages like GLSL and HLSL is what all the "material" code ultimately get translated to in the end. Shaders are the actual programs which are run directly on the GPU, and to create them, you use a shading language. 3D packages are generally used to make it easer for you to make realistic looking graphics, and writing shaders by hand is a ...


7

It's a good idea to separate parameters into a few categories based on how often they're changed, or which other parts of the renderer they hook up to. For instance: Frame parameters - like the camera matrix, screen size, and current time Material parameters - like textures, specular and gloss values, etc. Object parameters - like an object's world matrix, ...


6

MaterialPropertyBlock probably what you are looking for. Just make sure to create the block once and cache it, to save on garbage collection. I'd create one MaterialPropertyBlock per piece color (so a red and a black, with the material by itself being white), cache them, and apply the block to each piece as needed.


5

Physically based rendering basically means that you strive to have realistic materials and lighting calculations. The way you do this can vary a bit (or a lot) depending on application, but the main idea is that no material can reflect more light back than hits it, and preferably you want to measure the Bidirectional reflectance distribution function (or ...


5

I'd recommend testing empirically to confirm, but the second answer at this link says that triangle data for submeshes is indexed sequentially in order of submesh index. That means all the triangles for submesh 0 have lower indices than those in submesh 1, etc... So, you can iterate over the submeshes until you find the one your triangle belongs within: ...


5

The default shaders in Unity 5+ use something called physically-based rendering. This means they try to model a number of quirks we observe in real materials, which aren't included by the Lambertian/Phong approximations that have been popular in games in the past. One of those effects is Fresnel reflection, where the shiny reflection off of a surface ...


4

When importing a texture, you can set two different 'wrap modes'. These tell the renderer what to do when the UV map goes past the edges of the texture. Yours is set to 'clamp', which will just stretch the pixels on the edge. This is useful for preventing artifacts when rendering sprites, but in this case you will want to set it to repeat. Note that in 2D ...


4

First, create a simple mesh (such as a quad or a cube). Place it over top the actual game area, and stretch it so that it covers the entire camera view. Next, create a new shader named "ObscurityShader", and paste in the following shader code: Shader "Custom/ObscurityShader" { SubShader { Tags{"Queue" = "Transparent+1" "RenderType" = "...


4

There are actually two completely unrelated kinds of materials in Unity: Renderer materials (which define how things are rendered) and physics materials (which define how rigidbodies behave when they bump into each other). But if you are talking about color, you are likely talking about renderer materials. Generally speaking, you can assign a material to ...


3

It looks like the Wings3D object doesn't have texture coordinates. There is a texture applied, it's just not applied correctly. Without texture coordinates, it'll just stretch a single pixel of the texture over the entire object.


3

Scripts put in a folder named Editor affect Unity's editor, rather than running when you play the game. You can use this functionality to extend the capabilities of the editor, to run custom functions you create. For example, here's a script that adds a window with buttons for custom functions: http://wiki.unity3d.com/index.php?title=FindMissingScripts You ...


3

Resolved! effect.texture2d0.envMode = GLKTextureEnvModeDecal; It is related to the Texture Environment Parameters, i.e. how OpenGL combines the diffuse color of the material with the texture value. As described here: khronos.org/opengles/sdk/1.1/docs/man/glTexEnv.xml. If I'm right that GLKit instruction should correspond to: glTexEnvi(GL_TEXTURE_ENV, ...


3

If you want to change a Material in Unity you have to retrieve it first. If your GameObject uses a Material it means that it uses a Renderer. You can retrieve your object renderer using the internal variable renderer or get it using the GetComponent function. On the renderer object you will find a material property containing the active Material. For ...


3

To quote directly from the link you provided: For instance, OpenCTM does not handle multiple meshes, transformation matrices, materials, light sources, physical properties, etc. So, the answer is it does not have built in material support. However, it also says 'Supports storage of per-vertex normals, UV coordinates and custom vertex attributes.' This ...


3

You need to edit your shader source file in order to add "Cull Off" inside, more info here If you are not writing your own shaders (and so use default provided Unity shaders) then you can look at proposed solutions here


3

In a simple case you can change the main albedo color of the material of an object by assigning a different Color to gameobject.renderer.material.color Note that some advanced materials have multiple color properties which serve different purposes. In that case Material.color might not be the color you actually want to change and you have to use the ...


3

Renderer.materials is a getter that returns a copy of the materials array. The code you've written modifies that copy, but does not change the material used by the object, which is why it always shows up as the default. What you want to do instead is something like the following: var renderer = GetComponent<Renderer>(); var materials = renderer....


3

Here's an example of what you can do with a single material and a shader that changes behaviour based on world position: This shader looks something like this: Shader "Unlit/WorldspaceSwitch" { Properties { _Color ("Surface Color", Color) = (1, 1, 1, 1) _UnderColor ("Underground Color", Color) = (0, 0, 0, 0) } SubShader {...


3

When you set the UVs for your model, make sure the faces which are supposed to have a different material get assigned to different images. When you then import the model into Unity, you will have a different material-slot for each image in your model. You can then drag-and-drop different materials into those. Another option is to use one material for ...


3

To upgrade all the materials that can be supported by LWRP, go to: Edit Menu -> Render Pipeline -> Lightweight Render Pipeline -> Update Project Materials to LightweightRP Materials Note - only standard shader materials will be brought across. Lit/specialist shaders will not be converted automatically. You will see warnings in the console about those the ...


3

// assume "sprite" is your Sprite object var croppedTexture = new Texture2D( (int)sprite.rect.width, (int)sprite.rect.height ); var pixels = sprite.texture.GetPixels( (int)sprite.textureRect.x, (int)sprite.textureRect.y, (int)sprite.textureRect.width, ...


3

To upgrade built-in Shaders (ref): Open your Project in Unity, and go to Edit > Render Pipeline > Universal Render Pipeline. According to your needs, select either Upgrade Project Materials to URP Materials or Upgrade Selected Materials to URP Materials.


2

To apply different textures based on height the general method is to, in a pixel shader; Find the height of the geometry at the current pixel position. Perform a texture lookup on the heightmap that defines the geometry or just find the position of the current geometry as you would for lighting and find the y component. Supply your shader with some kind ...


2

Although late, there is a "cheat" which can help you understand better. A material is everything that is attached to a certain shader for that draw call. For example, in the above answer, you have this material: [Material] Shader=NormalMappedSpecular.glsl Texture1=Rock.png Texture2=RockNormal.png Texture3=RockSpecular.png which translated that you will ...


2

If you modify a material, it affects the objects that are using it. You need to duplicate that material, modify its texture and reassign it to the target object.


2

You need two vertexes in such this case. There is no way around it. If the faces have a different texture then you will need a different vertexes to define them. To simplify it you could try to save the mesh in such way - check whatever modelling program you use. Sometime it may be as simple as telling it not to weld vertexes together.


2

I tested your script and was able to dynamically adjust the colors of the line renderer. Perhaps you didn't pass your linerenderer component into your script in the editor on the attached object? Alternatively, you could add to your script: void Start() { lineRenderer = gameObject.GetComponent<LineRenderer>(); } Aside from that your code seems to ...


2

If you want to create a transparent material you have to make your material "translucent". Glass also has the property that its surface is very shiny, so you also have to change the "Translucency Lighting Mode" to "Surface", otherwise you can not control highlights on the surface. Be sure to adjust the "Opacity" output pin of your material. You can have a ...


Only top voted, non community-wiki answers of a minimum length are eligible