Hot answers tagged

6

I can't see anything fundamentally wrong with the shader, but here are a few things I find commonly done wrong with deferred shading that you might be doing. 1: Drawing full screen lights. The beauty of deferred shading is that you can pack your lights into geometry so that you only need to consider a part of the screen when drawing them (Like a cube with 2 ...


6

vec3 norm = vec3(uViewMatrix * uModelMatrix * aNormal); The normal cannot be transformed like a point, to transform a normal you use the inverse transpose matrix. If you want the fun details of why this is here is a qoute from the OpenGL Red Book that explains it better then I ever will: Mathematically, it's better to think of normal vectors not as ...


4

It's common for people to compute lighting in eye space because of how the specular component of lighting in the Phong model is calculated. Doing the calculation in view space, allows you to avoid a vector subtraction in the vertex shader, a basically negligible optimization. If you were instead to do the calculations in world space, which you absolutely ...


4

No, but OpenGL might ;) The base Vulkan specification only supports SPIR-V. However, Vulkan does allow for vendor extensions. And NVIDIA is already on-record on this matter; they will be providing a Vulkan extension to be able to shove GLSL into their Vulkan implementation. That shouldn't be taken to mean everyone else will. However, let's not forget that ...


3

The problem was there gl_FragColor = (1.0, 0 , 0 ,1.0);//vec4(texVal.rgb, texVal.a)*(1.0, 0 , 0 ,1.0); it miss the vec4 name gl_FragColor = vec4(1.0, 0 , 0 ,1.0);//vec4(texVal.rgb, texVal.a)*vec4(1.0, 0 , 0 ,1.0);


3

First Question: The dot product basically tells you how much two vectors are pointing in the same direction. So if a light points directly against the normal of a surface the surface will be brighter than if it points at it in an angled way or away from it. If you are struggling with getting this to work, I would advise very heavily against trying to ...


3

The error here is that you're trying to sample from a texture in a vertex shader the way you would in a fragment or pixel shader. Vertex texture fetches are a little bit special. They're only supported in Shader Model 3 and up, and they're unable to use the tex2d() function. That may sound odd, but tex2D() is really a shortcut that says "figure out the ...


2

Is there other, or correct way? Sure, there's tons of ways to "show the status of the enemy" and maybe not even with color. This is a very subjective question but it comes down to what you think looks best and what works with the rest of your game. In case of use vertex shader, how I change the color of enemy without losing all details (Something like a ...


1

I managed to solve my problem. I used the shaders from this post: http://forum.unity3d.com/threads/sprite-renderer-mask-on-specific-sorting-layer.356824/#post-2310992 And a simple grey circle for the "blur-free" circular zone. The pre-blurred sprites used the "Stencil Draw In Mask" one, the regular sprites used a shader that was the same as the above, but ...


1

The looks like a compiler bug. But in any case: You don't need the copy into a const array, just use the non-const one. You don't need those large arrays, from what I see everything in the shader can be done in a single for (i = 0; i < TAM; i += 3) loop with small arrays of 3. That should work around the compiler bug and probably make the shader ...


1

It worked. My Code: Mesh mesh = new Mesh(); mesh.vertices = newVertices; mesh.uv = newUV; GetComponent<MeshFilter>().mesh = mesh; mesh.SetIndices(new int[] { 0 }, MeshTopology.Points, 0); The last line creates was very important to create a trinagle. For saving the Mesh: AssetDatabase.CreateAsset(m1, "Assets/" + "oneVertexMesh" ...


1

OK, So taken from http://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html : The Standard Shader has some extra requirements if you want to modify Materials at runtime, because - behind the scenes - it is actually many different shaders rolled into one. These different types of shader are called Shader Variants and can be thought of as ...


1

Unfortunately, when it comes to lighting, some way or another, you'll need some normals. As you mentioned, for flat shading, you need per triangle normals, which implies vertices duplication, compared to smooth shading. The most often used techniques to compute normals in an OpenGL shader (using dfx/dfy or geometry shader) are not available in gles 2.0. ...


1

You want stenciling here. Your first pass renders the circles to the stencil buffer. The second pass renders the visible outline, anywhere the stencil buffer has not changed. The second pass must use geometry which is larger than the first pass, in this case, a simple linear scalar is sufficient. While the solution I have for drawing outlines over here ...



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