need help with a shader error!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kicknbritt
Citizen
Posts: 96
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

need help with a shader error!

Post by kicknbritt »

Hey guys I am working on putting a blocky rendering engine I was working on a while ago on android. I am using the SS3D library. I previously was working on windows 10 64 bit.

When I loaded the game into the love2d android app I get this error
Error

Error validating pixel shader code:
Line 37: ERROR: 'max' : no matching overloaded function found
Line 37: ERROR: '' : missing #endif
Line 37: ERROR: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.


Traceback

[C]: in function 'newShader'
GameState/Components/SS3D/Scripts/NewScene.lua:60: in function 'NewScene'
GameState/Components/SS3D/SS3D.lua:76: in function 'Load'
main.lua:75: in function 'LoadModule'
main.lua:101: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'




Here is my shader code:

Code: Select all

	love.graphics.setDepthMode("lequal", true)

    -- define the shaders used in rendering the SS3D.Scene
    SS3D.Scene.threeShader = love.graphics.newShader[[
        uniform mat4 view;
        uniform mat4 model_matrix;
        uniform mat4 model_matrix_inverse;
        uniform float ambientLight;
        uniform vec3 ambientVector;

        varying mat4 modelView;
        varying mat4 modelViewProjection;
        varying vec3 normal;
        varying vec3 vposition;

        #ifdef VERTEX
            attribute vec4 VertexNormal;

            vec4 position(mat4 transform_projection, vec4 vertex_position) {
                modelView = view * model_matrix;
                modelViewProjection = view * model_matrix * transform_projection;

                normal = vec3(model_matrix_inverse * vec4(VertexNormal));
                vposition = vec3(model_matrix * vertex_position);

                return view * model_matrix * vertex_position;
            }
        #endif

        #ifdef PIXEL
            vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
                vec4 texturecolor = Texel(texture, texture_coords);

                // if the alpha here is zero just don't draw anything here
                // otherwise alpha values of zero will render as black pixels
                if (texturecolor.a == 0.0)
                {
                    discard;
                }

                float light = max(dot(normalize(ambientVector), normal), 0);
                texturecolor.rgb *= max(light, ambientLight);

                return color*texturecolor;
            }
        #endif
    ]]


  
I believe the error is throwing at this
" float light = max(dot(normalize(ambientVector), normal), 0); "

Anyone know whats up here?? Thanks
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: need help with a shader error!

Post by pgimeno »

kicknbritt wrote: Sun Apr 05, 2020 10:15 am Anyone know whats up here?? Thanks
I suspect the error is the use of 0 (integer) instead of 0.0 (float).
User avatar
kicknbritt
Citizen
Posts: 96
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: need help with a shader error!

Post by kicknbritt »

Ah yep that was it. I was just reading how glsl needs everything to be floats too. Thanks.
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 29 guests