quindo Posted April 26, 2016 Posted April 26, 2016 Hello everyone, I've implemented a improvised bump map shader, that uses a normal map texture of an object. The thing is that every object needs to have custom texture, so 1 texture for 1 object, as for now i know only how to use it for single object. I can't just use engineApplyShaderToWorldTexture(shader,"*"), because it applies the same texture to every object. How can i make it use different textures for different objects? Here's current example showing the difference that the shader makes(open in 2 tabs and compare them): http://i.imgur.com/BWYPR5Y.jpg http://i.imgur.com/t7Yvsmr.jpg
Ren_712 Posted April 26, 2016 Posted April 26, 2016 engineApplyShaderToWorldTexture(shader,"*", targetElement) The targetElement is the object You want to apply the shader to.
quindo Posted April 26, 2016 Author Posted April 26, 2016 Ren_712: Yeah, i use it already, the problem is that i use this kind of maps: https://imgur.com/4YNmVv0 so every object needs different texture, and the shader is able to use only one unique texture.
Captain Cody Posted April 26, 2016 Posted April 26, 2016 I didn't understand a word of what you just said quind. Please state your question a bit more clearly.
quindo Posted April 26, 2016 Author Posted April 26, 2016 Okay, sorry, i guess it was written in a bit of a rush. The thing is that i created the shader that applies bump map to custom object (the rocks in my first 2 screenshots), the original texture is mixed with the normal map (screenshot in my last reply). The shader takes the normal as a Value like this: normal = dxCreateTexture("normal/kamienie_nororg.jpg") dxSetShaderValue(shader,"Tex0",normal) engineApplyShaderToWorldTexture(shader,"kamienie") I want to use the same shader for more than 1 object, which means that i need to give every object it's custom texture. I'm looking for the best way to do it.
Captain Cody Posted April 27, 2016 Posted April 27, 2016 Use a table to define the textures, then define the shader with local and set the local shaders value, then apply it. If that makes sense. textures = {{"texturename","Something.png"},{"texturename2","Something2.png"}} for i,v in pairs (texutres) do local shader = dxCreateShader( "whatever.fx" ) local normal = dxCreateTexture("normal/"..v[2]) dxSetShaderValue(shader,"Tex0",normal) engineApplyShaderToWorldTexture(shader,v[1]) end
quindo Posted April 27, 2016 Author Posted April 27, 2016 Thank You! It's exactly what i needed, sorry for explaining it so bad in the first place.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now