sprite bump mapping

Fidelity

New member
Joined
Jun 21, 2021
Messages
1
I would like to be able to load a sprite (Image) with a diffuse, specular and normal map, from 3 files and would really like an example how to do that please if anyone knows of one.
Looking at the API it has to do with BumpShader() but I'm not sure how it knows which texture is which.

Is it something like this? ::

Code:
Local color: = Texture.Load("/path/to/texture")

Local norm := Texture.Load("/path/to/texture")

Local spec := Texture.Load("/path/to/texture")



Local myMaterial := New Material(Shader.BumpShader())

myMaterial.SetTexture("ColorTexture", color)

myMaterial.SetTexture("NormalTexture", norm)

myMaterial.SetTexture("SpecularTexture", spec)

myMaterial.SetVector("AmbientColor", [0.0, 0.0, 0.0, 1.0])



Local myImage:Image = New Image(myMaterial, 0.5, 0.5)

Update:
I've just looked at the example directlight and it simply loads an image. There is no loading diffuse, specular and normal maps however those 3 image files are in the same directory as each other. So I'm wondering if you just need to name the files correctly, put them in the same directory it works automatically.
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
Hi Fifelity and welcome to the forum. As you might have guest it, mojo2 loads the normal and bump map automatically. If they have the correct naming, like in that directlight example. This is the internal code that loads a texture. You you provide an extra image for each the specular and for normals, then you just have to load its diffuse image.

1626378434425.png
 
Top Bottom