tobspr / RenderPipeline

Physically Based Shading and Deferred Rendering for the Panda3D game engine
https://github.com/tobspr/RenderPipeline/wiki
Other
962 stars 132 forks source link

Setting texture to shader terrain through custom shader failed #127

Closed sbxzy closed 2 years ago

sbxzy commented 2 years ago

In custom shader YAML file, I wrote: ... fragment: defines: |

define DONT_FETCH_DEFAULT_TEXTURES 0

    #define DONT_SET_MATERIAL_PROPERTIES 1

inout: | 
...
vec3 diffuse = texture(p3d_Texture0, terrain_uv * 16.0).xyz;

... When the last line is commented out, there is no problem, otherwise there's the error message:

:display:gsg:glgsg(error): glUniform3fv has failed to set the uniform at location '10': the uniform's type, component size, or matrix dimensions are incompatible with the function variant (GL_INVALID_OPERATION) :display:gsg:glgsg(error): glUniform3fv has failed to set the uniform at location '10': the uniform's type, component size, or matrix dimensions are incompatible with the function variant (GL_INVALID_OPERATION) :display:gsg:glgsg(error): glUniform2iv has failed to set the uniform at location '11': the uniform's type, component size, or matrix dimensions are incompatible with the function variant (GL_INVALID_OPERATION) ...(repeating)

The texture is set like in the panda3d shader terrain sample program.

In fact, by replaceing the line "vec3 diffuse = texture(p3d_Texture0, terrain_uv * 16.0).xyz;" with just "p3d_Texture0", the error would persist. This happens on both rx6600 and gtx1050, but there is no error message on later, only the texture data is unusable.

sbxzy commented 2 years ago

I figured that out, just output generated shaders to a directory, and find the problem. I forgot where is the problem, but that is easy. It turns out you can add arbitrary texture to terrains.