New answers tagged

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


0

Use the built-in glsl function step to set any alpha value below 0.5 to 0.0. color.a *= step(color.a, 0.5);


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


0

Fastest solution is to change your comparison to account for JPG compression artifacts (that slightly alter pixels colors): if (overlay.r <= 0.02 && overlay.g <= 0.02 && overlay.b <= 0.02) Right solution would be to add Alpha to your image and use it for transparency.


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


0

Okay, I found the answer, with debugging it by myself. The fix is kinda simple, just remove the 1 - in this line fixed4 tex = tex2D(_GrabTexture, float2(coord.x, 1 - coord.y)); Shader "Unity Answers/Solid Transparency Color" { Properties { _Color ("Color", Color) = (0.5, 0.5, 0.5, 0.5) } SubShader { ...


1

Unity's ArasP has written an optimizer that could possibly do what you need: https://github.com/aras-p/glsl-optimizer You could also save the driver's compiled shader binary using OpenGL extension GL_ARB_get_program_binary on the first run and use it on subsequent runs to reduce loading hitches. The binary is hardware and driver dependent so you can't ship ...



Top 50 recent answers are included