I’m rendering to a texture after it’s altered and pushing that to a TerrainShaderMesh.
So, I render to this frame buffer and everything looks good when I push to the texture on the TerrainShaderMesh. When I try to save it, off of the texture on the TerrainShaderMesh, it appears to save each channel as it’s own pixel. If I only shade the r component, then the first pixel in the saved image is good and the second and third are blank.
props = FrameBufferProperties()
props.setRgbaBits(16, 16, 16, 0)
self.alt_buffer = base.win.makeTextureBuffer("terrainHeightMap",
self.texture_size.x,
self.texture_size.y,
self.heightmap_texture, True, props)
#version 130
// @formatter:off
uniform sampler2D p3d_Texture0;
uniform sampler2D heightmap_brush;
uniform float brush_strength;
uniform bool use_brush;
vec2 tex_size;
// Input from vertex shader
in vec2 texcoord;
in vec4 projector_texcoord;
void main() {
vec4 color = texture(p3d_Texture0, texcoord);
gl_FragColor = color;
// gl_FragColor = vec4(color.x, 0.0, 0.0, 0.0);
vec4 brush = vec4(0.0);
if(use_brush) {
if (projector_texcoord.x >= 0.0 && projector_texcoord.x <= 1.0 &&
projector_texcoord.y >= 0.0 && projector_texcoord.y <= 1.0) {
brush = textureProj(heightmap_brush, projector_texcoord);
gl_FragColor = color + brush * brush_strength;
// gl_FragColor = vec4(color.x, 0.0, 0.0, 1.0) + vec4(brush.x, 0.0, 0.0, 1.0) * brush_strength;
}
}
}