New answers tagged

0

The only point of trying to approximate this sphere is to filter which pixels to modify. Try this from the reverse direction: 1) Render everything (no sphere) normally using FragmentShader1, transforming with ViewProjection: return tex2D(_MainTex, i.uv); 2) Activate an Opaque BlendState so we overwrite whatever was just drawn. 3) Activate ...


0

Do you know the basic principles of java? If eclipse crosses out something, it means, that method is deprecated. Use glGetShaderi instead of glGetShader. Also, some other things you should consider to do: After you linked the shader, you don't need to have the vertex and fragment shader, delete them immedialitely after it. BindAttributes comes before ...


0

In your ShaderProgram.java try binding the attributes before you link and validate the program: public ShaderProgram(String vertexFile, String fragmentFile){ vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER); fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER); programID = GL20.glCreateProgram(); ...


0

I think you're missing a bind to your index buffer. It's been a while, but I believe binding the VertexArray only affects the vertex data, not the index data. If I remove the glBindBuffer(GL_ELEMEN_ARRAY_BUFFER...) from my code, i get a black screen. glBindVertexArray(VAO); **glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);** glDrawElements(GL_TRIANGLES, 6, ...


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 ...


0

HLSL in Direc3D 11 has a feature called Class Instances, in which you can dynamically plug in what functionality should be used in a particular draw call. You keep the implementation in the shader file and query out the location via reflection. The instances are specified as an array to your SetShader call. The MSDN page that outlines this is Instances and ...


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 ...


0

I have solved this same problem (need to render the same geometry with simpler shaders for shadow mapping) in 2 ways: Wrap shader code sections into #IFDEF directives, so that on compile time I could enable or disable them, thus constructing 2 shaders from single source. (I mostly use it to enable-disable effects on-the-fly) Copy-paste the shader code and ...


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 ...


0

So basically you are looking to paint your environment as it is shot? Apply 2 textures to your object, the main texture being pure black, the secondary being the actual coloured texture. Grab the point on the object that the mesh was struck Convert this point into the x,y coordinate on the texture itself Grab the pixel (and maybe surrounding pixels) and ...


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);


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 ...


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 ...


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 ...


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 ...


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 ...


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 ...


0

Computing vertex normals is a complex process as you need to have all incident faces available, and the ability to "split verts" when needed. This is not really something well suited to the Geometry Shader. Face normals do fit well with Geometry Shader because you only care about the primitive itself. Is there some reason you have to do this on the GPU? ...


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. ...


0

Ok so the problem was not winding. It seems that MickLH is right in that one cannot simply combine all the shared points in a mesh into one vertex. Only vertices used in triangles with similar normals can be combined otherwise one gets this strange effect.


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 ...


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 ...



Top 50 recent answers are included