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 / Coloured shaders or stained glass?

Author
Message
C0wbox
17
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 5th Apr 2010 18:03
Does anyone know how to colour shaders or make stained glass?

I've got countless refracty shaders but I can't make any of them like a particular colour... - If I had some kind of an image I could apply as colouring or a colour I could apply to the whole thing, that would be handy.

Can anyone suggest anything?

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Apr 2010 18:23
I would add the texture to the shader itself, so that it can be applied with code - then take that texture, and add the output to the refracted output, and normalize.

I'm sure it's possible to do it that way, like have a translucent stained glass texture that is included with the shader output. I'm sure some shader guru will come along and make it really easy, but it might be worth having a go yourself, no harm in messing with copies of your shaders, maybe check a texture blend shader like GG's to see if the texturing can apply to the refraction shader as well. It has to get that normal texture reading, so perhaps the shader could get the colour image data as well.

If you can figure that out though, then you'll be able to apply the colouring any way you like - either mixing with the refraction colour of each pixel, or use it as a base colour and use the refraction data to shade it. It may be possible to factor in that Z component in the normal map (height) and use that to change the strength of the transparency - thinner and thicker stained glass would look great.


Health, Ammo, and bacon and eggs!
C0wbox
17
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 5th Apr 2010 21:01


I'm GLaD you understood that. xD

I get what you're on about but I have no idea how to code shaders and the like, so I'd have no idea what I'm doing and eventually end up making a complete mess of it. !

<Waits for GG or someone>


Serial Velocity
15
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 5th Apr 2010 21:20
You could simply multiply the shaders output by a certain colour value, for example at the end of the pixel shader, it could have something like:



to colour the result, simply change it to something like this:



which will make it a very deep red. Play around with the first 3 values of the float4 until you get the colour you want. The last float value is the alpha which you probably don't want to touch unless you want the glass to be translucent.

C0wbox
17
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 5th Apr 2010 22:27 Edited at: 5th Apr 2010 22:29
Oo, that might help, I'll have a go at that.

EDIT:

! That's excellent - exactly what I was looking for, thanks.

Login to post a reply

Server time is: 2024-03-29 08:06:25
Your offset time is: 2024-03-29 08:06:25