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.

DarkBASIC Professional Discussion / Shader and Texture Tiling(or Stretching) - Please help!

Author
Message
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 10th Jan 2017 23:38
Hi guys,

I am using Evolved's parlallax mapping for my project.

The problem is that in my project the user is able to scale the object. However, when this texture is applied, the texture on the object stretches along with the object. I want to do the following if its possible: To manually shrink the object's texture which i found impossible with scale object texture objnum, 0(or 1 or 2), 5, 5. Or, even a better idea but i am not really sure if this is possible: To automatically scale the texture(so, creating tiles) as long as the object stretches.

In this post i've attached the shader.

Thank you very much for your time to help me!
Alex Matei CEO
www.alexmatei.com

Attachments

Login to view attachments
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 11th Jan 2017 00:35
I think you only can set Uv scale in shader by DBPro : OUT.Tex=IN.UV*Scale.xy
Or you can link UV scale and object scale ( if object scales equally on all three dimensions (xyz) )
Object position, scale, rotation can be get by World matrixes inside shader.
For example position=float3(World._m30,World._m31 ,World._m32)
Get scale value is a bit complicated. Sorry I lost code for it

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 11th Jan 2017 10:50
Hi Kuper,

I am pretty rubbish with hlsl. Is there a possibility to build up an example at least from the code you pasted there or something?

Thank you!
Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 11th Jan 2017 18:39
Anyone got any other ideas?

Thank you!
Alex Matei CEO
www.alexmatei.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jan 2017 09:04
The problem is that you can of course set the UV scale with a variable in a shader - but that applies to the shader, so if the same shader was used on 2 objects, both objects would have the UV cords scaled. If one object was a wall that you scaled the UV on to look better, and the second object was a character, well the character texturing would go to hell... this should only ever apply to objects that use repeating textures, and there's no standard scale that you want to apply globally, so you can't really do much directly in the shader, not without having more than one instance of the shader (bad idea). So inside the HLSL shader you can have a variable that you can modify inside DBPro, and this can easily be used to multiply the UV coordinates, but that applies to any object that is using that shader.

I think your best option is to modify the vertex data of the object you want to scale textures on, like step through each vertex and multiply the UV coordinates. It's quite straightforward, probably not as complicated as it sounds - actually the only tricky part is figuring out how the object should be locked for vertex modification. The object would probably have to be checked for how many limbs it has, then step through the limbs one by one, and each vertex for each limb. It would be best with this idea to have a simple reset button - so if you press that it re-loads the object and resets any messing you've done with the UV cords - mainly just because scaling the UV cords in this way will be permanent, so it would be very difficult or impossible to get the UV cords back to what they were... easier to just forget the modifications and reload the object.
The code is dark and full of errors
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jan 2017 13:56
Hey VanB,

Thank you so much for the details. I really forgot that if you apply in the shader the scaling code, it will obviously change the other objects indeed!

I'll try to see how can i do with the vertex stuff.

Is it ok to start with "lock object vertex" or how it was?
Alex Matei CEO
www.alexmatei.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jan 2017 14:13
I have a few functions that use the vertexdata commands, I will get an example to you tonight.
The code is dark and full of errors
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jan 2017 14:18
Very nice of you VanB! I can't wait , really! Thank you again!

And also thank you kuper for the other info!

I will be waiting the function!
Alex Matei CEO
www.alexmatei.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jan 2017 20:48
Here's that example. Really it just boils down to that VertexUVScale(obj,scaleu#,scalev#) function, just pass the object number and scale values to it, most of the code is just to show how it works.

The code is dark and full of errors
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jan 2017 21:01
Hi VanB,

Thank you so much for the example!

I tested the demo, it works really well but on my application i did the following: Just imported an object with the number 1 and changed the code instead of obj i pasted in "1". I then clicked the mouse as it says in the code but nothing happened(The object already got textured and shaded!)
Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jan 2017 21:05
I pasted the raw code now as it was without any modifications i saw later that the function call has an object requirement to put in. But still no results though
Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2024-04-24 03:28:57
Your offset time is: 2024-04-24 03:28:57