Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] How to overlay two textures?

Author
Message
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 19:07
I have a 3D object that has texture applied to it. I want to insert one extra texture above it (with alpha channel). How can I do it?

The author of this post has marked a post as an answer.

Go to answer

puzzler2018
User Banned
Posted: 24th Dec 2018 21:41
I dont think this can be done without memblock work

Can use SetObjectMeshFromMemblock to create objects with a different meshIndex

Objects have between 1-255 MeshIndexes which a different texture can be applied to.

If i have time this week, ill build something up for you to explain this theory




puzzler2018
User Banned
Posted: 24th Dec 2018 22:00
Do you happen to have a small snippet at all showing your example and what you like to acheive for us to work from?
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 22:27
I have a model that needs to show bruises after being punched.

Instead of replacing whole texture with same one that has additional bruises, I need to figure how to add these bruises as layers over the main texture.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Dec 2018 22:29
Shader my friend, use a shader.
puzzler2018
User Banned
Posted: 24th Dec 2018 22:31 Edited at: 24th Dec 2018 22:32
OK cool - so

- your image thats applied to the object,,

- how about using again image memblock work this time to add those darker points/dints anywhere on the memblock image

- reapply the new resulting image to the object.

Would that work for you?

Or as Santman suggests use incrediable shaders?

Are you new to AppGameKit at all?
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 22:38
It seems that SetObjectMeshImage() can do the trick. I need to do further investigation.
puzzler2018
User Banned
Posted: 24th Dec 2018 22:40
Ok cool - let us know of your how you get on.

psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 22:41
I am new to 3D in AGK. I know to use shaders only visually, like connecting nodes.

No matter if SetObjectMeshImage() will work or not, I am interested @puzzler2018 to see your version with using memblocks
puzzler2018
User Banned
Posted: 24th Dec 2018 22:43 Edited at: 24th Dec 2018 22:44
Sure no worries...

I will produce image memblocks with decals.. in a sense bullets onto an image to re apply to an object

Will need to be Wednesday.

That ok?
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Dec 2018 22:43
Add objectmeshtexture will set seperate textures on seperate meshes, it won;t add them on top of each other on the same mesh.

By default you can assign up to 8 images to a mesh, but you will need to control how they change, either manually or with different images. For example, if the head is a seperate mesh, then you can have four images for normal, light, medium and heavy bruising, then you just manually adjust the texture so that a different one appears. That's the easy route.

A shader would, in theory, allow you to control the exact amount of bruising that came through, but you would need to either use a memblock or a seperate render image to control that.
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 22:49
That's super OK Puzzler, thanks for your help!


Thanks Santman for explanation.
puzzler2018
User Banned
Posted: 24th Dec 2018 22:52
Or indeed check out my Lemmings thread to see image memblocks at work

[img]null[/img]https://forum.thegamecreators.com/thread/223399

Have a nice Xmas Day with family
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 24th Dec 2018 23:03
will do, thank you and Merry Christmas!
puzzler2018
User Banned
Posted: 24th Dec 2018 23:37 Edited at: 24th Dec 2018 23:45
Soemthing to get you started



Press left mouse button for a bullet shot
puzzler2018
User Banned
Posted: 24th Dec 2018 23:56 Edited at: 24th Dec 2018 23:56
Im thinking Dartboard game - Genius
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 25th Dec 2018 21:38
Ok, I am realizing where is what in your example.

I have a question, aside from your example:

Is it possible in background to
- take a model texture and make a sprite out of that image
- take a bruises textures as sprite and put it above model image.
-print that overlay sprites in backbuffer
- use that print image as a new texture for the model

I hope I was clear what I am asking: to create two separate sprites from model texture and additional bruises image, overlay these two sprites, render them outside as an image and use that new image as a new texture.
puzzler2018
User Banned
Posted: 25th Dec 2018 21:50
Ok cool

Ill have a think...

I think you can have texture stages on images which will be a diffuse image, normal image, and some others when using

setobjectimage ( objectID , textureimageID, textureStage)

But Im 100% sure at the moment what these would really achieve for you request.

Interesting though and certainly worth a think over.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Dec 2018 00:10
This post has been marked by the post author as the answer.
If you want to use several layers of textures
you use a shader (up to 7 textures)
you then can use a blend shader to blend layer 1 with layer 0 for example
please see the shader thread for examples by blendman
https://forum.thegamecreators.com/thread/214598
fubar
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 26th Dec 2018 12:58
I was able to make shader work on pc, however when I run it on a cellphone I am getting an error that you can see in attachment

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Dec 2018 13:12
Its a declaration error where uv1varying is not declared in one of the files

If you show the ps and vs file as code snippets here i may be able to help
im not sure why it worked on pc tho
fubar
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 26th Dec 2018 13:33
Basically I just copy/paste blendman shader script as you suggested


MERGE.ps





MERGE.VS
puzzler2018
User Banned
Posted: 26th Dec 2018 13:40 Edited at: 26th Dec 2018 13:40
Perhaps add

varying vec2 uv1Varying;

into the the Vertex shader file.

But thats as far as i go with Shader work - knowledge is zilch im afraid
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Dec 2018 13:43
Looks in order but perhaps
try this for merge. vs

fubar
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 26th Dec 2018 14:18
It's working, but now I lost animation (bone) controls :\
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Dec 2018 20:50 Edited at: 26th Dec 2018 20:50
Quote: "It's working, but now I lost animation (bone) controls :\"

The shader only effects the drawn pixels 1 pixel at a time hence why they can be slow on mobiles
but there is a default/basic shader that all agk programs use. The shader don't effect the animations
only how they are displayed.

If the bone animations have stopped working its a problem with the code or possibly speed of the device
fubar
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 26th Dec 2018 21:17 Edited at: 26th Dec 2018 21:18
Its because your vertex shader has no bone information in it.



Attached is the default bone vertex shader. You may need to add any missing variables, and pass them to the pixel shader.

uniform highp vec4 agk_bonequats1[28];
uniform highp vec4 agk_bonequats2[28];

The 28 is how many bones you have. Although, I believe you can just put in 100, and I have noticed no difference.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Dec 2018 21:52
Thanks Golelorn, I stand corrected wasn't sure it would effect bones
fubar
puzzler2018
User Banned
Posted: 27th Dec 2018 18:03
Say If you have a large UV Mapped image say 1900 by 300 to apply to a model then can use this to apply a red mark to where a the body image part is

Say for example the actual body is around
X - 950 to 1280
Y - 0 to 300

on that image then...



Login to post a reply

Server time is: 2024-11-23 09:11:35
Your offset time is: 2024-11-23 09:11:35