Trying to texture a "boulder" like mesh

Hello everyone. I recently added pillars to my game and I was able to properly scale the texture using the code:

var_texcoord0 = texcoord0 * p * 2;

where textcoord0 is “attribute mediump vec2 texcoord0;” and var_texcoord0 is “varying mediump vec2 var_texcoord0;”

I am now trying to texture a boulder mesh the same way but regardless of the scalar I apply to var_texcoord0 the boulder appears as just a coloured object without texture detail. If I change the texture the base color of the boulder changes. Is there something unique I have to do in order to scale a texture for a more complex mesh? Thanks for any help anyone can provide :slight_smile:

( Edit: First time I read your post I read it wrong. )

Post a sample! :slight_smile: A sample to mess with will get results.

Try a triplanar material for the complex mesh.

It really depends on your UVs / how you use them I think. Others may give a better answer.

3 Likes

Thank you! I now see the model properly textured in the editor. However, I am wondering how I can get the mesh from the model object in lua code? I tried to get the mesh property but it doesn’t exist. I want to scale the collada dae model up by a factor in the code vs trying to work w/ a large model in Blender. P.S. thanks for all the help, I’m finding the lack of Defold related docs pretty frustrating but I hope I can contribute some info back to the community at some point.

Here’s the code I’m using to scale my column mesh object:

require "singletons"

first_init = true

function init(self)
	self.gop = gop.get()
	self.gop.objtype = hash("decor")
	if first_init then
		self.light = vmath.vector4(0, 0, 164, 1)
		go.set("#mesh", "light", self.light)

		local res = go.get("#mesh", "vertices")
		local buf = resource.get_buffer(res)
		self.box_positions = buffer.get_stream(buf, "position")

		for i=1,#self.box_positions do
			if i%3==0 then
				self.box_positions[i] = self.box_positions[i] * 64
			elseif i%3==1 then
				self.box_positions[i] = self.box_positions[i] * wall_width / 2
			else
				self.box_positions[i] = self.box_positions[i] * wall_height / 2
			end
		end
	end

	local pos = go.get_position()
	pos.z = pos.z + 65
	go.set_position(pos)
	first_init = false
end

However it requires access to a mesh to grab the vertices.

I gave up on trying to do this in the code. Instead I set the grid size in Blender to 32px per square. Then I exported the Collada DAE model with unwrapped UVs. After that I was able to properly texture a concrete slab which I think looks better for the level I’m working on right now:

1 Like

Hi,
I am new to Defold, and I’m looking for a triplanar material.
From your answer I imagine it might be available somewhere, am I missing it?

Thanks! :slight_smile: