Hot answers tagged

7

I would guess that they've scaled and shifted their outputs into the range from 0f to 1f (0-255) for the purpose of that greyscale height visualisation. They probably omitted that adjustment from the formula because it's not critical to the shape they're describing with the normal map. Try multiplying the result by something in the neighbourhood of 0.5f ...


2

No. The size of the array has to be a constant. Specifically from the GLSL specification: 4.1.9 Arrays ... When an array size is specified in a declaration, it must be an integral constant expression (see Section 4.3.3 “Constant Expressions” ) greater than zero.


2

I was able to eliminate all of the GpuProgram warnings and also fix all of my animations by trial and error elimination of several shaders and additionally re-importing the models from Blender. Steps as follows. I set all of the models to use the standard shader in Unity. I then deleted and reloaded the offending shaders and did not have any errors, this ...


2

There's really not much room for optimization here, having divergent branches over such a small if body is probably not affecting your performance really at all. You could use something like discard which might convey your intention better, but ultimately will not change your performance. Taking from this post, here's an example usage. if (color.a < ...


1

The cheapest (but not necessarily very flexible) solution would be to duplicate the shader code in your C# script. When the player clicks, fire a ray through the mouse position. Capture the RaycastHit struct, and it will give you the world position and texture coordinates of the point directly under the mouse. (If you've displaced your sphere out along the ...


1

The screen coords go from {-1,-1} to {1,1} but you are most likely feeding it {0,0} to {1,1} - hence the fact that only one-quarter of the screen gets rendered. So just to be clear - point {0,0} is not the top-left (or bottom-left, depending on your co-ordinate system) point; it's the center. This also explains the texture coord tranformation that you are ...


1

Maybe you mean glUseProgram()? I can't find something related to glUseShader, so if i'm wrong then sorry. But if this is the case then basically you use it when you want to use the shader itself. This is an example from my current opengl project (EDIT: Oh, by the way, this example code is on the main rendering loop): GL30.glBindVertexArray(vao); // Binding ...



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