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 / How to scale texture stages for textureblend.fx (HELP)

Author
Message
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 27th Nov 2011 09:37
I am using textureblend.fx I have made my Stages but how can i scale each stage differently on my terrain
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Nov 2011 16:29
Quote: "I am using textureblend.fx"


What is that exactly?
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 27th Nov 2011 17:24
A shader that allows you to blend textures on my terrain using stages the first 2 stages which woud be 0 and 1 are for my color mask 3 is the base and 4,5,6,7 are the rest of the textures you are wanting to blend. when i use it it coms out ok but each texture uv needs its individual scale. i can scale object texture for the normal set terrain texture and i get the effect i want but its only the detail and base is there a way i can do this with all stages. either in code or in the fx file


thanks for all and any help
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 27th Nov 2011 21:34 Edited at: 27th Nov 2011 21:35
You have to do it in the HLSL shader.

What I *think* you want to do is have a UV scale for each texture stage.

To do this you (I think) perform this operation in the PIXEL shader. (I suppose you could pass a matrix from the VERTEX shader to the PIXEL shader) Either way you need to know what you want your UV values to be so you could even use a code Modifiable array.

What I *think* you are looking to do can be achieved any number of ways. Here are some quick examples.

In the vertex shader




In the Pixel shader



Of course there are other ways, but if this is what you are after then these examples should point you in the proper direction.
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 27th Nov 2011 22:43
i appreciate your help a little confused on where exactly these codes go in the fx file.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Nov 2011 23:24
I'd do it in the vertex shader using a cross between david w's two suggestions.

First of all add the following declarations as indicated (**)



Secondly, change the following lines in the vertex shader



to



For UVTiling1 and UVTiling2 use whatever values make sense in your application.

This assumes I've understood your question correctly.
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 27th Nov 2011 23:36
can i still use this to scale all 6 texture differently
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 28th Nov 2011 03:07 Edited at: 28th Nov 2011 03:09
Yes you can, keep in mind however that you will need to pack your UV coordinates into an array such as:

float4x4 UVTiling;

Because the vertex output struct wont hold the necessary up to eight UV coords you specify with texcoord0-8

Then address each element as necessary.

You can do this as an array address or as
UVTiling[0].x;
or
UVTiling._11;

Either way will provide the same results its really up to your preference
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 29th Nov 2011 20:40
I think I understand appreciate it guys. Keep you posted
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 29th Nov 2011 20:46
I have another question. How can I implement a light system for the shader. I notice the textures a bright and lights. Dont effect them. I may want a night level and they need to be dark except in light. How can this be achieved.
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 1st Dec 2011 04:16
Why don't you post what you already have for your shader and we can take a look at it. What you want to do is add a directional light. Keep in mind that because you are using custom UV coordinates for this system you will need to set them for each mesh that will be using this shader.
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 5th Dec 2011 23:08
Hi David Sorry for not posting sooner. I am working with textureblend.fx can be downloaded at the top of this post.
I did use the example you gave me for the pixel shader for tiling each texture seperatly.... Works great but believe me without yours and the guru of shaders(Green Gandalf) Help and me reading and rereading the fx file I would still be lost. Now my question on the lights are this....My terrain using the textureblend for tiling has very bright textures cause there is no light in the shader how is it possible to implement a light into the same shader so that i may be able to change lighting because now that i am using the the shader for my terrain no light(that is set terrain light command no longer works do to the shader. how can a light be implemeted into the same shader..... Thanks for all help...More than you'll ever know.
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 5th Dec 2011 23:13 Edited at: 7th Dec 2011 02:05
Here is a screen shot of the shader lighting with any light commands in the shader
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 5th Dec 2011 23:17
Here is the the code After I have changed it
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Dec 2011 12:55
Something's wrong with the image you attached to your previous post. It won't open as an image file here - it seems to be a Paint Shop Pro Image file which I can't open. Could you replace it with a standard format such as .jpg, .png, etc?

Is your revised shader using the default vertex lighting used in Advanced Terrain? If so - and if it works - that's a good idea. I think you've made an error though. The DIFFUSE color should be a float4, i.e. the four channels rbga in that order. If your light colour is white then you won't notice the difference - but if it's green then you'd probably just get black since the red component (which you're currently using) would be zero. You might also need to replace this line



with



(even if it's not needed it's good practice because it makes the intention clearer).
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 6th Dec 2011 19:05
I "think" what is happening is since the mesh is now being processed by the shader the default FFP lighting no longer applies. I am 99% certian this is the scenario. What I "think" he wants to do is PerPixel Lighting. If this is what you are after, let us know and we can guide you through the process.

It would be much easier if you just uploaded a small sample project for us (I suppose I could just make one), with all the code in how you are setting up your level.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Dec 2011 00:29
Quote: "I "think" what is happening is since the mesh is now being processed by the shader the default FFP lighting no longer applies."


Yes.

Quote: "What I "think" he wants to do is PerPixel Lighting."


Yes, again (probably). It would also help if he said exactly what he wanted.
airforce1
17
Years of Service
User Offline
Joined: 2nd Apr 2009
Location:
Posted: 7th Dec 2011 02:20 Edited at: 7th Dec 2011 02:30
A little confused maybe on what exactly im looking for i really like the lighting in Battlefield 2. but where im lost on shaders as well is If i wanted to put shaders on the objects that will need them including the terrain,would i have to set up the same light system in each shader for each object then if the light hits a model like a building how can its shadow be casted on the terrain since it follows light with in its own effects. little confusing and trying to understand how all this comes together in a game..
but yes i believe i am wanting perpixel lighting. Right now i have over 4500 lines of code i could give you a piece of the terrain code
Now This is going to be a night level so night time lighting would be good but as well if there are lights from buildings through out the level would i have to create a light in the terrain effects for every light im going to have and position each light in the shader to the position i would have the light source in darkbasic. im not trying to over load with these questions but im at an important part in this game that i need to know how this is done in games like battlefield,farcry,ect



Just add some cam controls and

Login to post a reply

Server time is: 2026-07-10 05:45:48
Your offset time is: 2026-07-10 05:45:48